Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion packages/authorization/src/authorize-interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,18 @@ export class AuthorizationInterceptor implements Provider<Interceptor> {
error.statusCode = this.options.defaultStatusCodeForDeny;
throw error;
}
return next();
const restrictedProperties: string[] = await invocationCtx.get(
AuthorizationTags.RESTRICTED_FIELDS,
);
const result = await next();
if (result && restrictedProperties) {
restrictedProperties.forEach(property => {
if (typeof result === 'object') {
delete (result as Record<string, unknown>)[property];
}
});
}
return result;
}
}

Expand Down
4 changes: 4 additions & 0 deletions packages/authorization/src/keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,8 @@ export namespace AuthorizationTags {
* A tag for authorizers
*/
export const AUTHORIZER = 'authorizer';
/**
* A tag for restricted fields
*/
export const RESTRICTED_FIELDS = 'restricted.fields';
}
Loading