rbac-engine
Version:
Role-based access control engine with policy-based permissions
29 lines • 1.52 kB
TypeScript
import { User, Role, Policy } from "./models";
import { IBaseRepository } from "./db/base-repo";
import { PolicyBuilder } from "./builders";
type RepositoryConstructor<T> = new (client: T) => IBaseRepository;
export declare class AccessControl<T> {
private repository;
constructor(client: T, repositoryConstructor: RepositoryConstructor<T>);
init(): Promise<void>;
createUser(user: User): Promise<User>;
createRole(role: Role): Promise<Role>;
assignRoleToUser(userId: string, roleId: string): Promise<User>;
createPolicy(policy: Policy | PolicyBuilder): Promise<Policy>;
attachPolicyToRole(policyId: string, roleId: string): Promise<void>;
attachPolicyToUser(policyId: string, userId: string): Promise<void>;
getUser(userId: string): Promise<User>;
getRole(roleId: string): Promise<Role>;
getUserPolicies(userId: string): Promise<Policy[]>;
getRolePolicies(roleId: string): Promise<Policy[]>;
updateRole(role: Role): Promise<Role>;
updatePolicy(policy: Policy): Promise<Policy>;
deletePolicy(policyId: string): Promise<void>;
deleteRole(roleId: string): Promise<void>;
detachPolicyFromRole(policyId: string, roleId: string): Promise<void>;
detachPolicyFromUser(policyId: string, userId: string): Promise<void>;
removeRoleFromUser(userId: string, roleId: string): Promise<void>;
hasAccess(userId: string, action: string, resource: string, context?: Record<string, any>): Promise<boolean>;
}
export {};
//# sourceMappingURL=core.d.ts.map