Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ describe('Authorization', () => {
},
]);
expect(orderId).to.eql('order-1');
expect(events).to.containEql('OrderController.prototype.placeOrder');
expect(events).to.eql(['OrderController.prototype.placeOrder']);
});

it('denies cancelOrder for regular user', async () => {
const result = invokeMethod(controller, 'cancelOrder', reqCtx, [
'order-01',
]);
await expect(result).to.be.rejectedWith('Access denied');
expect(events).to.containEql('OrderController.prototype.cancelOrder');
expect(events).to.eql(['OrderController.prototype.cancelOrder']);
});

class Order {
Expand Down
7 changes: 1 addition & 6 deletions packages/authorization/src/authorize-interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
config,
Context,
filterByTag,
inject,
Interceptor,
InvocationContext,
Next,
Expand All @@ -37,8 +35,6 @@ export class AuthorizationInterceptor implements Provider<Interceptor> {
private options: AuthorizationOptions;

constructor(
@inject(filterByTag(AuthorizationTags.AUTHORIZER))
private authorizers: Authorizer[],
@config({fromBinding: AuthorizationBindings.COMPONENT})
options: AuthorizationOptions = {},
) {
Expand Down Expand Up @@ -87,13 +83,12 @@ export class AuthorizationInterceptor implements Provider<Interceptor> {
};

debug('Security context for %s', description, authorizationCtx);
let authorizers = await loadAuthorizers(
const authorizers = await loadAuthorizers(
invocationCtx,
metadata.voters ?? [],
);

let finalDecision = this.options.defaultDecision;
authorizers = authorizers.concat(this.authorizers);
for (const fn of authorizers) {
const decision = await fn(authorizationCtx, metadata);
debug('Decision', decision);
Expand Down