Move policy decision types to permission-common

Co-authored-by: Mike Lewis <mtlewis@users.noreply.github.com>
Signed-off-by: Joe Porpeglia <josephp@spotify.com>
This commit is contained in:
Joe Porpeglia
2022-03-21 21:56:49 -04:00
committed by Joe Porpeglia
parent ac0a6cb827
commit 970814ed38
8 changed files with 54 additions and 59 deletions
@@ -50,6 +50,46 @@ export enum AuthorizeResult {
CONDITIONAL = 'CONDITIONAL',
}
/**
* A definitive decision returned by the {@link @backstage/plugin-permission-node#PermissionPolicy}.
*
* @remarks
*
* This indicates that the policy unconditionally allows (or denies) the request.
*
* @public
*/
export type DefinitivePolicyDecision = {
result: AuthorizeResult.ALLOW | AuthorizeResult.DENY;
};
/**
* A conditional decision returned by the {@link @backstage/plugin-permission-node#PermissionPolicy}.
*
* @remarks
*
* This indicates that the policy allows authorization for the request, given that the returned
* conditions hold when evaluated. The conditions will be evaluated by the corresponding plugin
* which knows about the referenced permission rules.
*
* @public
*/
export type ConditionalPolicyDecision = {
result: AuthorizeResult.CONDITIONAL;
pluginId: string;
resourceType: string;
conditions: PermissionCriteria<PermissionCondition>;
};
/**
* A decision returned by the {@link @backstage/plugin-permission-node#PermissionPolicy}.
*
* @public
*/
export type PolicyDecision =
| DefinitivePolicyDecision
| ConditionalPolicyDecision;
/**
* An individual authorization request for {@link PermissionClient#authorize}.
* @public
@@ -22,6 +22,9 @@ export type {
AuthorizeResponse,
IdentifiedPermissionMessage,
PermissionMessageBatch,
ConditionalPolicyDecision,
DefinitivePolicyDecision,
PolicyDecision,
PermissionCondition,
PermissionCriteria,
AllOfCriteria,