@vcita/oauth-client-nestjs 4.1.0 → 5.0.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -0
- package/README.md +44 -0
- package/dist/oauth/guards/api-scope.guard.d.ts +22 -0
- package/dist/oauth/guards/api-scope.guard.js +95 -0
- package/dist/oauth/guards/api-scope.guard.js.map +1 -0
- package/dist/oauth/guards/index.d.ts +1 -0
- package/dist/oauth/guards/index.js +1 -0
- package/dist/oauth/guards/index.js.map +1 -1
- package/dist/oauth/interfaces/oauth.interface.d.ts +2 -0
- package/dist/oauth/oauth.module.js +8 -0
- package/dist/oauth/oauth.module.js.map +1 -1
- package/dist/oauth/tests/mock-oauth.middleware.js +1 -1
- package/dist/oauth/tests/mock-oauth.middleware.js.map +1 -1
- package/dist/oauth/utils/authentication.utils.d.ts +1 -0
- package/dist/oauth/utils/authentication.utils.js +6 -1
- package/dist/oauth/utils/authentication.utils.js.map +1 -1
- package/dist/permissions/index.d.ts +1 -0
- package/dist/permissions/index.js +3 -1
- package/dist/permissions/index.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,39 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
6
6
|
|
|
7
7
|
___
|
|
8
8
|
# Releases
|
|
9
|
+
## Unreleased
|
|
10
|
+
### Added
|
|
11
|
+
- `ApiScopeGuard`: a global guard enforcing the `infra/requiredScopes` metadata that infra-nestjs's
|
|
12
|
+
`@ApiControllerScope` / `@ApiMethodScope` declare on routes. Opt in per service with
|
|
13
|
+
`OauthModule.register({ enforceApiScopes: true })`. Decision table: no declaration → allow; actor holds
|
|
14
|
+
a legacy scope → allow; actor holds any one declared scope → allow; otherwise 403
|
|
15
|
+
`insufficient_scope`. A scoped route reached with no authenticated actor answers 401, misdeclared routes included
|
|
16
|
+
- `legacyScopes` module option: the scopes the guard accepts as a legacy wildcard, defaulting to
|
|
17
|
+
`['all', 'admin']` — the two values core mints for tokens without capability scopes (`admin` is what the
|
|
18
|
+
static admin token and service identities carry). Narrow it per service to retire the allowance. `register`
|
|
19
|
+
throws when the value is not a list of scope names
|
|
20
|
+
- The guard denies (403 `unenforceable_scope`) two declarations no token could ever satisfy, which
|
|
21
|
+
infra-nestjs only warns about at boot: a derived `@ApiMethodScope` on a controller without
|
|
22
|
+
`@ApiControllerScope`, and a route on a scoped controller (own or inherited) that derives no scope
|
|
23
|
+
- `AuthenticationUtils.parseScopes`: normalizes the `scp` claim from a space- or comma-separated string, or an
|
|
24
|
+
array, into a deduplicated `scopes: string[]`
|
|
25
|
+
|
|
26
|
+
### Changed
|
|
27
|
+
- `@vcita/infra-nestjs` peer dependency floor moves from `^2.23.1` to `^3.0.0-rc.0`. The guard reads the
|
|
28
|
+
`infra/requiredScopes`, `infra/scopeAction` and `infra/scopeDomain` metadata that 3.0.0 is the first release to emit
|
|
29
|
+
|
|
30
|
+
### Fixed
|
|
31
|
+
- `MockAuthMiddleware` (what `OauthMocker` installs in e2e tests) dropped the bearer's `scopes`, so no e2e
|
|
32
|
+
test could reach `ApiScopeGuard` with a scope. It now carries the array the JSON bearer holds, and keeps
|
|
33
|
+
the old `null` when there is none
|
|
34
|
+
- `scp` was split on commas only, so the space-separated multi-scope claim core mints for an Okta admin
|
|
35
|
+
collapsed into one bogus scope and an array claim crashed the parser. Legacy single-scope tokens
|
|
36
|
+
(`scp: "all"`) parse exactly as before; a JWT without `scp` is still rejected with 401
|
|
37
|
+
|
|
38
|
+
## 4.2.0 (2025-09-30)
|
|
39
|
+
### Added
|
|
40
|
+
- Export `RequirePermissionsGuard` class to enable mocking it in tests
|
|
41
|
+
|
|
9
42
|
## 4.1.0 (2025-04-27)
|
|
10
43
|
### Added
|
|
11
44
|
- User-Agent header to internal/infra proxy service requests, set to APP_NAME env-var
|
package/README.md
CHANGED
|
@@ -76,6 +76,50 @@ OauthModule.register({ mainRoute: '' })
|
|
|
76
76
|
> :warning: **Note!**
|
|
77
77
|
> The interface will be changed on version 2.0.0
|
|
78
78
|
|
|
79
|
+
### Enforcing endpoint scopes
|
|
80
|
+
Routes declare the scopes they accept with infra-nestjs's `@ApiControllerScope` / `@ApiMethodScope`
|
|
81
|
+
(see its README, "API scopes"). This package supplies the guard that enforces those declarations at
|
|
82
|
+
request time, against the `scopes` the `AuthMiddleware` parsed out of the internal JWT's `scp` claim.
|
|
83
|
+
It is off by default; a service adopts it deliberately:
|
|
84
|
+
```typescript
|
|
85
|
+
OauthModule.register({ enforceApiScopes: true })
|
|
86
|
+
```
|
|
87
|
+
With it on, `ApiScopeGuard` runs globally and decides per route:
|
|
88
|
+
|
|
89
|
+
| Route declares | Actor holds | Result |
|
|
90
|
+
|------------------------------------|--------------------------------------|---------------------------------|
|
|
91
|
+
| nothing | anything, or nobody authenticated | allow |
|
|
92
|
+
| scopes | a legacy scope, `all` or `admin` | allow (rollout allowance) |
|
|
93
|
+
| scopes | any one of the declared scopes | allow |
|
|
94
|
+
| scopes | none of them | 403 `insufficient_scope` |
|
|
95
|
+
| scopes | no authenticated actor | 401 |
|
|
96
|
+
| a scope no token can satisfy | any authenticated actor, `all` included | 403 `unenforceable_scope` |
|
|
97
|
+
| a scope no token can satisfy | no authenticated actor | 401 |
|
|
98
|
+
|
|
99
|
+
The 403 row covers two declaration defects infra-nestjs only warns about at boot: a derived
|
|
100
|
+
`@ApiMethodScope(action)` on a controller that has no `@ApiControllerScope`, and a route on a scoped
|
|
101
|
+
controller that derives no scope from its verb (`@All()`, `@Head()`, `@Options()`, or an undecorated
|
|
102
|
+
subclass's own routes). The 403 message names the fix. Declare such a route explicitly with
|
|
103
|
+
`@ApiMethodScope(ScopeAction.CUSTOM, ...)`, or give the subclass its own `@ApiControllerScope`. An
|
|
104
|
+
anonymous caller never sees that message: the actor check runs first on every scoped route.
|
|
105
|
+
|
|
106
|
+
**Before turning the flag on**, look through every controller that carries `@ApiControllerScope` for
|
|
107
|
+
an `@All()`, `@Options()` or `@Head()` handler, such as a CORS preflight or a catch-all. Those handlers
|
|
108
|
+
were never meant to carry a scope, and with the guard on they answer 403 until they declare one with
|
|
109
|
+
`ScopeAction.CUSTOM` or move to a controller without a domain.
|
|
110
|
+
|
|
111
|
+
The legacy allowance covers the two scope values core mints for tokens that predate capability
|
|
112
|
+
scopes: `all` for session and app tokens, and `admin` for admin-typed principals that carry no scopes
|
|
113
|
+
at all, which is what the static admin token and service identities get. Holding one means the token
|
|
114
|
+
is trusted by actor type, which the actor guard still checks. It is a rollout decision, not a
|
|
115
|
+
permanent one, and each service retires it on its own schedule through `legacyScopes`:
|
|
116
|
+
```typescript
|
|
117
|
+
OauthModule.register({ enforceApiScopes: true, legacyScopes: ['all'] }) // no longer honour admin
|
|
118
|
+
OauthModule.register({ enforceApiScopes: true, legacyScopes: [] }) // capability scopes only
|
|
119
|
+
```
|
|
120
|
+
`register` throws when `legacyScopes` is present but is not a list of scope names, so a wrong value cannot
|
|
121
|
+
fall back to the default allowance unnoticed.
|
|
122
|
+
|
|
79
123
|
### Consuming Platform APIs
|
|
80
124
|
#### Internal Services
|
|
81
125
|
As an _Internal Service_ you have 2 options to consume a _Platform API_:
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { CanActivate, ExecutionContext, ForbiddenException } from '@nestjs/common';
|
|
2
|
+
import { Reflector } from '@nestjs/core';
|
|
3
|
+
import { ConfigService } from '@nestjs/config';
|
|
4
|
+
import { ApplicationConfig } from '../interfaces';
|
|
5
|
+
export declare const DEFAULT_LEGACY_SCOPES: readonly string[];
|
|
6
|
+
export declare class InsufficientScopeException extends ForbiddenException {
|
|
7
|
+
readonly requiredScopes: string[];
|
|
8
|
+
constructor(requiredScopes: string[]);
|
|
9
|
+
}
|
|
10
|
+
export declare class UnenforceableScopeException extends ForbiddenException {
|
|
11
|
+
constructor(route: string, reason: string);
|
|
12
|
+
}
|
|
13
|
+
export declare class ApiScopeGuard implements CanActivate {
|
|
14
|
+
private readonly reflector;
|
|
15
|
+
private readonly configService;
|
|
16
|
+
constructor(reflector: Reflector, configService: ConfigService<ApplicationConfig>);
|
|
17
|
+
canActivate(context: ExecutionContext): boolean;
|
|
18
|
+
private legacyScopes;
|
|
19
|
+
private requireActor;
|
|
20
|
+
private routeName;
|
|
21
|
+
private declarationDefect;
|
|
22
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ApiScopeGuard = exports.UnenforceableScopeException = exports.InsufficientScopeException = exports.DEFAULT_LEGACY_SCOPES = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const core_1 = require("@nestjs/core");
|
|
15
|
+
const config_1 = require("@nestjs/config");
|
|
16
|
+
const infra_nestjs_1 = require("@vcita/infra-nestjs");
|
|
17
|
+
const authentication_utils_1 = require("../utils/authentication.utils");
|
|
18
|
+
exports.DEFAULT_LEGACY_SCOPES = ['all', 'admin'];
|
|
19
|
+
class InsufficientScopeException extends common_1.ForbiddenException {
|
|
20
|
+
constructor(requiredScopes) {
|
|
21
|
+
super(`Insufficient scope, requires one of: ${requiredScopes.join(' ')}`, 'insufficient_scope');
|
|
22
|
+
this.requiredScopes = requiredScopes;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.InsufficientScopeException = InsufficientScopeException;
|
|
26
|
+
class UnenforceableScopeException extends common_1.ForbiddenException {
|
|
27
|
+
constructor(route, reason) {
|
|
28
|
+
super(`Route ${route} declares scope enforcement but no scope can satisfy it: ${reason}`, 'unenforceable_scope');
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.UnenforceableScopeException = UnenforceableScopeException;
|
|
32
|
+
let ApiScopeGuard = class ApiScopeGuard {
|
|
33
|
+
constructor(reflector, configService) {
|
|
34
|
+
this.reflector = reflector;
|
|
35
|
+
this.configService = configService;
|
|
36
|
+
}
|
|
37
|
+
canActivate(context) {
|
|
38
|
+
var _a;
|
|
39
|
+
if (context.getType() !== 'http')
|
|
40
|
+
return true;
|
|
41
|
+
const requiredScopes = this.reflector.get(infra_nestjs_1.REQUIRED_SCOPES_KEY, context.getHandler());
|
|
42
|
+
if (requiredScopes === undefined) {
|
|
43
|
+
const defect = this.declarationDefect(context);
|
|
44
|
+
if (!defect)
|
|
45
|
+
return true;
|
|
46
|
+
this.requireActor(context);
|
|
47
|
+
throw new UnenforceableScopeException(this.routeName(context), defect);
|
|
48
|
+
}
|
|
49
|
+
const auth = this.requireActor(context);
|
|
50
|
+
const actorScopes = (_a = auth.scopes) !== null && _a !== void 0 ? _a : [];
|
|
51
|
+
const legacyScopes = this.legacyScopes();
|
|
52
|
+
if (actorScopes.some((scope) => legacyScopes.includes(scope)))
|
|
53
|
+
return true;
|
|
54
|
+
if (requiredScopes.some((scope) => actorScopes.includes(scope)))
|
|
55
|
+
return true;
|
|
56
|
+
throw new InsufficientScopeException(requiredScopes);
|
|
57
|
+
}
|
|
58
|
+
legacyScopes() {
|
|
59
|
+
var _a;
|
|
60
|
+
return (_a = this.configService.get('legacyScopes')) !== null && _a !== void 0 ? _a : exports.DEFAULT_LEGACY_SCOPES;
|
|
61
|
+
}
|
|
62
|
+
requireActor(context) {
|
|
63
|
+
const auth = authentication_utils_1.AuthenticationUtils.getAuthorizationPayloadEntity(context);
|
|
64
|
+
if (!auth) {
|
|
65
|
+
throw new common_1.UnauthorizedException('Scoped endpoint requires an authenticated actor');
|
|
66
|
+
}
|
|
67
|
+
return auth;
|
|
68
|
+
}
|
|
69
|
+
routeName(context) {
|
|
70
|
+
return `${context.getClass().name}.${context.getHandler().name}`;
|
|
71
|
+
}
|
|
72
|
+
declarationDefect(context) {
|
|
73
|
+
const handler = context.getHandler();
|
|
74
|
+
const controller = context.getClass();
|
|
75
|
+
if (this.reflector.get(infra_nestjs_1.SCOPES_ACTION_KEY, handler) !== undefined) {
|
|
76
|
+
return (`@ApiMethodScope was given an action but ${controller.name} has no ` +
|
|
77
|
+
'@ApiControllerScope to derive the scope from');
|
|
78
|
+
}
|
|
79
|
+
if (this.reflector.get(infra_nestjs_1.SCOPE_DOMAIN_KEY, controller) === undefined)
|
|
80
|
+
return undefined;
|
|
81
|
+
if (Reflect.hasOwnMetadata(infra_nestjs_1.SCOPE_DOMAIN_KEY, controller)) {
|
|
82
|
+
return (`${controller.name} is scoped but this route derives no scope from its verb; ` +
|
|
83
|
+
'declare it with @ApiMethodScope(ScopeAction.CUSTOM, ...)');
|
|
84
|
+
}
|
|
85
|
+
return (`${controller.name} inherits a scope domain from a base controller but declares none of its own; ` +
|
|
86
|
+
'add @ApiControllerScope to it');
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
ApiScopeGuard = __decorate([
|
|
90
|
+
(0, common_1.Injectable)(),
|
|
91
|
+
__metadata("design:paramtypes", [core_1.Reflector,
|
|
92
|
+
config_1.ConfigService])
|
|
93
|
+
], ApiScopeGuard);
|
|
94
|
+
exports.ApiScopeGuard = ApiScopeGuard;
|
|
95
|
+
//# sourceMappingURL=api-scope.guard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"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,gCAAiB,EAAE,OAAO,CAAC,KAAK,SAAS,EAAE;YAChE,OAAO,CACL,2CAA2C,UAAU,CAAC,IAAI,UAAU;gBACpE,8CAA8C,CAC/C,CAAC;SACH;QAED,IAAI,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,+BAAgB,EAAE,UAAU,CAAC,KAAK,SAAS;YAAE,OAAO,SAAS,CAAC;QAErF,IAAI,OAAO,CAAC,cAAc,CAAC,+BAAgB,EAAE,UAAU,CAAC,EAAE;YACxD,OAAO,CACL,GAAG,UAAU,CAAC,IAAI,4DAA4D;gBAC9E,0DAA0D,CAC3D,CAAC;SACH;QACD,OAAO,CACL,GAAG,UAAU,CAAC,IAAI,gFAAgF;YAClG,+BAA+B,CAChC,CAAC;IACJ,CAAC;CACF,CAAA;AAzEY,aAAa;IADzB,IAAA,mBAAU,GAAE;qCAGmB,gBAAS;QACL,sBAAa;GAHpC,aAAa,CAyEzB;AAzEY,sCAAa"}
|
|
@@ -11,4 +11,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
__exportStar(require("./client-provider-matter.guard"), exports);
|
|
14
|
+
__exportStar(require("./api-scope.guard"), exports);
|
|
14
15
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/oauth/guards/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iEAA+C"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/oauth/guards/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iEAA+C;AAC/C,oDAAkC"}
|
|
@@ -26,6 +26,8 @@ export interface ApplicationConfig {
|
|
|
26
26
|
authExcludePaths?: (ExcludePath | RegExp)[];
|
|
27
27
|
applyWebhooks?: boolean;
|
|
28
28
|
useTokenExpiry?: boolean;
|
|
29
|
+
enforceApiScopes?: boolean;
|
|
30
|
+
legacyScopes?: string[];
|
|
29
31
|
providers?: {
|
|
30
32
|
[VCITA_STAFF_PROVIDER_NAME]?: VcitaProvidersOptions;
|
|
31
33
|
[VCITA_CLIENT_PROVIDER_NAME]?: VcitaProvidersOptions;
|
|
@@ -34,6 +34,7 @@ const feature_flags_module_1 = require("../feature-flags/feature-flags.module");
|
|
|
34
34
|
const cookie = require("cookie");
|
|
35
35
|
const core_1 = require("@nestjs/core");
|
|
36
36
|
const authorization_actor_guard_1 = require("./guards/authorization-actor.guard");
|
|
37
|
+
const api_scope_guard_1 = require("./guards/api-scope.guard");
|
|
37
38
|
const permissions_1 = require("../permissions");
|
|
38
39
|
const originalSerialize = cookie.serialize;
|
|
39
40
|
cookie.serialize = function (name, val, options = {}) {
|
|
@@ -49,6 +50,9 @@ cookie.serialize = function (name, val, options = {}) {
|
|
|
49
50
|
}
|
|
50
51
|
return res;
|
|
51
52
|
};
|
|
53
|
+
function isScopeList(value) {
|
|
54
|
+
return Array.isArray(value) && value.every((scope) => typeof scope === 'string' && scope.length > 0);
|
|
55
|
+
}
|
|
52
56
|
let OauthModule = OauthModule_1 = class OauthModule {
|
|
53
57
|
configure(consumer) {
|
|
54
58
|
var _a;
|
|
@@ -64,6 +68,9 @@ let OauthModule = OauthModule_1 = class OauthModule {
|
|
|
64
68
|
}
|
|
65
69
|
static register(config = {}) {
|
|
66
70
|
var _a;
|
|
71
|
+
if (config.legacyScopes !== undefined && !isScopeList(config.legacyScopes)) {
|
|
72
|
+
throw new Error('OauthModule.register: legacyScopes must be a list of scope names, e.g. [] or ["all"]');
|
|
73
|
+
}
|
|
67
74
|
if ((_a = config.authExcludePaths) === null || _a === void 0 ? void 0 : _a.length) {
|
|
68
75
|
config.authExcludePaths = config.authExcludePaths.map((path) => {
|
|
69
76
|
if (path instanceof RegExp) {
|
|
@@ -113,6 +120,7 @@ let OauthModule = OauthModule_1 = class OauthModule {
|
|
|
113
120
|
provide: core_1.APP_GUARD,
|
|
114
121
|
useClass: authorization_actor_guard_1.ActorGuard,
|
|
115
122
|
},
|
|
123
|
+
...(config.enforceApiScopes ? [{ provide: core_1.APP_GUARD, useClass: api_scope_guard_1.ApiScopeGuard }] : []),
|
|
116
124
|
],
|
|
117
125
|
imports: [
|
|
118
126
|
configModule,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth.module.js","sourceRoot":"","sources":["../../src/oauth/oauth.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAOwB;AACxB,8CAA8C;AAC9C,4DAAwD;AACxD,qEAAiE;AACjE,kEAA8D;AAC9D,sEAAkE;AAClE,6CAAgD;AAChD,wEAA6D;AAC7D,2CAA6D;AAE7D,gGAA2F;AAC3F,qDAAmE;AACnE,+CAAkD;AAClD,sEAAiE;AACjE,sDAAkE;AAClE,wEAAmE;AACnE,8EAAyE;AACzE,8EAAyE;AACzE,+CAA2C;AAC3C,kFAA4F;AAC5F,oCAAuC;AACvC,2EAAuE;AACvE,kEAA8D;AAC9D,gFAA2E;AAI3E,iCAAiC;AACjC,uCAAyC;AACzC,kFAAgE;AAChE,gDAAmD;AACnD,MAAM,iBAAiB,GAAG,MAAM,CAAC,SAAS,CAAC;AAC3C,MAAM,CAAC,SAAS,GAAG,UACjB,IAAY,EACZ,GAAW,EACX,UAAoE,EAAE;IAEtE,MAAM,EAAE,WAAW,EAAE,GAAG,WAAW,EAAE,GAAG,OAAO,CAAC;IAChD,IAAI,GAAG,GAAG,iBAAiB,CAAC,IAAI,EAAE,GAAG,EAAE,WAAW,CAAC,CAAC;IAEpD,IAAI,WAAW,EAAE;QACf,IAAI,WAAW,CAAC,MAAM,EAAE;YACtB,GAAG,IAAI,eAAe,CAAC;SACxB;aAAM;YACL,sCAAwB,CAAC,IAAI,CAC3B,sBAAsB,IAAI,mFAAmF,CAC9G,CAAC;SACH;KACF;IACD,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"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MAAM,CAAC;4BACxB,CAAC;4BACD,oBAAoB,EAAE,CAAC;4BACvB,gBAAgB,EAAE,IAAI;yBACvB;qBACF;oBACD,MAAM,EAAE,CAAC,sBAAa,CAAC;iBACxB,CAAC;gBACF,mBAAW,CAAC,YAAY,EAAE;gBAC1B,yCAAkB;gBAClB,+BAAiB;aAClB;YACD,OAAO,EAAE;gBACP,4BAAY;gBACZ,qCAAgB;gBAChB,uCAAiB;gBACjB,6CAAoB;gBACpB,6CAAoB;gBACpB,kCAAe;aAChB;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AA1IY,WAAW;IAFvB,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,WAAW,CA0IvB;AA1IY,kCAAW"}
|
|
@@ -9,7 +9,7 @@ class MockAuthMiddleware {
|
|
|
9
9
|
if (authorizationHeader == null)
|
|
10
10
|
return next();
|
|
11
11
|
const authObject = JSON.parse(authorizationHeader.replace('Bearer ', ''));
|
|
12
|
-
const auth = new __1.AuthorizationPayloadEntity(null, MockAuthMiddleware.to_actor(authObject.actor));
|
|
12
|
+
const auth = new __1.AuthorizationPayloadEntity(Array.isArray(authObject.scopes) ? authObject.scopes : null, MockAuthMiddleware.to_actor(authObject.actor));
|
|
13
13
|
req[auth_enum_1.authActorHeader] = auth;
|
|
14
14
|
next();
|
|
15
15
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock-oauth.middleware.js","sourceRoot":"","sources":["../../../src/oauth/tests/mock-oauth.middleware.ts"],"names":[],"mappings":";;;AAEA,6BAKe;AACf,kDAAqD;AAErD,MAAa,kBAAkB;IAC7B,KAAK,CAAC,GAAG,CAAC,GAAY,EAAE,GAAa,EAAE,IAAgB;QACrD,MAAM,mBAAmB,GAAG,GAAG,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;QACrD,IAAI,mBAAmB,IAAI,IAAI;YAAE,OAAO,IAAI,EAAE,CAAC;QAE/C,MAAM,UAAU,G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,CAAC,GAAG,EACX,OAAO,CAAC,IAAI,EACZ,kBAAkB,CAAC,UAAU,CAAC,OAAO,CAAC,SAAS,CAAC,CACjD,CAAC;IACJ,CAAC;CACF;AAjCD,gDAiCC;AAED,MAAa,iBAAiB;IAE5B,YACkB,IAAY,EACX,SAAqC;;QADtC,SAAI,GAAJ,IAAI,CAAQ;QACX,cAAS,GAAT,SAAS,CAA4B;QAEtD,IAAI,CAAC,UAAU,GAAG,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,KAAK,0CAAE,IAAI,CAAC;IAC3C,CAAC;IAED,YAAY;;QACV,OAAO,MAAA,MAAA,IAAI,CAAC,SAAS,0CAAE,KAAK,0CAAE,GAAG,CAAC;IACpC,CAAC;IAED,6BAA6B;QAC3B,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED,qBAAqB;QACnB,OAAO,IAAI,GAAG,CAAC,6BAA6B,CAAC,CAAC;IAChD,CAAC;CACF;AApBD,8CAoBC;AAED,MAAa,gBAAgB;IAA7B;QACU,gBAAW,GAAG,KAAK,CAAC;IAe9B,CAAC;IAbC,oBAAoB,CAAC,GAAG;QACtB,MAAM,SAAS,GAAG,GAAG,CAAC,2BAAe,CAAC,CAAC;QACvC,IAAI,CAAC,WAAW,GAAG,SAAS,KAAK,SAAS,CAAC;QAC3C,OAAO,IAAI,iBAAiB,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC;IACjE,CAAC;IAED,KAAK,CAAC,aAAa;QACjB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,KAAK,CAAC,YAAY;QAChB,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;CACF;AAhBD,4CAgBC"}
|
|
@@ -27,6 +27,7 @@ export declare class AuthenticationUtils {
|
|
|
27
27
|
static parseActorFromPayload(payload: JwtPayload): AuthorizationPayloadEntity;
|
|
28
28
|
static parseActorFromCookie(cookiePayload: AuthenticationCookiePayload): AuthorizationPayloadEntity;
|
|
29
29
|
static parseClaim<ClaimDataType, ClaimParsedValue>(claim: ClaimDataType, parser: (claim: ClaimDataType) => ClaimParsedValue, claimNotPresent?: () => ClaimParsedValue | null, badClaim?: () => ClaimParsedValue | null): ClaimParsedValue;
|
|
30
|
+
static parseScopes(scpClaim: string | string[] | null | undefined): string[];
|
|
30
31
|
static parseIssuer(issClaim: string): [string, ActorType];
|
|
31
32
|
static parseSubjects(subClaim: string): BelongsEntity;
|
|
32
33
|
static parseBelongs(belongsClaim: string | undefined): BelongsEntity;
|
|
@@ -61,7 +61,7 @@ class AuthenticationUtils {
|
|
|
61
61
|
return claims;
|
|
62
62
|
}
|
|
63
63
|
static parseActorFromPayload(payload) {
|
|
64
|
-
const scopes = AuthenticationUtils.parseClaim(payload.scp,
|
|
64
|
+
const scopes = AuthenticationUtils.parseClaim(payload.scp, AuthenticationUtils.parseScopes, () => {
|
|
65
65
|
throw new common_1.UnauthorizedException('Bad JWT received, no [ scp ] claim');
|
|
66
66
|
});
|
|
67
67
|
const [iss_uid, iss_type] = AuthenticationUtils.parseClaim(payload.iss, AuthenticationUtils.parseIssuer, () => { throw new common_1.UnauthorizedException('Bad JWT received, no [ iss ] claim'); });
|
|
@@ -102,6 +102,11 @@ class AuthenticationUtils {
|
|
|
102
102
|
throw e;
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
|
+
static parseScopes(scpClaim) {
|
|
106
|
+
const values = Array.isArray(scpClaim) ? scpClaim : [scpClaim !== null && scpClaim !== void 0 ? scpClaim : ''];
|
|
107
|
+
const scopes = values.flatMap((value) => String(value).split(/[\s,]+/));
|
|
108
|
+
return [...new Set(scopes.filter(Boolean))];
|
|
109
|
+
}
|
|
105
110
|
static parseIssuer(issClaim) {
|
|
106
111
|
return AuthenticationUtils.extractEntityUidAndType(issClaim);
|
|
107
112
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authentication.utils.js","sourceRoot":"","sources":["../../../src/oauth/utils/authentication.utils.ts"],"names":[],"m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BAAiB,CAAC,CAAC;QACrE,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,CAAC,2BAA2B,CAChC,OAAe,EACf,OAAe,EACf,YAAoC;QAEpC,OAAO,IAAA,mBAAI,EACT,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,EACtD,IAAI,CAAC,YAAY,EAAE,EACnB,IAAI,CAAC,cAAc,EAAE,CACtB,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,iBAAiB,CACtB,OAAe,EACf,OAAe,EACf,eAAuC,EAAE,EACzC,GAAG,GAAG,EAAE;QAER,OAAO;YACL,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC;YAC5C,GAAG,YAAY;SAChB,CAAC;IACJ,CAAC;IAEO,MAAM,CAAC,aAAa,CAC1B,QAAgB,EAChB,OAAe,EACf,GAAG,GAAG,EAAE;QAER,MAAM,oBAAoB,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;QACrE,MAAM,MAAM,GAAG;YACb,GAAG,EAAE,IAAA,uBAAa,GAAE,CAAC,IAAI;YACzB,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAA,uBAAa,GAAE,CAAC,IAAI;YAC7C,GAAG,EAAE,QAAQ;YACb,GAAG,EAAE,oBAAoB,GAAG,GAAG;YAC/B,GAAG,EAAE,oBAAoB;SAC1B,CAAC;QAEF,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,MAAM,CAAC,qBAAqB,CAAC,OAAmB;QAC9C,MAAM,MAAM,GAAG,mBAAmB,CAAC,UAAU,CAC3C,OAAO,CAAC,GAAG,EACX,
|
|
1
|
+
{"version":3,"file":"authentication.utils.js","sourceRoot":"","sources":["../../../src/oauth/utils/authentication.utils.ts"],"names":[],"mappings":";;;AAAA,+CAQsB;AAEtB,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AAc,2BAAmB,CAAC,SAAS,CAAC;AACrD,8BAAU,GAAgB,CAAC,2BAAmB,CAAC,SAAS,CAAC,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { PermissionsModule } from './permissions.module';
|
|
2
2
|
export { PermissionService } from './permissions.service';
|
|
3
3
|
export { RequirePermissions } from './permissions.decorator';
|
|
4
|
+
export { RequirePermissionsGuard } from './permissions.guard';
|
|
4
5
|
export { PermissionsCacheService } from './permissions-cache.service';
|
|
5
6
|
export * from './exceptions';
|
|
@@ -10,13 +10,15 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.PermissionsCacheService = exports.RequirePermissions = exports.PermissionService = exports.PermissionsModule = void 0;
|
|
13
|
+
exports.PermissionsCacheService = exports.RequirePermissionsGuard = exports.RequirePermissions = exports.PermissionService = exports.PermissionsModule = void 0;
|
|
14
14
|
var permissions_module_1 = require("./permissions.module");
|
|
15
15
|
Object.defineProperty(exports, "PermissionsModule", { enumerable: true, get: function () { return permissions_module_1.PermissionsModule; } });
|
|
16
16
|
var permissions_service_1 = require("./permissions.service");
|
|
17
17
|
Object.defineProperty(exports, "PermissionService", { enumerable: true, get: function () { return permissions_service_1.PermissionService; } });
|
|
18
18
|
var permissions_decorator_1 = require("./permissions.decorator");
|
|
19
19
|
Object.defineProperty(exports, "RequirePermissions", { enumerable: true, get: function () { return permissions_decorator_1.RequirePermissions; } });
|
|
20
|
+
var permissions_guard_1 = require("./permissions.guard");
|
|
21
|
+
Object.defineProperty(exports, "RequirePermissionsGuard", { enumerable: true, get: function () { return permissions_guard_1.RequirePermissionsGuard; } });
|
|
20
22
|
var permissions_cache_service_1 = require("./permissions-cache.service");
|
|
21
23
|
Object.defineProperty(exports, "PermissionsCacheService", { enumerable: true, get: function () { return permissions_cache_service_1.PermissionsCacheService; } });
|
|
22
24
|
__exportStar(require("./exceptions"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/permissions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2DAAyD;AAAhD,uHAAA,iBAAiB,OAAA;AAC1B,6DAA0D;AAAjD,wHAAA,iBAAiB,OAAA;AAC1B,iEAA6D;AAApD,2HAAA,kBAAkB,OAAA;AAC3B,yEAAsE;AAA7D,oIAAA,uBAAuB,OAAA;AAChC,+CAA6B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/permissions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2DAAyD;AAAhD,uHAAA,iBAAiB,OAAA;AAC1B,6DAA0D;AAAjD,wHAAA,iBAAiB,OAAA;AAC1B,iEAA6D;AAApD,2HAAA,kBAAkB,OAAA;AAC3B,yDAA8D;AAArD,4HAAA,uBAAuB,OAAA;AAChC,yEAAsE;AAA7D,oIAAA,uBAAuB,OAAA;AAChC,+CAA6B"}
|