Limited the permission rule parameters to JsonPrimatives and array of
Signed-off-by: Harry Hogg <hhogg@spotify.com>
This commit is contained in:
@@ -43,6 +43,7 @@
|
||||
"dependencies": {
|
||||
"@backstage/config": "workspace:^",
|
||||
"@backstage/errors": "workspace:^",
|
||||
"@backstage/types": "workspace:^",
|
||||
"cross-fetch": "^3.1.5",
|
||||
"uuid": "^8.0.0",
|
||||
"zod": "^3.11.6"
|
||||
|
||||
@@ -41,7 +41,7 @@ const permissionCriteriaSchema: z.ZodSchema<
|
||||
.object({
|
||||
rule: z.string(),
|
||||
resourceType: z.string(),
|
||||
params: z.record(z.unknown()),
|
||||
params: z.record(z.any()),
|
||||
})
|
||||
.or(z.object({ anyOf: z.array(permissionCriteriaSchema).nonempty() }))
|
||||
.or(z.object({ allOf: z.array(permissionCriteriaSchema).nonempty() }))
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { JsonPrimitive } from '@backstage/types';
|
||||
import { ResourcePermission } from '.';
|
||||
import { Permission } from './permission';
|
||||
|
||||
@@ -101,7 +102,7 @@ export type PolicyDecision =
|
||||
*/
|
||||
export type PermissionCondition<
|
||||
TResourceType extends string = string,
|
||||
TParams extends Record<string, unknown> = Record<string, unknown>,
|
||||
TParams extends PermissionRuleParams = PermissionRuleParams,
|
||||
> = {
|
||||
resourceType: TResourceType;
|
||||
rule: string;
|
||||
@@ -148,6 +149,16 @@ export type PermissionCriteria<TQuery> =
|
||||
| NotCriteria<TQuery>
|
||||
| TQuery;
|
||||
|
||||
/**
|
||||
* A parameter to a permission rule.
|
||||
*/
|
||||
export type PermissionRuleParam = undefined | JsonPrimitive | JsonPrimitive[];
|
||||
|
||||
/**
|
||||
* Types that can be used as parameters to permission rules.
|
||||
*/
|
||||
export type PermissionRuleParams = Record<string, PermissionRuleParam>;
|
||||
|
||||
/**
|
||||
* An individual request sent to the permission backend.
|
||||
* @public
|
||||
|
||||
@@ -33,6 +33,8 @@ export type {
|
||||
PolicyDecision,
|
||||
PermissionCondition,
|
||||
PermissionCriteria,
|
||||
PermissionRuleParam,
|
||||
PermissionRuleParams,
|
||||
AllOfCriteria,
|
||||
AnyOfCriteria,
|
||||
NotCriteria,
|
||||
|
||||
Reference in New Issue
Block a user