Skip to content

Commit 584624c

Browse files
committed
fix: getImplicitPermissionsForUser missing domain parameter
1 parent 968372c commit 584624c

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/enforcer.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -302,11 +302,16 @@ export class Enforcer extends ManagementEnforcer {
302302
* getPermissionsForUser("alice") can only get: [["alice", "data2", "read"]].
303303
* But getImplicitPermissionsForUser("alice") will get: [["admin", "data1", "read"], ["alice", "data2", "read"]].
304304
*/
305-
public async getImplicitPermissionsForUser(user: string): Promise<string[][]> {
306-
const roles = [user, ...(await this.getImplicitRolesForUser(user))];
305+
public async getImplicitPermissionsForUser(user: string, ...domain: string[]): Promise<string[][]> {
306+
const roles = [user, ...(await this.getImplicitRolesForUser(user, ...domain))];
307307
const res: string[][] = [];
308+
const withDomain = domain && domain.length !== 0;
308309
roles.forEach(n => {
309-
res.push(...this.getPermissionsForUser(n));
310+
if (withDomain) {
311+
res.push(...this.getFilteredPolicy(0, n, ...domain));
312+
} else {
313+
res.push(...this.getPermissionsForUser(n));
314+
}
310315
});
311316
return res;
312317
}

0 commit comments

Comments
 (0)