vulcain-corejs
Version:
Vulcain micro-service framework
58 lines (57 loc) • 1.48 kB
TypeScript
import { RequestContext } from '../requestContext';
export interface IAuthorizationPolicy {
/**
* get user scopes
*
* @returns {Array<string>}
*
* @memberOf IPolicy
*/
scopes(requestContext: RequestContext): 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(requestContext: RequestContext, handlerScope: string): boolean;
isAdmin(requestContext: RequestContext): boolean;
}
/**
* Default policy
*
* @export
* @class DefaultPolicy
*/
export declare class DefaultAuthorizationPolicy {
/**
* Get user scopes
*
* @readonly
* @type {Array<string>}
*/
scopes(requestContext: RequestContext): 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 {number}
*/
hasScope(requestContext: RequestContext, handlerScope: string): boolean;
/**
* Check if the current user is an admin
*
* @returns {boolean}
*/
isAdmin(requestContext: RequestContext): boolean;
}