Rename permission backend request and response types
Signed-off-by: Joe Porpeglia <josephp@spotify.com>
This commit is contained in:
committed by
Joe Porpeglia
parent
970814ed38
commit
e43290ce96
@@ -17,7 +17,7 @@
|
||||
import { ServerPermissionClient } from './ServerPermissionClient';
|
||||
import {
|
||||
IdentifiedPermissionMessage,
|
||||
AuthorizeQuery,
|
||||
EvaluatePermissionRequest,
|
||||
AuthorizeResult,
|
||||
createPermission,
|
||||
} from '@backstage/plugin-permission-common';
|
||||
@@ -33,7 +33,7 @@ import { RestContext, rest } from 'msw';
|
||||
const server = setupServer();
|
||||
const mockAuthorizeHandler = jest.fn((req, res, { json }: RestContext) => {
|
||||
const responses = req.body.items.map(
|
||||
(r: IdentifiedPermissionMessage<AuthorizeQuery>) => ({
|
||||
(r: IdentifiedPermissionMessage<EvaluatePermissionRequest>) => ({
|
||||
id: r.id,
|
||||
result: AuthorizeResult.ALLOW,
|
||||
}),
|
||||
|
||||
@@ -20,9 +20,9 @@ import {
|
||||
} from '@backstage/backend-common';
|
||||
import { Config } from '@backstage/config';
|
||||
import {
|
||||
AuthorizeQuery,
|
||||
EvaluatePermissionRequest,
|
||||
AuthorizeRequestOptions,
|
||||
AuthorizeDecision,
|
||||
EvaluatePermissionResponse,
|
||||
AuthorizeResult,
|
||||
PermissionClient,
|
||||
PermissionAuthorizer,
|
||||
@@ -78,9 +78,9 @@ export class ServerPermissionClient implements PermissionAuthorizer {
|
||||
}
|
||||
|
||||
async authorize(
|
||||
queries: AuthorizeQuery[],
|
||||
requests: EvaluatePermissionRequest[],
|
||||
options?: AuthorizeRequestOptions,
|
||||
): Promise<AuthorizeDecision[]> {
|
||||
): Promise<EvaluatePermissionResponse[]> {
|
||||
// Check if permissions are enabled before validating the server token. That
|
||||
// way when permissions are disabled, the noop token manager can be used
|
||||
// without fouling up the logic inside the ServerPermissionClient, because
|
||||
@@ -89,9 +89,9 @@ export class ServerPermissionClient implements PermissionAuthorizer {
|
||||
!this.permissionEnabled ||
|
||||
(await this.isValidServerToken(options?.token))
|
||||
) {
|
||||
return queries.map(_ => ({ result: AuthorizeResult.ALLOW }));
|
||||
return requests.map(_ => ({ result: AuthorizeResult.ALLOW }));
|
||||
}
|
||||
return this.permissionClient.authorize(queries, options);
|
||||
return this.permissionClient.authorize(requests, options);
|
||||
}
|
||||
|
||||
private async isValidServerToken(
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
|
||||
import {
|
||||
AuthorizeQuery,
|
||||
EvaluatePermissionRequest,
|
||||
PolicyDecision,
|
||||
} from '@backstage/plugin-permission-common';
|
||||
import { BackstageIdentityResponse } from '@backstage/plugin-auth-node';
|
||||
@@ -31,7 +31,10 @@ import { BackstageIdentityResponse } from '@backstage/plugin-auth-node';
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export type PolicyAuthorizeQuery = Omit<AuthorizeQuery, 'resourceRef'>;
|
||||
export type PolicyAuthorizeQuery = Omit<
|
||||
EvaluatePermissionRequest,
|
||||
'resourceRef'
|
||||
>;
|
||||
|
||||
/**
|
||||
* A policy to evaluate authorization requests for any permissioned action performed in Backstage.
|
||||
|
||||
Reference in New Issue
Block a user