UNPKG

vulcain-corejs

Version:
58 lines (57 loc) 1.48 kB
import { SecurityContext } from './securityContext'; export interface IAuthorizationPolicy { /** * get user scopes * * @returns {Array<string>} * * @memberOf IPolicy */ scopes(sec: SecurityContext): Array<string>; /** * Check if the current user scopes are valid with a specific scope * * @param {string} handlerScope Scope to check * @returns {boolean} * * @memberOf IPolicy */ hasScope(sec: SecurityContext, handlerScope: string): boolean; isAdmin(sec: SecurityContext): boolean; } /** * Default policy * * @export * @class DefaultPolicy */ export declare class DefaultAuthorizationPolicy { /** * Get user scopes * * @readonly * @type {Array<string>} */ scopes(sec: SecurityContext): Array<string>; /** * Check if the current user has a specific scope * * Rules: * scope userScope Result * null/?/* true * null false * * true * x x true * x-yz x-* true * * @param {string} scope * @returns {boolean} */ hasScope(sec: SecurityContext, handlerScope: string): boolean; /** * Check if the current user is an admin * * @returns {boolean} */ isAdmin(sec: SecurityContext): boolean; }