From e79e280dc76efe5964ad0b53242d6b44e4524073 Mon Sep 17 00:00:00 2001 From: Max Peintner Date: Fri, 14 Apr 2023 17:20:53 +0200 Subject: [PATCH] fix(console): set options (#5605) fix: set idp options --- .../provider-azure-ad.component.html | 13 ++-- .../provider-azure-ad.component.ts | 41 ++++++++++--- .../provider-github-es.component.html | 11 +++- .../provider-github-es.component.ts | 2 + .../provider-github.component.html | 11 +++- ...provider-gitlab-self-hosted.component.html | 11 +++- .../provider-gitlab.component.html | 11 +++- .../provider-google.component.html | 10 ++- .../provider-ldap.component.html | 10 ++- .../provider-oauth.component.html | 61 ++++++++++--------- .../provider-oauth.component.ts | 2 + .../provider-oidc/provider-oidc.component.ts | 2 + .../src/app/modules/providers/providers.scss | 4 ++ console/src/app/services/admin.service.ts | 4 ++ console/src/app/services/mgmt.service.ts | 4 ++ console/src/assets/i18n/de.json | 1 + console/src/assets/i18n/en.json | 1 + console/src/assets/i18n/es.json | 7 ++- console/src/assets/i18n/fr.json | 1 + console/src/assets/i18n/it.json | 1 + console/src/assets/i18n/ja.json | 7 ++- console/src/assets/i18n/pl.json | 1 + console/src/assets/i18n/zh.json | 1 + 23 files changed, 154 insertions(+), 63 deletions(-) diff --git a/console/src/app/modules/providers/provider-azure-ad/provider-azure-ad.component.html b/console/src/app/modules/providers/provider-azure-ad/provider-azure-ad.component.html index a10621d0ef..259cdc530c 100644 --- a/console/src/app/modules/providers/provider-azure-ad/provider-azure-ad.component.html +++ b/console/src/app/modules/providers/provider-azure-ad/provider-azure-ad.component.html @@ -25,9 +25,14 @@ - {{ - 'IDP.UPDATECLIENTSECRET' | translate - }} + {{ 'IDP.UPDATECLIENTSECRET' | translate }} + {{ 'IDP.CLIENTSECRET' | translate }} @@ -85,7 +90,7 @@ - + {{ 'IDP.AZUREADTENANTID' | translate }} diff --git a/console/src/app/modules/providers/provider-azure-ad/provider-azure-ad.component.ts b/console/src/app/modules/providers/provider-azure-ad/provider-azure-ad.component.ts index df188d9cd2..0933433a67 100644 --- a/console/src/app/modules/providers/provider-azure-ad/provider-azure-ad.component.ts +++ b/console/src/app/modules/providers/provider-azure-ad/provider-azure-ad.component.ts @@ -44,7 +44,10 @@ export class ProviderAzureADComponent { public provider?: Provider.AsObject; public updateClientSecret: boolean = false; + + public AzureTenantIDType: number = 3; public tenantTypes = [ + this.AzureTenantIDType, AzureADTenantType.AZURE_AD_TENANT_TYPE_COMMON, AzureADTenantType.AZURE_AD_TENANT_TYPE_ORGANISATIONS, AzureADTenantType.AZURE_AD_TENANT_TYPE_CONSUMERS, @@ -126,15 +129,34 @@ export class ProviderAzureADComponent { : new MgmtGetProviderByIDRequest(); req.setId(id); this.service - .getProviderByID(req) + .getProviderID(req) .then((resp) => { - this.provider = resp.idp; + const object = resp.toObject(); + this.provider = object.idp; this.loading = false; if (this.provider?.config?.azureAd) { this.form.patchValue(this.provider.config.azureAd); this.name?.setValue(this.provider.name); this.tenantId?.setValue(this.provider.config.azureAd.tenant?.tenantId); this.tenantType?.setValue(this.provider.config.azureAd.tenant?.tenantType); + + const tenant = resp.getIdp()?.getConfig()?.getAzureAd()?.getTenant(); + + if (tenant) { + switch (tenant.getTypeCase()) { + case AzureADTenant.TypeCase.TENANT_ID: + this.tenantId?.setValue(tenant.getTenantId()); + this.tenantType?.setValue(this.AzureTenantIDType); + break; + case AzureADTenant.TypeCase.TENANT_TYPE: + this.tenantType?.setValue(tenant.getTenantType()); + this.tenantId?.setValue(''); + break; + case AzureADTenant.TypeCase.TYPE_NOT_SET: + this.tenantType?.setValue(this.AzureTenantIDType); + break; + } + } } }) .catch((error) => { @@ -159,8 +181,11 @@ export class ProviderAzureADComponent { req.setEmailVerified(this.emailVerified?.value); const tenant = new AzureADTenant(); - tenant.setTenantId(this.tenantId?.value); - tenant.setTenantType(this.tenantType?.value); + if (this.tenantType?.value === this.AzureTenantIDType) { + tenant.setTenantId(this.tenantId?.value); + } else { + tenant.setTenantType(this.tenantType?.value); + } req.setTenant(tenant); req.setScopesList(this.scopesList?.value); @@ -194,9 +219,11 @@ export class ProviderAzureADComponent { req.setEmailVerified(this.emailVerified?.value); const tenant = new AzureADTenant(); - - tenant.setTenantId(this.tenantId?.value); - tenant.setTenantType(this.tenantType?.value); + if (this.tenantType?.value === this.AzureTenantIDType) { + tenant.setTenantId(this.tenantId?.value); + } else { + tenant.setTenantType(this.tenantType?.value); + } req.setTenant(tenant); req.setScopesList(this.scopesList?.value); diff --git a/console/src/app/modules/providers/provider-github-es/provider-github-es.component.html b/console/src/app/modules/providers/provider-github-es/provider-github-es.component.html index f0c439d298..a4511570a6 100644 --- a/console/src/app/modules/providers/provider-github-es/provider-github-es.component.html +++ b/console/src/app/modules/providers/provider-github-es/provider-github-es.component.html @@ -40,9 +40,14 @@ - {{ - 'IDP.UPDATECLIENTSECRET' | translate - }} + {{ 'IDP.UPDATECLIENTSECRET' | translate }} + {{ 'IDP.CLIENTSECRET' | translate }} diff --git a/console/src/app/modules/providers/provider-github-es/provider-github-es.component.ts b/console/src/app/modules/providers/provider-github-es/provider-github-es.component.ts index 3264f0b297..847006e7f4 100644 --- a/console/src/app/modules/providers/provider-github-es/provider-github-es.component.ts +++ b/console/src/app/modules/providers/provider-github-es/provider-github-es.component.ts @@ -153,6 +153,7 @@ export class ProviderGithubESComponent { req.setClientId(this.clientId?.value); req.setClientSecret(this.clientSecret?.value); req.setScopesList(this.scopesList?.value); + req.setProviderOptions(this.options); this.loading = true; this.service @@ -183,6 +184,7 @@ export class ProviderGithubESComponent { req.setClientId(this.clientId?.value); req.setClientSecret(this.clientSecret?.value); req.setScopesList(this.scopesList?.value); + req.setProviderOptions(this.options); this.loading = true; this.service diff --git a/console/src/app/modules/providers/provider-github/provider-github.component.html b/console/src/app/modules/providers/provider-github/provider-github.component.html index 8b40a2070e..540c178709 100644 --- a/console/src/app/modules/providers/provider-github/provider-github.component.html +++ b/console/src/app/modules/providers/provider-github/provider-github.component.html @@ -21,9 +21,14 @@ - {{ - 'IDP.UPDATECLIENTSECRET' | translate - }} + {{ 'IDP.UPDATECLIENTSECRET' | translate }} + {{ 'IDP.CLIENTSECRET' | translate }} diff --git a/console/src/app/modules/providers/provider-gitlab-self-hosted/provider-gitlab-self-hosted.component.html b/console/src/app/modules/providers/provider-gitlab-self-hosted/provider-gitlab-self-hosted.component.html index 194e9dbede..61df5dfbbc 100644 --- a/console/src/app/modules/providers/provider-gitlab-self-hosted/provider-gitlab-self-hosted.component.html +++ b/console/src/app/modules/providers/provider-gitlab-self-hosted/provider-gitlab-self-hosted.component.html @@ -30,9 +30,14 @@ - {{ - 'IDP.UPDATECLIENTSECRET' | translate - }} + {{ 'IDP.UPDATECLIENTSECRET' | translate }} + {{ 'IDP.CLIENTSECRET' | translate }} diff --git a/console/src/app/modules/providers/provider-gitlab/provider-gitlab.component.html b/console/src/app/modules/providers/provider-gitlab/provider-gitlab.component.html index 0ef22147de..c4ec64094b 100644 --- a/console/src/app/modules/providers/provider-gitlab/provider-gitlab.component.html +++ b/console/src/app/modules/providers/provider-gitlab/provider-gitlab.component.html @@ -20,9 +20,14 @@ - {{ - 'IDP.UPDATECLIENTSECRET' | translate - }} + {{ 'IDP.UPDATECLIENTSECRET' | translate }} + {{ 'IDP.CLIENTSECRET' | translate }} diff --git a/console/src/app/modules/providers/provider-google/provider-google.component.html b/console/src/app/modules/providers/provider-google/provider-google.component.html index 912d4fd8b5..a77006c7af 100644 --- a/console/src/app/modules/providers/provider-google/provider-google.component.html +++ b/console/src/app/modules/providers/provider-google/provider-google.component.html @@ -20,9 +20,13 @@ - {{ - 'IDP.UPDATECLIENTSECRET' | translate - }} + {{ 'IDP.UPDATECLIENTSECRET' | translate }} {{ 'IDP.CLIENTSECRET' | translate }} diff --git a/console/src/app/modules/providers/provider-ldap/provider-ldap.component.html b/console/src/app/modules/providers/provider-ldap/provider-ldap.component.html index ee49949346..28b7f5ec6f 100644 --- a/console/src/app/modules/providers/provider-ldap/provider-ldap.component.html +++ b/console/src/app/modules/providers/provider-ldap/provider-ldap.component.html @@ -39,9 +39,13 @@ - {{ - 'IDP.UPDATEBINDPASSWORD' | translate - }} + {{ 'IDP.UPDATEBINDPASSWORD' | translate }} {{ 'IDP.BINDPASSWORD' | translate }} diff --git a/console/src/app/modules/providers/provider-oauth/provider-oauth.component.html b/console/src/app/modules/providers/provider-oauth/provider-oauth.component.html index b88aece27d..da85abb3a3 100644 --- a/console/src/app/modules/providers/provider-oauth/provider-oauth.component.html +++ b/console/src/app/modules/providers/provider-oauth/provider-oauth.component.html @@ -13,40 +13,45 @@

{{ 'IDP.CREATE.OAUTH.DESCRIPTION' | translate }}

- - {{ 'IDP.NAME' | translate }} - - - - - {{ 'IDP.AUTHORIZATIONENDPOINT' | translate }} - - - - - {{ 'IDP.TOKENENDPOINT' | translate }} - - - - - {{ 'IDP.USERENDPOINT' | translate }} - - - - - {{ 'IDP.IDATTRIBUTE' | translate }} - - -
+ + {{ 'IDP.NAME' | translate }} + + + + + {{ 'IDP.AUTHORIZATIONENDPOINT' | translate }} + + + + + {{ 'IDP.TOKENENDPOINT' | translate }} + + + + + {{ 'IDP.USERENDPOINT' | translate }} + + + + + {{ 'IDP.IDATTRIBUTE' | translate }} + + + {{ 'IDP.CLIENTID' | translate }} - {{ - 'IDP.UPDATECLIENTSECRET' | translate - }} + {{ 'IDP.UPDATECLIENTSECRET' | translate }} + {{ 'IDP.CLIENTSECRET' | translate }} diff --git a/console/src/app/modules/providers/provider-oauth/provider-oauth.component.ts b/console/src/app/modules/providers/provider-oauth/provider-oauth.component.ts index e789e89eb4..3f68bf83a6 100644 --- a/console/src/app/modules/providers/provider-oauth/provider-oauth.component.ts +++ b/console/src/app/modules/providers/provider-oauth/provider-oauth.component.ts @@ -155,6 +155,7 @@ export class ProviderOAuthComponent { req.setClientId(this.clientId?.value); req.setClientSecret(this.clientSecret?.value); req.setScopesList(this.scopesList?.value); + req.setProviderOptions(this.options); this.loading = true; this.service @@ -186,6 +187,7 @@ export class ProviderOAuthComponent { req.setClientId(this.clientId?.value); req.setClientSecret(this.clientSecret?.value); req.setScopesList(this.scopesList?.value); + req.setProviderOptions(this.options); this.loading = true; this.service diff --git a/console/src/app/modules/providers/provider-oidc/provider-oidc.component.ts b/console/src/app/modules/providers/provider-oidc/provider-oidc.component.ts index 6302df15c6..b26d2e9f92 100644 --- a/console/src/app/modules/providers/provider-oidc/provider-oidc.component.ts +++ b/console/src/app/modules/providers/provider-oidc/provider-oidc.component.ts @@ -130,6 +130,7 @@ export class ProviderOIDCComponent { req.setClientSecret(this.clientSecret?.value); req.setIssuer(this.issuer?.value); req.setScopesList(this.scopesList?.value); + req.setProviderOptions(this.options); this.loading = true; this.service @@ -158,6 +159,7 @@ export class ProviderOIDCComponent { req.setClientSecret(this.clientSecret?.value); req.setIssuer(this.issuer?.value); req.setScopesList(this.scopesList?.value); + req.setProviderOptions(this.options); this.loading = true; this.service diff --git a/console/src/app/modules/providers/providers.scss b/console/src/app/modules/providers/providers.scss index cb3ccaddf7..4241609431 100644 --- a/console/src/app/modules/providers/providers.scss +++ b/console/src/app/modules/providers/providers.scss @@ -36,6 +36,10 @@ } } + .update-secret-checkbox { + margin: 0.5rem 0 0 0; + } + .formfield { display: block; max-width: 400px; diff --git a/console/src/app/services/admin.service.ts b/console/src/app/services/admin.service.ts index c47c576979..e6e2b130ad 100644 --- a/console/src/app/services/admin.service.ts +++ b/console/src/app/services/admin.service.ts @@ -1047,6 +1047,10 @@ export class AdminService { return this.grpcService.admin.getProviderByID(req, null).then((resp) => resp.toObject()); } + public getProviderID(req: GetProviderByIDRequest): Promise { + return this.grpcService.admin.getProviderByID(req, null); + } + public listIAMMembers( limit: number, offset: number, diff --git a/console/src/app/services/mgmt.service.ts b/console/src/app/services/mgmt.service.ts index 0574bbf4af..49efdcb4c4 100644 --- a/console/src/app/services/mgmt.service.ts +++ b/console/src/app/services/mgmt.service.ts @@ -987,6 +987,10 @@ export class ManagementService { return this.grpcService.mgmt.getProviderByID(req, null).then((resp) => resp.toObject()); } + public getProviderID(req: GetProviderByIDRequest): Promise { + return this.grpcService.mgmt.getProviderByID(req, null); + } + public addHumanUser(req: AddHumanUserRequest): Promise { return this.grpcService.mgmt.addHumanUser(req, null).then((resp) => resp.toObject()); } diff --git a/console/src/assets/i18n/de.json b/console/src/assets/i18n/de.json index 39810d6ddd..d54974b5b2 100644 --- a/console/src/assets/i18n/de.json +++ b/console/src/assets/i18n/de.json @@ -1699,6 +1699,7 @@ "2": "inaktiv" }, "AZUREADTENANTTYPES": { + "3": "Tenant ID", "0": "Common", "1": "Organizations", "2": "Consumers" diff --git a/console/src/assets/i18n/en.json b/console/src/assets/i18n/en.json index 0b8198e390..8aabe4d58e 100644 --- a/console/src/assets/i18n/en.json +++ b/console/src/assets/i18n/en.json @@ -1699,6 +1699,7 @@ "2": "inactive" }, "AZUREADTENANTTYPES": { + "3": "Tenant ID", "0": "Common", "1": "Organizations", "2": "Consumers" diff --git a/console/src/assets/i18n/es.json b/console/src/assets/i18n/es.json index 3514cf8132..c9c1a26829 100644 --- a/console/src/assets/i18n/es.json +++ b/console/src/assets/i18n/es.json @@ -1699,9 +1699,10 @@ "2": "inactivo" }, "AZUREADTENANTTYPES": { - "0": "Común", - "1": "Organizaciones", - "2": "Clientes" + "3": "Tenant ID", + "0": "Common", + "1": "Organizations", + "2": "Consumers" }, "AZUREADTENANTTYPE": "Tipo de Tenant", "AZUREADTENANTID": "ID de Tenant", diff --git a/console/src/assets/i18n/fr.json b/console/src/assets/i18n/fr.json index 2a0e3292b8..6c11c83522 100644 --- a/console/src/assets/i18n/fr.json +++ b/console/src/assets/i18n/fr.json @@ -1703,6 +1703,7 @@ "2": "inactif" }, "AZUREADTENANTTYPES": { + "3": "Tenant ID", "0": "Common", "1": "Organizations", "2": "Consumers" diff --git a/console/src/assets/i18n/it.json b/console/src/assets/i18n/it.json index 8a1e3dc07b..4b9c88bae4 100644 --- a/console/src/assets/i18n/it.json +++ b/console/src/assets/i18n/it.json @@ -1704,6 +1704,7 @@ "2": "inattivo" }, "AZUREADTENANTTYPES": { + "3": "Tenant ID", "0": "Common", "1": "Organizations", "2": "Consumers" diff --git a/console/src/assets/i18n/ja.json b/console/src/assets/i18n/ja.json index 4821833892..5127adf698 100644 --- a/console/src/assets/i18n/ja.json +++ b/console/src/assets/i18n/ja.json @@ -1694,9 +1694,10 @@ "2": "非アクティブ" }, "AZUREADTENANTTYPES": { - "0": "共通", - "1": "組織", - "2": "顧客" + "3": "Tenant ID", + "0": "Common", + "1": "Organizations", + "2": "Consumers" }, "AZUREADTENANTTYPE": "テナントタイプ", "AZUREADTENANTID": "テナントID", diff --git a/console/src/assets/i18n/pl.json b/console/src/assets/i18n/pl.json index 3884b850c8..594e3654b2 100644 --- a/console/src/assets/i18n/pl.json +++ b/console/src/assets/i18n/pl.json @@ -1703,6 +1703,7 @@ "2": "nieaktywny" }, "AZUREADTENANTTYPES": { + "3": "Tenant ID", "0": "Common", "1": "Organizations", "2": "Consumers" diff --git a/console/src/assets/i18n/zh.json b/console/src/assets/i18n/zh.json index 27bb27d810..0c0b953e38 100644 --- a/console/src/assets/i18n/zh.json +++ b/console/src/assets/i18n/zh.json @@ -1702,6 +1702,7 @@ "2": "停用" }, "AZUREADTENANTTYPES": { + "3": "Tenant ID", "0": "Common", "1": "Organizations", "2": "Consumers"