Rename policy input type

Signed-off-by: Joe Porpeglia <josephp@spotify.com>
This commit is contained in:
Joe Porpeglia
2022-03-22 10:49:42 -04:00
committed by Joe Porpeglia
parent e43290ce96
commit 0b98a49509
2 changed files with 9 additions and 11 deletions
+1 -1
View File
@@ -14,4 +14,4 @@
* limitations under the License.
*/
export type { PermissionPolicy, PolicyAuthorizeQuery } from './types';
export type { PermissionPolicy, PolicyQuery } from './types';
+8 -10
View File
@@ -15,26 +15,24 @@
*/
import {
EvaluatePermissionRequest,
Permission,
PolicyDecision,
} from '@backstage/plugin-permission-common';
import { BackstageIdentityResponse } from '@backstage/plugin-auth-node';
/**
* An authorization request to be evaluated by the {@link PermissionPolicy}.
* A query to be evaluated by the {@link PermissionPolicy}.
*
* @remarks
*
* This differs from {@link @backstage/permission-common#AuthorizeQuery} in that `resourceRef`
* should never be provided. This forces policies to be written in a way that's compatible with
* filtering collections of resources at data load time.
* Unlike other parts of the permission API, the policy does not accept a resource ref. This keeps
* the policy decoupled from the resource loading and condition applying logic.
*
* @public
*/
export type PolicyAuthorizeQuery = Omit<
EvaluatePermissionRequest,
'resourceRef'
>;
export type PolicyQuery = {
permission: Permission;
};
/**
* A policy to evaluate authorization requests for any permissioned action performed in Backstage.
@@ -54,7 +52,7 @@ export type PolicyAuthorizeQuery = Omit<
*/
export interface PermissionPolicy {
handle(
request: PolicyAuthorizeQuery,
request: PolicyQuery,
user?: BackstageIdentityResponse,
): Promise<PolicyDecision>;
}