From e6c86a3f0796feb0f26ff27617273c7ac0036caf Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Mon, 15 Jan 2024 11:47:06 +0100 Subject: [PATCH] Fix FieldRule (#2362) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix FieldRule * `username` can also be a list, * `realm.name` is the field name, using an intermediate `realm` object does not work. * `metadata` is not a key: keys are of the form `metadata.key = value` * Apply suggestions from code review Co-authored-by: Laurent Saint-Félix * Run `make contrib` * Update RoleMappingRule.ts Co-authored-by: Laurent Saint-Félix * Address review comments --------- Co-authored-by: Laurent Saint-Félix (cherry picked from commit 383d22a67299c8e8b2d1317fe7cae2bbded5b615) --- output/schema/schema.json | 43 ++++--------------- output/typescript/types.ts | 9 +--- .../security/_types/RoleMappingRule.ts | 12 +++--- 3 files changed, 15 insertions(+), 49 deletions(-) diff --git a/output/schema/schema.json b/output/schema/schema.json index 89a67b537e..f08193ac72 100644 --- a/output/schema/schema.json +++ b/output/schema/schema.json @@ -169890,7 +169890,7 @@ "type": { "kind": "instance_of", "type": { - "name": "Name", + "name": "Names", "namespace": "_types" } } @@ -169918,27 +169918,21 @@ } }, { - "name": "metadata", - "required": false, - "type": { - "kind": "user_defined_value" - } - }, - { - "name": "realm", + "name": "realm.name", "required": false, "type": { "kind": "instance_of", "type": { - "name": "Realm", - "namespace": "security._types" + "name": "Name", + "namespace": "_types" } } } ], - "specLocation": "security/_types/RoleMappingRule.ts#L33-L42", + "specLocation": "security/_types/RoleMappingRule.ts#L34-L44", "variants": { - "kind": "container" + "kind": "container", + "nonExhaustive": true } }, { @@ -170220,27 +170214,6 @@ ], "specLocation": "security/_types/Privileges.ts#L197-L199" }, - { - "kind": "interface", - "name": { - "name": "Realm", - "namespace": "security._types" - }, - "properties": [ - { - "name": "name", - "required": true, - "type": { - "kind": "instance_of", - "type": { - "name": "Name", - "namespace": "_types" - } - } - } - ], - "specLocation": "security/_types/RoleMappingRule.ts#L44-L46" - }, { "kind": "interface", "name": { @@ -170672,7 +170645,7 @@ } } ], - "specLocation": "security/_types/RoleMappingRule.ts#L23-L31", + "specLocation": "security/_types/RoleMappingRule.ts#L24-L32", "variants": { "kind": "container" } diff --git a/output/typescript/types.ts b/output/typescript/types.ts index 9ffd778679..a8cea64c19 100644 --- a/output/typescript/types.ts +++ b/output/typescript/types.ts @@ -15977,11 +15977,10 @@ export interface SecurityCreatedStatus { } export interface SecurityFieldRule { - username?: Name + username?: Names dn?: Names groups?: Names - metadata?: any - realm?: SecurityRealm + 'realm.name'?: Name } export interface SecurityFieldSecurity { @@ -16011,10 +16010,6 @@ export interface SecurityManageUserPrivileges { applications: string[] } -export interface SecurityRealm { - name: Name -} - export interface SecurityRealmInfo { name: Name type: string diff --git a/specification/security/_types/RoleMappingRule.ts b/specification/security/_types/RoleMappingRule.ts index b373fb4eb0..85b52882a8 100644 --- a/specification/security/_types/RoleMappingRule.ts +++ b/specification/security/_types/RoleMappingRule.ts @@ -26,21 +26,19 @@ import { Name, Names } from '@_types/common' export class RoleMappingRule { any?: RoleMappingRule[] all?: RoleMappingRule[] + // `field` should have been defined as SingleKeyDictionary + // However, this was initially defined as a container with a limited number of variants, + // and was later made non_exhaustive to limit breaking changes. field?: FieldRule except?: RoleMappingRule } /** * @variants container + * @non_exhaustive */ export class FieldRule { - username?: Name + username?: Names dn?: Names groups?: Names - metadata?: UserDefinedValue - realm?: Realm -} - -export class Realm { - name: Name }