permission-common: removed the token option from the base evaluator options
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-permission-common': minor
|
||||
---
|
||||
|
||||
**BREAKING**: Removed the deprecated and unused `token` option from `EvaluatorRequestOptions`. The `PermissionsClient` now has its own `PermissionClientRequestOptions` type that declares the `token` option instead.
|
||||
@@ -94,9 +94,7 @@ export type EvaluatePermissionResponseBatch =
|
||||
PermissionMessageBatch<EvaluatePermissionResponse>;
|
||||
|
||||
// @public
|
||||
export type EvaluatorRequestOptions = {
|
||||
token?: string;
|
||||
};
|
||||
export interface EvaluatorRequestOptions {}
|
||||
|
||||
// @public
|
||||
export type IdentifiedPermissionMessage<T> = T & {
|
||||
@@ -162,14 +160,19 @@ export class PermissionClient implements PermissionEvaluator {
|
||||
constructor(options: { discovery: DiscoveryApi; config: Config });
|
||||
authorize(
|
||||
requests: AuthorizePermissionRequest[],
|
||||
options?: EvaluatorRequestOptions,
|
||||
options?: PermissionClientRequestOptions,
|
||||
): Promise<AuthorizePermissionResponse[]>;
|
||||
authorizeConditional(
|
||||
queries: QueryPermissionRequest[],
|
||||
options?: EvaluatorRequestOptions,
|
||||
options?: PermissionClientRequestOptions,
|
||||
): Promise<QueryPermissionResponse[]>;
|
||||
}
|
||||
|
||||
// @public
|
||||
export type PermissionClientRequestOptions = {
|
||||
token?: string;
|
||||
};
|
||||
|
||||
// @public
|
||||
export type PermissionCondition<
|
||||
TResourceType extends string = string,
|
||||
@@ -191,11 +194,15 @@ export type PermissionCriteria<TQuery> =
|
||||
export interface PermissionEvaluator {
|
||||
authorize(
|
||||
requests: AuthorizePermissionRequest[],
|
||||
options?: EvaluatorRequestOptions,
|
||||
options?: EvaluatorRequestOptions & {
|
||||
_ignored?: never;
|
||||
},
|
||||
): Promise<AuthorizePermissionResponse[]>;
|
||||
authorizeConditional(
|
||||
requests: QueryPermissionRequest[],
|
||||
options?: EvaluatorRequestOptions,
|
||||
options?: EvaluatorRequestOptions & {
|
||||
_ignored?: never;
|
||||
},
|
||||
): Promise<QueryPermissionResponse[]>;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@ import {
|
||||
PermissionEvaluator,
|
||||
QueryPermissionRequest,
|
||||
AuthorizePermissionRequest,
|
||||
EvaluatorRequestOptions,
|
||||
AuthorizePermissionResponse,
|
||||
QueryPermissionResponse,
|
||||
} from './types/api';
|
||||
@@ -93,6 +92,15 @@ const responseSchema = <T>(
|
||||
),
|
||||
});
|
||||
|
||||
/**
|
||||
* Options for {@link PermissionClient} requests.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export type PermissionClientRequestOptions = {
|
||||
token?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* An isomorphic client for requesting authorization for Backstage permissions.
|
||||
* @public
|
||||
@@ -112,7 +120,7 @@ export class PermissionClient implements PermissionEvaluator {
|
||||
*/
|
||||
async authorize(
|
||||
requests: AuthorizePermissionRequest[],
|
||||
options?: EvaluatorRequestOptions,
|
||||
options?: PermissionClientRequestOptions,
|
||||
): Promise<AuthorizePermissionResponse[]> {
|
||||
return this.makeRequest(
|
||||
requests,
|
||||
@@ -126,7 +134,7 @@ export class PermissionClient implements PermissionEvaluator {
|
||||
*/
|
||||
async authorizeConditional(
|
||||
queries: QueryPermissionRequest[],
|
||||
options?: EvaluatorRequestOptions,
|
||||
options?: PermissionClientRequestOptions,
|
||||
): Promise<QueryPermissionResponse[]> {
|
||||
return this.makeRequest(queries, queryPermissionResponseSchema, options);
|
||||
}
|
||||
|
||||
@@ -244,7 +244,7 @@ export interface PermissionEvaluator {
|
||||
*/
|
||||
authorize(
|
||||
requests: AuthorizePermissionRequest[],
|
||||
options?: EvaluatorRequestOptions,
|
||||
options?: EvaluatorRequestOptions & { _ignored?: never }, // Since the options are empty we add this placeholder to reject all options
|
||||
): Promise<AuthorizePermissionResponse[]>;
|
||||
|
||||
/**
|
||||
@@ -257,22 +257,20 @@ export interface PermissionEvaluator {
|
||||
*/
|
||||
authorizeConditional(
|
||||
requests: QueryPermissionRequest[],
|
||||
options?: EvaluatorRequestOptions,
|
||||
options?: EvaluatorRequestOptions & { _ignored?: never }, // Since the options are empty we add this placeholder to reject all options
|
||||
): Promise<QueryPermissionResponse[]>;
|
||||
}
|
||||
|
||||
// Note(Rugvip): I kept the below type around in case we want to add new options
|
||||
// in the future, for example a signal. It also helps out enabling API
|
||||
// constraints, as without this we can't have the permissions service implement
|
||||
// the evaluator interface due to the mismatch in parameter count.
|
||||
|
||||
/**
|
||||
* Options for {@link PermissionEvaluator} requests.
|
||||
*
|
||||
* This is currently empty, as there are no longer any common options for the permission evaluator.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export type EvaluatorRequestOptions = {
|
||||
/**
|
||||
* @deprecated Backend plugins should no longer depend on the
|
||||
* `PermissionEvaluator`, but instead use the `PermissionService` from
|
||||
* `@backstage/backend-plugin-api`. Frontend plugins should not need to inject
|
||||
* this token at all, but instead implicitly rely on underlying fetchApi to do
|
||||
* it for them.
|
||||
*/
|
||||
token?: string;
|
||||
};
|
||||
export interface EvaluatorRequestOptions {}
|
||||
|
||||
Reference in New Issue
Block a user