UNPKG

casbin

Version:

An authorization library that supports access control models like ACL, RBAC, ABAC in Node.JS

54 lines (53 loc) 1.95 kB
import { Adapter } from './adapter'; import { Model } from '../model'; import { FileSystem } from './fileSystem'; /** * FileAdapter is the file adapter for Casbin. * It can load policy from file or save policy to file. */ export declare class FileAdapter implements Adapter { readonly filePath: string; protected readonly fs?: FileSystem; /** * FileAdapter is the constructor for FileAdapter. * * @param filePath filePath the path of the policy file. * @param fs {@link FileSystem} */ constructor(filePath: string, fs?: FileSystem); loadPolicy(model: Model): Promise<void>; private loadPolicyFile; /** * savePolicy saves all policy rules to the storage. */ savePolicy(model: Model): Promise<boolean>; private escapeCsv; private savePolicyFile; /** * addPolicy adds a policy rule to the storage. */ addPolicy(sec: string, ptype: string, rule: string[]): Promise<void>; /** * addPolicies adds policy rules to the storage. This is part of the Auto-Save feature. */ addPolicies(sec: string, ptype: string, rules: string[][]): Promise<void>; /** * UpdatePolicy updates a policy rule from storage. * This is part of the Auto-Save feature. */ updatePolicy(sec: string, ptype: string, oldRule: string[], newRule: string[]): Promise<void>; /** * removePolicy removes a policy rule from the storage. */ removePolicy(sec: string, ptype: string, rule: string[]): Promise<void>; /** * removePolicies removes policy rules from the storage. * This is part of the Auto-Save feature. */ removePolicies(sec: string, ptype: string, rules: string[][]): Promise<void>; /** * removeFilteredPolicy removes policy rules that match the filter from the storage. */ removeFilteredPolicy(sec: string, ptype: string, fieldIndex: number, ...fieldValues: string[]): Promise<void>; }