@@ -10,12 +10,17 @@ import { Authorizer } from "../../policies/authorizers/Authorizer";
1010/**
1111 * A TicketingStrategy that simply stores provided Claims, and calculates all
1212 * available Permissions from them upon resolution.
13+ *
14+ * If `allowPartialSuccess` is set to true,
15+ * the strategy will return all available permissions,
16+ * even if not all required permissions are granted.
1317 */
1418export class ImmediateAuthorizerStrategy implements TicketingStrategy {
1519 protected readonly logger = getLoggerFor ( this ) ;
1620
1721 constructor (
1822 protected authorizer : Authorizer ,
23+ protected readonly allowPartialSuccess = false ,
1924 ) { }
2025
2126 /** @inheritdoc */
@@ -45,9 +50,12 @@ export class ImmediateAuthorizerStrategy implements TicketingStrategy {
4550
4651 const permissions = await this . calculatePermissions ( ticket ) ;
4752
53+ // Always fail if no results at all, even with allowPartialSuccess
4854 if ( permissions . length === 0 ) return Failure ( [ ] ) ;
4955
50- // TODO: if, in the future, we want to allow partial results, this will need to change
56+ // With partial success enabled, any non-empty authorization result is accepted
57+ if ( this . allowPartialSuccess ) return Success ( permissions ) ;
58+
5159 // Verify all required scopes have been granted
5260 const unmatchedPermissions : Permission [ ] = [ ] ;
5361 for ( const required of ticket . permissions ) {
0 commit comments