@loopback/authorization 0.9.1 → 0.10.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/README.md +3 -3
- package/dist/authorization-component.js +3 -3
- package/dist/authorization-component.js.map +1 -1
- package/dist/authorize-interceptor.js +8 -8
- package/dist/authorize-interceptor.js.map +1 -1
- package/dist/decorators/authorize.js +1 -1
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/package.json +13 -13
- package/src/decorators/authorize.ts +1 -1
package/README.md
CHANGED
|
@@ -150,8 +150,8 @@ information from the request. Therefore we have created another module,
|
|
|
150
150
|
|
|
151
151
|
## Contributions
|
|
152
152
|
|
|
153
|
-
- [Guidelines](https://github.com/
|
|
154
|
-
- [Join the team](https://github.com/
|
|
153
|
+
- [Guidelines](https://github.com/loopbackio/loopback-next/blob/master/docs/CONTRIBUTING.md)
|
|
154
|
+
- [Join the team](https://github.com/loopbackio/loopback-next/issues/110)
|
|
155
155
|
|
|
156
156
|
## Tests
|
|
157
157
|
|
|
@@ -160,7 +160,7 @@ run `npm test` from the root folder.
|
|
|
160
160
|
## Contributors
|
|
161
161
|
|
|
162
162
|
See
|
|
163
|
-
[all contributors](https://github.com/
|
|
163
|
+
[all contributors](https://github.com/loopbackio/loopback-next/graphs/contributors).
|
|
164
164
|
|
|
165
165
|
## License
|
|
166
166
|
|
|
@@ -11,11 +11,11 @@ const authorize_interceptor_1 = require("./authorize-interceptor");
|
|
|
11
11
|
const keys_1 = require("./keys");
|
|
12
12
|
let AuthorizationComponent = class AuthorizationComponent {
|
|
13
13
|
constructor() {
|
|
14
|
-
this.bindings = [core_1.createBindingFromClass(authorize_interceptor_1.AuthorizationInterceptor)];
|
|
14
|
+
this.bindings = [(0, core_1.createBindingFromClass)(authorize_interceptor_1.AuthorizationInterceptor)];
|
|
15
15
|
}
|
|
16
16
|
};
|
|
17
|
-
AuthorizationComponent = tslib_1.__decorate([
|
|
18
|
-
core_1.injectable({ tags: { [core_1.ContextTags.KEY]: keys_1.AuthorizationBindings.COMPONENT.key } })
|
|
17
|
+
AuthorizationComponent = (0, tslib_1.__decorate)([
|
|
18
|
+
(0, core_1.injectable)({ tags: { [core_1.ContextTags.KEY]: keys_1.AuthorizationBindings.COMPONENT.key } })
|
|
19
19
|
], AuthorizationComponent);
|
|
20
20
|
exports.AuthorizationComponent = AuthorizationComponent;
|
|
21
21
|
//# sourceMappingURL=authorization-component.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorization-component.js","sourceRoot":"","sources":["../src/authorization-component.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,uCAAuC;AACvC,+CAA+C;AAC/C,gEAAgE;;;;AAEhE,yCAMwB;AACxB,mEAAiE;AACjE,iCAA6C;AAG7C,IAAa,sBAAsB,GAAnC,MAAa,sBAAsB;IAAnC;QACE,aAAQ,GAAc,CAAC,6BAAsB,
|
|
1
|
+
{"version":3,"file":"authorization-component.js","sourceRoot":"","sources":["../src/authorization-component.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,uCAAuC;AACvC,+CAA+C;AAC/C,gEAAgE;;;;AAEhE,yCAMwB;AACxB,mEAAiE;AACjE,iCAA6C;AAG7C,IAAa,sBAAsB,GAAnC,MAAa,sBAAsB;IAAnC;QACE,aAAQ,GAAc,CAAC,IAAA,6BAAsB,EAAC,gDAAwB,CAAC,CAAC,CAAC;IAC3E,CAAC;CAAA,CAAA;AAFY,sBAAsB;IADlC,IAAA,iBAAU,EAAC,EAAC,IAAI,EAAE,EAAC,CAAC,kBAAW,CAAC,GAAG,CAAC,EAAE,4BAAqB,CAAC,SAAS,CAAC,GAAG,EAAC,EAAC,CAAC;GAChE,sBAAsB,CAElC;AAFY,wDAAsB"}
|
|
@@ -8,12 +8,12 @@ exports.AuthorizationInterceptor = void 0;
|
|
|
8
8
|
const tslib_1 = require("tslib");
|
|
9
9
|
const core_1 = require("@loopback/core");
|
|
10
10
|
const security_1 = require("@loopback/security");
|
|
11
|
-
const debug_1 = tslib_1.__importDefault(require("debug"));
|
|
11
|
+
const debug_1 = (0, tslib_1.__importDefault)(require("debug"));
|
|
12
12
|
const authorize_1 = require("./decorators/authorize");
|
|
13
13
|
const keys_1 = require("./keys");
|
|
14
14
|
const types_1 = require("./types");
|
|
15
15
|
const util_1 = require("./util");
|
|
16
|
-
const debug = debug_1.default('loopback:authorization:interceptor');
|
|
16
|
+
const debug = (0, debug_1.default)('loopback:authorization:interceptor');
|
|
17
17
|
let AuthorizationInterceptor = class AuthorizationInterceptor {
|
|
18
18
|
constructor(options = {}) {
|
|
19
19
|
this.options = {
|
|
@@ -30,7 +30,7 @@ let AuthorizationInterceptor = class AuthorizationInterceptor {
|
|
|
30
30
|
async intercept(invocationCtx, next) {
|
|
31
31
|
var _a;
|
|
32
32
|
const description = debug.enabled ? invocationCtx.description : '';
|
|
33
|
-
let metadata = authorize_1.getAuthorizationMetadata(invocationCtx.target, invocationCtx.methodName);
|
|
33
|
+
let metadata = (0, authorize_1.getAuthorizationMetadata)(invocationCtx.target, invocationCtx.methodName);
|
|
34
34
|
if (!metadata) {
|
|
35
35
|
debug('No authorization metadata is found for %s', description);
|
|
36
36
|
}
|
|
@@ -47,7 +47,7 @@ let AuthorizationInterceptor = class AuthorizationInterceptor {
|
|
|
47
47
|
});
|
|
48
48
|
debug('Current user', user);
|
|
49
49
|
const authorizationCtx = {
|
|
50
|
-
principals: user ? [util_1.createPrincipalFromUserProfile(user)] : [],
|
|
50
|
+
principals: user ? [(0, util_1.createPrincipalFromUserProfile)(user)] : [],
|
|
51
51
|
roles: [],
|
|
52
52
|
scopes: [],
|
|
53
53
|
resource: invocationCtx.targetName,
|
|
@@ -87,10 +87,10 @@ let AuthorizationInterceptor = class AuthorizationInterceptor {
|
|
|
87
87
|
return next();
|
|
88
88
|
}
|
|
89
89
|
};
|
|
90
|
-
AuthorizationInterceptor = tslib_1.__decorate([
|
|
91
|
-
core_1.injectable(core_1.asGlobalInterceptor('authorization')),
|
|
92
|
-
tslib_1.__param(0, core_1.config({ fromBinding: keys_1.AuthorizationBindings.COMPONENT })),
|
|
93
|
-
tslib_1.__metadata("design:paramtypes", [Object])
|
|
90
|
+
AuthorizationInterceptor = (0, tslib_1.__decorate)([
|
|
91
|
+
(0, core_1.injectable)((0, core_1.asGlobalInterceptor)('authorization')),
|
|
92
|
+
(0, tslib_1.__param)(0, (0, core_1.config)({ fromBinding: keys_1.AuthorizationBindings.COMPONENT })),
|
|
93
|
+
(0, tslib_1.__metadata)("design:paramtypes", [Object])
|
|
94
94
|
], AuthorizationInterceptor);
|
|
95
95
|
exports.AuthorizationInterceptor = AuthorizationInterceptor;
|
|
96
96
|
async function loadAuthorizers(ctx, authorizers) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorize-interceptor.js","sourceRoot":"","sources":["../src/authorize-interceptor.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,uCAAuC;AACvC,+CAA+C;AAC/C,gEAAgE;;;;AAEhE,yCAWwB;AACxB,iDAAiE;AACjE
|
|
1
|
+
{"version":3,"file":"authorize-interceptor.js","sourceRoot":"","sources":["../src/authorize-interceptor.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,uCAAuC;AACvC,+CAA+C;AAC/C,gEAAgE;;;;AAEhE,yCAWwB;AACxB,iDAAiE;AACjE,+DAAiC;AACjC,sDAAgE;AAChE,iCAAgE;AAChE,mCAMiB;AACjB,iCAAsD;AAEtD,MAAM,KAAK,GAAG,IAAA,eAAY,EAAC,oCAAoC,CAAC,CAAC;AAGjE,IAAa,wBAAwB,GAArC,MAAa,wBAAwB;IAGnC,YAEE,UAAgC,EAAE;QAElC,IAAI,CAAC,OAAO,GAAG;YACb,eAAe,EAAE,6BAAqB,CAAC,IAAI;YAC3C,UAAU,EAAE,6BAAqB,CAAC,IAAI;YACtC,wBAAwB,EAAE,GAAG;YAC7B,GAAG,OAAO;SACX,CAAC;QACF,KAAK,CAAC,uB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K,GAAG,IAAI,0BAAkB,CAAC,eAAe,CAAC,CAAC;YACtD,KAAK,CAAC,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,wBAAwB,CAAC;YACzD,MAAM,KAAK,CAAC;SACb;QACD,OAAO,IAAI,EAAE,CAAC;IAChB,CAAC;CACF,CAAA;AAhGY,wBAAwB;IADpC,IAAA,iBAAU,EAAC,IAAA,0BAAmB,EAAC,eAAe,CAAC,CAAC;IAK5C,wBAAA,IAAA,aAAM,EAAC,EAAC,WAAW,EAAE,4BAAqB,CAAC,SAAS,EAAC,CAAC,CAAA;;GAJ9C,wBAAwB,CAgGpC;AAhGY,4DAAwB;AAkGrC,KAAK,UAAU,eAAe,CAC5B,GAAY,EACZ,WAAwD;IAExD,MAAM,mBAAmB,GAAiB,EAAE,CAAC;IAC7C,MAAM,QAAQ,GAAG,GAAG,CAAC,SAAS,CAAa,wBAAiB,CAAC,UAAU,CAAC,CAAC;IACzE,WAAW,GAAG,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3D,KAAK,MAAM,OAAO,IAAI,WAAW,EAAE;QACjC,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE;YACjC,mBAAmB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;SACnC;aAAM;YACL,MAAM,EAAE,GAAG,MAAM,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YAClC,mBAAmB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;SAC9B;KACF;IACD,OAAO,mBAAmB,CAAC;AAC7B,CAAC"}
|
|
@@ -62,7 +62,7 @@ function authorize(spec) {
|
|
|
62
62
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
63
63
|
target, method,
|
|
64
64
|
// Use `any` to for `TypedPropertyDescriptor`
|
|
65
|
-
// See https://github.com/
|
|
65
|
+
// See https://github.com/loopbackio/loopback-next/pull/2704
|
|
66
66
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
67
67
|
methodDescriptor) {
|
|
68
68
|
if (method && methodDescriptor) {
|
package/dist/index.js
CHANGED
|
@@ -15,9 +15,9 @@ const tslib_1 = require("tslib");
|
|
|
15
15
|
*
|
|
16
16
|
* @packageDocumentation
|
|
17
17
|
*/
|
|
18
|
-
tslib_1.__exportStar(require("./authorization-component"), exports);
|
|
19
|
-
tslib_1.__exportStar(require("./authorize-interceptor"), exports);
|
|
20
|
-
tslib_1.__exportStar(require("./decorators/authorize"), exports);
|
|
21
|
-
tslib_1.__exportStar(require("./keys"), exports);
|
|
22
|
-
tslib_1.__exportStar(require("./types"), exports);
|
|
18
|
+
(0, tslib_1.__exportStar)(require("./authorization-component"), exports);
|
|
19
|
+
(0, tslib_1.__exportStar)(require("./authorize-interceptor"), exports);
|
|
20
|
+
(0, tslib_1.__exportStar)(require("./decorators/authorize"), exports);
|
|
21
|
+
(0, tslib_1.__exportStar)(require("./keys"), exports);
|
|
22
|
+
(0, tslib_1.__exportStar)(require("./types"), exports);
|
|
23
23
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,uCAAuC;AACvC,+CAA+C;AAC/C,gEAAgE;;;AAEhE;;;;;;;;;GASG;AAEH,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,uCAAuC;AACvC,+CAA+C;AAC/C,gEAAgE;;;AAEhE;;;;;;;;;GASG;AAEH,yEAA0C;AAC1C,uEAAwC;AACxC,sEAAuC;AACvC,sDAAuB;AACvB,uDAAwB"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loopback/authorization",
|
|
3
3
|
"description": "A LoopBack component for authorization support.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.10.0",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"LoopBack",
|
|
7
7
|
"Authorization"
|
|
@@ -13,11 +13,11 @@
|
|
|
13
13
|
"copyright.owner": "IBM Corp.",
|
|
14
14
|
"repository": {
|
|
15
15
|
"type": "git",
|
|
16
|
-
"url": "https://github.com/
|
|
16
|
+
"url": "https://github.com/loopbackio/loopback-next.git",
|
|
17
17
|
"directory": "packages/authorization"
|
|
18
18
|
},
|
|
19
19
|
"engines": {
|
|
20
|
-
"node": "
|
|
20
|
+
"node": "12 || 14 || 16 || 17"
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|
|
23
23
|
"acceptance": "lb-mocha \"dist/__tests__/acceptance/**/*.js\"",
|
|
@@ -40,20 +40,20 @@
|
|
|
40
40
|
"!/fixtures"
|
|
41
41
|
],
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"@loopback/core": "^
|
|
43
|
+
"@loopback/core": "^3.0.0"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@loopback/security": "^0.
|
|
47
|
-
"debug": "^4.3.
|
|
48
|
-
"tslib": "^2.
|
|
46
|
+
"@loopback/security": "^0.6.0",
|
|
47
|
+
"debug": "^4.3.2",
|
|
48
|
+
"tslib": "^2.3.1"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@loopback/build": "^
|
|
52
|
-
"@loopback/core": "^
|
|
53
|
-
"@loopback/testlab": "^
|
|
54
|
-
"@types/debug": "^4.1.
|
|
51
|
+
"@loopback/build": "^8.0.0",
|
|
52
|
+
"@loopback/core": "^3.0.0",
|
|
53
|
+
"@loopback/testlab": "^4.0.0",
|
|
54
|
+
"@types/debug": "^4.1.7",
|
|
55
55
|
"@types/node": "10.17.60",
|
|
56
|
-
"casbin": "^5.
|
|
56
|
+
"casbin": "^5.11.5"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "00a62f630c19341ce399cec3a45563b1ead6e3b8"
|
|
59
59
|
}
|
|
@@ -94,7 +94,7 @@ export function authorize(spec: AuthorizationMetadata) {
|
|
|
94
94
|
target: any,
|
|
95
95
|
method?: string,
|
|
96
96
|
// Use `any` to for `TypedPropertyDescriptor`
|
|
97
|
-
// See https://github.com/
|
|
97
|
+
// See https://github.com/loopbackio/loopback-next/pull/2704
|
|
98
98
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
99
99
|
methodDescriptor?: TypedPropertyDescriptor<any>,
|
|
100
100
|
) {
|