@loopback/authorization
Advanced tools
Comparing version 0.2.2 to 0.3.0
@@ -6,2 +6,13 @@ # Change Log | ||
# [0.3.0](https://github.com/strongloop/loopback-next/compare/@loopback/authorization@0.2.2...@loopback/authorization@0.3.0) (2019-09-17) | ||
### Features | ||
* **authorization:** add support for default authorization metadata ([7034bb0](https://github.com/strongloop/loopback-next/commit/7034bb0)) | ||
## [0.2.2](https://github.com/strongloop/loopback-next/compare/@loopback/authorization@0.2.1...@loopback/authorization@0.2.2) (2019-09-06) | ||
@@ -8,0 +19,0 @@ |
@@ -37,5 +37,9 @@ "use strict"; | ||
const description = debug.enabled ? invocationCtx.description : ''; | ||
const metadata = authorize_1.getAuthorizationMetadata(invocationCtx.target, invocationCtx.methodName); | ||
let metadata = authorize_1.getAuthorizationMetadata(invocationCtx.target, invocationCtx.methodName); | ||
if (!metadata) { | ||
debug('No authorization metadata is found %s', description); | ||
debug('No authorization metadata is found for %s', description); | ||
} | ||
metadata = metadata || this.options.defaultMetadata; | ||
if (!metadata) { | ||
debug('Authorization is skipped for %s', description); | ||
const result = await next(); | ||
@@ -42,0 +46,0 @@ return result; |
@@ -155,2 +155,8 @@ import { BindingAddress, InvocationContext } from '@loopback/context'; | ||
precedence?: AuthorizationDecision.DENY | AuthorizationDecision.ALLOW; | ||
/** | ||
* Default authorization metadata if a method is not decorated with `@authorize`. | ||
* If not set, no authorization will be enforced for those methods that are | ||
* not associated with authorization metadata. | ||
*/ | ||
defaultMetadata?: AuthorizationMetadata; | ||
} |
{ | ||
"name": "@loopback/authorization", | ||
"version": "0.2.2", | ||
"version": "0.3.0", | ||
"description": "A LoopBack component for authorization support.", | ||
@@ -25,12 +25,12 @@ "engines": { | ||
"dependencies": { | ||
"@loopback/context": "^1.22.1", | ||
"@loopback/core": "^1.10.1", | ||
"@loopback/security": "^0.1.1", | ||
"@loopback/context": "^1.23.0", | ||
"@loopback/core": "^1.10.2", | ||
"@loopback/security": "^0.1.2", | ||
"debug": "^4.1.1" | ||
}, | ||
"devDependencies": { | ||
"@loopback/build": "^2.0.10", | ||
"@loopback/testlab": "^1.8.0", | ||
"@loopback/build": "^2.0.11", | ||
"@loopback/testlab": "^1.8.1", | ||
"@types/debug": "^4.1.4", | ||
"@types/node": "10.14.17", | ||
"@types/node": "10.14.18", | ||
"casbin": "^3.0.4" | ||
@@ -55,3 +55,3 @@ }, | ||
}, | ||
"gitHead": "4e653bbff797b26437bd1b0817ed9b8c91f3477b" | ||
"gitHead": "8c05b57d6d7eb03530f7be8b4e392e73694c7013" | ||
} |
@@ -63,3 +63,3 @@ // Copyright IBM Corp. 2019. All Rights Reserved. | ||
const description = debug.enabled ? invocationCtx.description : ''; | ||
const metadata = getAuthorizationMetadata( | ||
let metadata = getAuthorizationMetadata( | ||
invocationCtx.target, | ||
@@ -69,3 +69,7 @@ invocationCtx.methodName, | ||
if (!metadata) { | ||
debug('No authorization metadata is found %s', description); | ||
debug('No authorization metadata is found for %s', description); | ||
} | ||
metadata = metadata || this.options.defaultMetadata; | ||
if (!metadata) { | ||
debug('Authorization is skipped for %s', description); | ||
const result = await next(); | ||
@@ -72,0 +76,0 @@ return result; |
@@ -180,2 +180,8 @@ // Copyright IBM Corp. 2018. All Rights Reserved. | ||
precedence?: AuthorizationDecision.DENY | AuthorizationDecision.ALLOW; | ||
/** | ||
* Default authorization metadata if a method is not decorated with `@authorize`. | ||
* If not set, no authorization will be enforced for those methods that are | ||
* not associated with authorization metadata. | ||
*/ | ||
defaultMetadata?: AuthorizationMetadata; | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
62305
1246
Updated@loopback/context@^1.23.0
Updated@loopback/core@^1.10.2
Updated@loopback/security@^0.1.2