UNPKG

@universis/janitor

Version:

Universis api plugin for handling user authorization and rate limiting

88 lines (74 loc) 2.66 kB
/** * @license * Universis Project Version 1.0 * Copyright (c) 2018, Universis Project All rights reserved * * Use of this source code is governed by an LGPL 3.0 license that can be * found in the LICENSE file at https://universis.io/license */ import {ApplicationBase, ApplicationService, ConfigurationBase, ConfigurationStrategy} from '@themost/common'; export declare class ScopeString { constructor(str: string); split(): string[]; } export declare interface UniversisConfigurationSection { universis: { [k: string]: any; } } export declare interface ScopeAccessConfigurationSection { janitor: { scopeAccess: { imports: string[] } } } /** * Declares a configuration element for managing scope-based permissions on server resources */ export declare interface ScopeAccessConfigurationElement { /** * Gets or sets an array of strings that holds an array of scopes e.g. students or students:read or students,teachers etc */ scope: string[], /** * Gets or sets a string which represents the regular expression that is going to be used for validating endpoint */ resource: string; /** * Gets or sets an array of strings which represents the access levels for the given scopes e.g. READ or READ,WRITE etc */ access: string[]; /** * Gets or sets a string which represents a short description for this item */ description?: string; } export declare class ScopeAccessConfiguration extends ConfigurationStrategy { constructor(configuration: ConfigurationBase); /** * Gets an array of scope access configuration elements */ public elements: ScopeAccessConfigurationElement[]; /** * Verifies the given request and returns a promise that resolves with a scope access configuration element */ verify(req: Request): Promise<ScopeAccessConfigurationElement>; } export declare class DefaultScopeAccessConfiguration extends ScopeAccessConfiguration { constructor(configuration: ConfigurationBase); /** * Gets an array of scope access configuration elements */ public elements: ScopeAccessConfigurationElement[]; /** * Verifies the given request and returns a promise that resolves with a scope access configuration element */ verify(req: Request): Promise<ScopeAccessConfigurationElement>; } export declare class EnableScopeAccessConfiguration extends ApplicationService { constructor(app: ApplicationBase); } export declare class ExtendScopeAccessConfiguration extends ApplicationService { constructor(app: ApplicationBase); }