nest-authz
Advanced tools
Comparing version 2.9.0 to 2.10.0
@@ -32,3 +32,3 @@ "use strict"; | ||
const types_1 = require("./types"); | ||
let AuthZGuard = exports.AuthZGuard = AuthZGuard_1 = class AuthZGuard { | ||
let AuthZGuard = AuthZGuard_1 = class AuthZGuard { | ||
constructor(reflector, enforcer, options) { | ||
@@ -102,2 +102,3 @@ this.reflector = reflector; | ||
}; | ||
exports.AuthZGuard = AuthZGuard; | ||
exports.AuthZGuard = AuthZGuard = AuthZGuard_1 = __decorate([ | ||
@@ -104,0 +105,0 @@ (0, common_1.Injectable)(), |
@@ -25,3 +25,3 @@ "use strict"; | ||
const services_1 = require("./services"); | ||
let AuthZModule = exports.AuthZModule = AuthZModule_1 = class AuthZModule { | ||
let AuthZModule = AuthZModule_1 = class AuthZModule { | ||
static register(options) { | ||
@@ -76,2 +76,3 @@ if (options.enablePossession === undefined) { | ||
}; | ||
exports.AuthZModule = AuthZModule; | ||
exports.AuthZModule = AuthZModule = AuthZModule_1 = __decorate([ | ||
@@ -78,0 +79,0 @@ (0, common_1.Global)(), |
@@ -5,2 +5,7 @@ import * as casbin from 'casbin'; | ||
constructor(enforcer: casbin.Enforcer); | ||
enforce(...params: string[]): Promise<boolean>; | ||
enforceWithMatcher(matcher: string, ...params: string[]): Promise<boolean>; | ||
enforceEx(...params: string[]): Promise<[boolean, string[]]>; | ||
enforceExWithMatcher(matcher: string, ...params: string[]): Promise<[boolean, string[]]>; | ||
batchEnforce(params: string[][]): Promise<boolean[]>; | ||
getAllSubjects(): Promise<string[]>; | ||
@@ -50,2 +55,4 @@ getAllNamedSubjects(ptype: string): Promise<string[]>; | ||
loadPolicy(): Promise<void>; | ||
updateGroupingPolicy(oldRule: string[], newRule: string[]): Promise<boolean>; | ||
updateNamedGroupingPolicy(ptype: string, oldRule: string[], newRule: string[]): Promise<boolean>; | ||
} |
@@ -19,6 +19,21 @@ "use strict"; | ||
const casbin = require("casbin"); | ||
let AuthZManagementService = exports.AuthZManagementService = class AuthZManagementService { | ||
let AuthZManagementService = class AuthZManagementService { | ||
constructor(enforcer) { | ||
this.enforcer = enforcer; | ||
} | ||
enforce(...params) { | ||
return this.enforcer.enforce(params); | ||
} | ||
enforceWithMatcher(matcher, ...params) { | ||
return this.enforcer.enforceWithMatcher(matcher, params); | ||
} | ||
enforceEx(...params) { | ||
return this.enforcer.enforceEx(params); | ||
} | ||
enforceExWithMatcher(matcher, ...params) { | ||
return this.enforcer.enforceExWithMatcher(matcher, params); | ||
} | ||
batchEnforce(params) { | ||
return this.enforcer.batchEnforce(params); | ||
} | ||
getAllSubjects() { | ||
@@ -156,3 +171,10 @@ return this.enforcer.getAllSubjects(); | ||
} | ||
updateGroupingPolicy(oldRule, newRule) { | ||
return this.enforcer.updateGroupingPolicy(oldRule, newRule); | ||
} | ||
updateNamedGroupingPolicy(ptype, oldRule, newRule) { | ||
return this.enforcer.updateNamedGroupingPolicy(ptype, oldRule, newRule); | ||
} | ||
}; | ||
exports.AuthZManagementService = AuthZManagementService; | ||
exports.AuthZManagementService = AuthZManagementService = __decorate([ | ||
@@ -159,0 +181,0 @@ (0, common_1.Injectable)(), |
@@ -28,3 +28,3 @@ "use strict"; | ||
const casbin = require("casbin"); | ||
let AuthZRBACService = exports.AuthZRBACService = class AuthZRBACService { | ||
let AuthZRBACService = class AuthZRBACService { | ||
constructor(enforcer) { | ||
@@ -87,2 +87,3 @@ this.enforcer = enforcer; | ||
}; | ||
exports.AuthZRBACService = AuthZRBACService; | ||
exports.AuthZRBACService = AuthZRBACService = __decorate([ | ||
@@ -89,0 +90,0 @@ (0, common_1.Injectable)(), |
{ | ||
"name": "nest-authz", | ||
"version": "2.9.0", | ||
"version": "2.10.0", | ||
"description": "Nest.js RBAC & ABAC authorization module based on Node-Casbin", | ||
@@ -30,3 +30,3 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"casbin": "^5.11.1" | ||
"casbin": "^5.30.0" | ||
}, | ||
@@ -33,0 +33,0 @@ "devDependencies": { |
@@ -16,2 +16,62 @@ import { Injectable, Inject } from '@nestjs/common'; | ||
/** | ||
* enforce decides whether a "subject" can access a "object" with the operation "action" | ||
* | ||
* @param params the request parameters, usually (sub, obj, act) | ||
* | ||
* @return whether or not the request is allowed | ||
*/ | ||
enforce(...params: string[]): Promise<boolean> { | ||
return this.enforcer.enforce(params); | ||
} | ||
/** | ||
* enforceWithMatcher uses a custom matcher to decides whether a "subject" can access a "object" with the operation "action" | ||
* | ||
* @param matcher the matcher statement to use | ||
* @param params the request parameters, usually (sub, obj, act) | ||
* | ||
* @return whether or not the request is allowed | ||
*/ | ||
enforceWithMatcher(matcher: string, ...params: string[]): Promise<boolean> { | ||
return this.enforcer.enforceWithMatcher(matcher, params); | ||
} | ||
/** | ||
* enforceEx explains enforcement by returning matched rules. | ||
* | ||
* @param params the request parameters, usually (sub, obj, act) | ||
* | ||
* @return whether or not the request is allowed, and what policy caused that decision | ||
*/ | ||
enforceEx(...params: string[]): Promise<[boolean, string[]]> { | ||
return this.enforcer.enforceEx(params); | ||
} | ||
/** | ||
* enforceExWithMatcher uses a custom matcher and explains enforcement by returning matched rules. | ||
* | ||
* @param matcher the matcher statement to use | ||
* @param params the request parameters, usually (sub, obj, act) | ||
* | ||
* @return whether or not the request is allowed, and what policy caused that decision | ||
*/ | ||
enforceExWithMatcher( | ||
matcher: string, | ||
...params: string[] | ||
): Promise<[boolean, string[]]> { | ||
return this.enforcer.enforceExWithMatcher(matcher, params); | ||
} | ||
/** | ||
* batchEnforce enforces each request and returns result in a bool array | ||
* | ||
* @param params the request parameters, usually (sub, obj, act) | ||
* | ||
* @return an array with the enforcement results for each given request | ||
*/ | ||
batchEnforce(params: string[][]): Promise<boolean[]> { | ||
return this.enforcer.batchEnforce(params); | ||
} | ||
/** | ||
* getAllSubjects gets the list of subjects that show up in the current policy. | ||
@@ -541,2 +601,33 @@ * | ||
} | ||
/** | ||
* updateGroupingPolicy updates a role inheritance rule from the current policy. | ||
* If the rule not exists, the function returns false. | ||
* Otherwise the function returns true by changing it to the new rule. | ||
* | ||
* @param oldRule the role inheritance rule will be remove | ||
* @param newRule the role inheritance rule will be added | ||
* @return succeeds or not. | ||
*/ | ||
updateGroupingPolicy(oldRule: string[], newRule: string[]): Promise<boolean> { | ||
return this.enforcer.updateGroupingPolicy(oldRule, newRule); | ||
} | ||
/** | ||
* updateNamedGroupingPolicy updates a named role inheritance rule from the current policy. | ||
* If the rule not exists, the function returns false. | ||
* Otherwise the function returns true by changing it to the new rule. | ||
* | ||
* @param ptype the policy type, can be "g", "g2", "g3", .. | ||
* @param oldRule the role inheritance rule will be remove | ||
* @param newRule the role inheritance rule will be added | ||
* @return succeeds or not. | ||
*/ | ||
updateNamedGroupingPolicy( | ||
ptype: string, | ||
oldRule: string[], | ||
newRule: string[] | ||
): Promise<boolean> { | ||
return this.enforcer.updateNamedGroupingPolicy(ptype, oldRule, newRule); | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
99922
1888
Updatedcasbin@^5.30.0