diff --git a/src/enforcer.ts b/src/enforcer.ts index 6421e9a..2e1262b 100644 --- a/src/enforcer.ts +++ b/src/enforcer.ts @@ -302,11 +302,16 @@ export class Enforcer extends ManagementEnforcer { * getPermissionsForUser("alice") can only get: [["alice", "data2", "read"]]. * But getImplicitPermissionsForUser("alice") will get: [["admin", "data1", "read"], ["alice", "data2", "read"]]. */ - public async getImplicitPermissionsForUser(user: string): Promise { - const roles = [user, ...(await this.getImplicitRolesForUser(user))]; + public async getImplicitPermissionsForUser(user: string, ...domain: string[]): Promise { + const roles = [user, ...(await this.getImplicitRolesForUser(user, ...domain))]; const res: string[][] = []; + const withDomain = domain && domain.length !== 0; roles.forEach(n => { - res.push(...this.getPermissionsForUser(n)); + if (withDomain) { + res.push(...this.getFilteredPolicy(0, n, ...domain)); + } else { + res.push(...this.getPermissionsForUser(n)); + } }); return res; }