@appsensorlike/appsensorlike
Version:
A port of OWASP AppSensor reference implementation
46 lines (45 loc) • 1.68 kB
TypeScript
import { ClientApplication } from "../core.js";
/**
* This enum gives the options of the types of actions that can be
* performed and for which access control needs to be considered.
*
* This works in conjunction with the {@link AccessController}.
*/
declare enum Action {
UNKNOWN = "UNKNOWN",
ADD_EVENT = "ADD_EVENT",
ADD_ATTACK = "ADD_ATTACK",
GET_RESPONSES = "GET_RESPONSES",
EXECUTE_REPORT = "EXECUTE_REPORT",
GET_EVENTS = "GET_EVENTS",
GET_ATTACKS = "GET_ATTACKS"
}
/**
* Role is the standard attribution of an access to be used by the {@link AccessController}
* to determine {@link ClientApplication} access to the different pieces of functionality.
*/
declare enum Role {
ADD_EVENT = "ADD_EVENT",
ADD_ATTACK = "ADD_ATTACK",
GET_RESPONSES = "GET_RESPONSES",
EXECUTE_REPORT = "EXECUTE_REPORT",
GET_EVENTS = "GET_EVENTS",
GET_ATTACKS = "GET_ATTACKS"
}
/**
* This class is intended to represent the "context" portion of
* a context-based {@link AccessController} . Conceptually, you would add
* attributes that you would like to evaluate to this object.
* Normal examples might include things like timestamps, geolocation, etc.
*/
declare class Context {
}
/**
* This interface is meant to gate access to the different {@link Action}
* that can be performed to ensure a {@link ClientApplication} has appropriate permissions.
*/
interface AccessController {
isAuthorized(clientApplication: ClientApplication, action: Action, context: Context): boolean;
assertAuthorized(clientApplication: ClientApplication, action: Action, context: Context): void;
}
export { Action, Role, Context, AccessController };