Skip to content

Commit

Permalink
fix(console): set options (#5605)
Browse files Browse the repository at this point in the history
fix: set idp options
  • Loading branch information
peintnermax committed Apr 14, 2023
1 parent d140f93 commit e79e280
Show file tree
Hide file tree
Showing 23 changed files with 150 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,14 @@ <h1>{{ 'IDP.CREATE.AZUREAD.TITLE' | translate }}</h1>
<input cnslInput formControlName="clientId" />
</cnsl-form-field>

<mat-checkbox *ngIf="provider" [(ngModel)]="updateClientSecret" [ngModelOptions]="{ standalone: true }">{{
'IDP.UPDATECLIENTSECRET' | translate
}}</mat-checkbox>
<mat-checkbox
class="update-secret-checkbox"
*ngIf="provider"
[(ngModel)]="updateClientSecret"
[ngModelOptions]="{ standalone: true }"
>{{ 'IDP.UPDATECLIENTSECRET' | translate }}</mat-checkbox
>

<cnsl-form-field *ngIf="!provider || (provider && updateClientSecret)" class="formfield">
<cnsl-label>{{ 'IDP.CLIENTSECRET' | translate }}</cnsl-label>
<input cnslInput formControlName="clientSecret" />
Expand Down Expand Up @@ -85,7 +90,7 @@ <h2>{{ 'IDP.OPTIONAL' | translate }}</h2>
</mat-select>
</cnsl-form-field>

<cnsl-form-field class="formfield">
<cnsl-form-field class="formfield" *ngIf="tenantType?.value === AzureTenantIDType">
<cnsl-label>{{ 'IDP.AZUREADTENANTID' | translate }}</cnsl-label>
<input cnslInput formControlName="tenantId" />
</cnsl-form-field>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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) => {
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,14 @@ <h1>{{ 'IDP.CREATE.GITHUBES.TITLE' | translate }}</h1>
<input cnslInput formControlName="clientId" />
</cnsl-form-field>

<mat-checkbox *ngIf="provider" [(ngModel)]="updateClientSecret" [ngModelOptions]="{ standalone: true }">{{
'IDP.UPDATECLIENTSECRET' | translate
}}</mat-checkbox>
<mat-checkbox
class="update-secret-checkbox"
*ngIf="provider"
[(ngModel)]="updateClientSecret"
[ngModelOptions]="{ standalone: true }"
>{{ 'IDP.UPDATECLIENTSECRET' | translate }}</mat-checkbox
>

<cnsl-form-field *ngIf="!provider || (provider && updateClientSecret)" class="formfield">
<cnsl-label>{{ 'IDP.CLIENTSECRET' | translate }}</cnsl-label>
<input cnslInput formControlName="clientSecret" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,14 @@ <h1>{{ 'IDP.CREATE.GITHUB.TITLE' | translate }}</h1>
<input cnslInput formControlName="clientId" />
</cnsl-form-field>

<mat-checkbox *ngIf="provider" [(ngModel)]="updateClientSecret" [ngModelOptions]="{ standalone: true }">{{
'IDP.UPDATECLIENTSECRET' | translate
}}</mat-checkbox>
<mat-checkbox
class="update-secret-checkbox"
*ngIf="provider"
[(ngModel)]="updateClientSecret"
[ngModelOptions]="{ standalone: true }"
>{{ 'IDP.UPDATECLIENTSECRET' | translate }}</mat-checkbox
>

<cnsl-form-field *ngIf="!provider || (provider && updateClientSecret)" class="formfield">
<cnsl-label>{{ 'IDP.CLIENTSECRET' | translate }}</cnsl-label>
<input cnslInput formControlName="clientSecret" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,14 @@ <h1>{{ 'IDP.CREATE.GITLABSELFHOSTED.TITLE' | translate }}</h1>
<input cnslInput formControlName="clientId" />
</cnsl-form-field>

<mat-checkbox *ngIf="provider" [(ngModel)]="updateClientSecret" [ngModelOptions]="{ standalone: true }">{{
'IDP.UPDATECLIENTSECRET' | translate
}}</mat-checkbox>
<mat-checkbox
class="update-secret-checkbox"
*ngIf="provider"
[(ngModel)]="updateClientSecret"
[ngModelOptions]="{ standalone: true }"
>{{ 'IDP.UPDATECLIENTSECRET' | translate }}</mat-checkbox
>

<cnsl-form-field *ngIf="!provider || (provider && updateClientSecret)" class="formfield">
<cnsl-label>{{ 'IDP.CLIENTSECRET' | translate }}</cnsl-label>
<input cnslInput formControlName="clientSecret" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,14 @@ <h1>{{ 'IDP.CREATE.GITLAB.TITLE' | translate }}</h1>
<input cnslInput formControlName="clientId" />
</cnsl-form-field>

<mat-checkbox *ngIf="provider" [(ngModel)]="updateClientSecret" [ngModelOptions]="{ standalone: true }">{{
'IDP.UPDATECLIENTSECRET' | translate
}}</mat-checkbox>
<mat-checkbox
class="update-secret-checkbox"
*ngIf="provider"
[(ngModel)]="updateClientSecret"
[ngModelOptions]="{ standalone: true }"
>{{ 'IDP.UPDATECLIENTSECRET' | translate }}</mat-checkbox
>

<cnsl-form-field *ngIf="!provider || (provider && updateClientSecret)" class="formfield">
<cnsl-label>{{ 'IDP.CLIENTSECRET' | translate }}</cnsl-label>
<input cnslInput formControlName="clientSecret" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,13 @@ <h1>{{ 'IDP.CREATE.GOOGLE.TITLE' | translate }}</h1>
<input cnslInput formControlName="clientId" />
</cnsl-form-field>

<mat-checkbox *ngIf="provider" [(ngModel)]="updateClientSecret" [ngModelOptions]="{ standalone: true }">{{
'IDP.UPDATECLIENTSECRET' | translate
}}</mat-checkbox>
<mat-checkbox
class="update-secret-checkbox"
*ngIf="provider"
[(ngModel)]="updateClientSecret"
[ngModelOptions]="{ standalone: true }"
>{{ 'IDP.UPDATECLIENTSECRET' | translate }}</mat-checkbox
>
<cnsl-form-field *ngIf="!provider || (provider && updateClientSecret)" class="formfield">
<cnsl-label>{{ 'IDP.CLIENTSECRET' | translate }}</cnsl-label>
<input cnslInput formControlName="clientSecret" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,13 @@ <h2 class="subheader">{{ 'IDP.LDAPCONNECTION' | translate }}</h2>
<input cnslInput formControlName="bindDn" />
</cnsl-form-field>

<mat-checkbox *ngIf="provider" [(ngModel)]="updateBindPassword" [ngModelOptions]="{ standalone: true }">{{
'IDP.UPDATEBINDPASSWORD' | translate
}}</mat-checkbox>
<mat-checkbox
class="update-secret-checkbox"
*ngIf="provider"
[(ngModel)]="updateBindPassword"
[ngModelOptions]="{ standalone: true }"
>{{ 'IDP.UPDATEBINDPASSWORD' | translate }}</mat-checkbox
>
<cnsl-form-field *ngIf="!provider || (provider && updateBindPassword)" class="formfield">
<cnsl-label>{{ 'IDP.BINDPASSWORD' | translate }}</cnsl-label>
<input cnslInput formControlName="bindPassword" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,40 +13,45 @@ <h1>{{ 'IDP.CREATE.OAUTH.TITLE' | translate }}</h1>
<p class="identity-provider-desc cnsl-secondary-text">{{ 'IDP.CREATE.OAUTH.DESCRIPTION' | translate }}</p>

<form [formGroup]="form" (ngSubmit)="submitForm()">
<cnsl-form-field class="formfield">
<cnsl-label>{{ 'IDP.NAME' | translate }}</cnsl-label>
<input cnslInput formControlName="name" />
</cnsl-form-field>
<div class="identity-provider-content">
<cnsl-form-field class="formfield">
<cnsl-label>{{ 'IDP.NAME' | translate }}</cnsl-label>
<input cnslInput formControlName="name" />
</cnsl-form-field>

<cnsl-form-field class="formfield">
<cnsl-label>{{ 'IDP.AUTHORIZATIONENDPOINT' | translate }}</cnsl-label>
<input cnslInput formControlName="authorizationEndpoint" />
</cnsl-form-field>
<cnsl-form-field class="formfield">
<cnsl-label>{{ 'IDP.AUTHORIZATIONENDPOINT' | translate }}</cnsl-label>
<input cnslInput formControlName="authorizationEndpoint" />
</cnsl-form-field>

<cnsl-form-field class="formfield">
<cnsl-label>{{ 'IDP.TOKENENDPOINT' | translate }}</cnsl-label>
<input cnslInput formControlName="tokenEndpoint" />
</cnsl-form-field>
<cnsl-form-field class="formfield">
<cnsl-label>{{ 'IDP.TOKENENDPOINT' | translate }}</cnsl-label>
<input cnslInput formControlName="tokenEndpoint" />
</cnsl-form-field>

<cnsl-form-field class="formfield">
<cnsl-label>{{ 'IDP.USERENDPOINT' | translate }}</cnsl-label>
<input cnslInput formControlName="userEndpoint" />
</cnsl-form-field>
<cnsl-form-field class="formfield">
<cnsl-label>{{ 'IDP.USERENDPOINT' | translate }}</cnsl-label>
<input cnslInput formControlName="userEndpoint" />
</cnsl-form-field>

<cnsl-form-field class="formfield">
<cnsl-label>{{ 'IDP.IDATTRIBUTE' | translate }}</cnsl-label>
<input cnslInput formControlName="idAttribute" />
</cnsl-form-field>
<cnsl-form-field class="formfield">
<cnsl-label>{{ 'IDP.IDATTRIBUTE' | translate }}</cnsl-label>
<input cnslInput formControlName="idAttribute" />
</cnsl-form-field>

<div class="identity-provider-content">
<cnsl-form-field class="formfield">
<cnsl-label>{{ 'IDP.CLIENTID' | translate }}</cnsl-label>
<input cnslInput formControlName="clientId" />
</cnsl-form-field>

<mat-checkbox *ngIf="provider" [(ngModel)]="updateClientSecret" [ngModelOptions]="{ standalone: true }">{{
'IDP.UPDATECLIENTSECRET' | translate
}}</mat-checkbox>
<mat-checkbox
class="update-secret-checkbox"
*ngIf="provider"
[(ngModel)]="updateClientSecret"
[ngModelOptions]="{ standalone: true }"
>{{ 'IDP.UPDATECLIENTSECRET' | translate }}</mat-checkbox
>

<cnsl-form-field *ngIf="!provider || (provider && updateClientSecret)" class="formfield">
<cnsl-label>{{ 'IDP.CLIENTSECRET' | translate }}</cnsl-label>
<input cnslInput formControlName="clientSecret" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions console/src/app/modules/providers/providers.scss
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
}
}

.update-secret-checkbox {
margin: 0.5rem 0 0 0;
}

.formfield {
display: block;
max-width: 400px;
Expand Down
4 changes: 4 additions & 0 deletions console/src/app/services/admin.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1047,6 +1047,10 @@ export class AdminService {
return this.grpcService.admin.getProviderByID(req, null).then((resp) => resp.toObject());
}

public getProviderID(req: GetProviderByIDRequest): Promise<GetProviderByIDResponse> {
return this.grpcService.admin.getProviderByID(req, null);
}

public listIAMMembers(
limit: number,
offset: number,
Expand Down
4 changes: 4 additions & 0 deletions console/src/app/services/mgmt.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -987,6 +987,10 @@ export class ManagementService {
return this.grpcService.mgmt.getProviderByID(req, null).then((resp) => resp.toObject());
}

public getProviderID(req: GetProviderByIDRequest): Promise<GetProviderByIDResponse> {
return this.grpcService.mgmt.getProviderByID(req, null);
}

public addHumanUser(req: AddHumanUserRequest): Promise<AddHumanUserResponse.AsObject> {
return this.grpcService.mgmt.addHumanUser(req, null).then((resp) => resp.toObject());
}
Expand Down
1 change: 1 addition & 0 deletions console/src/assets/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -1699,6 +1699,7 @@
"2": "inaktiv"
},
"AZUREADTENANTTYPES": {
"3": "Tenant ID",
"0": "Common",
"1": "Organizations",
"2": "Consumers"
Expand Down
1 change: 1 addition & 0 deletions console/src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1699,6 +1699,7 @@
"2": "inactive"
},
"AZUREADTENANTTYPES": {
"3": "Tenant ID",
"0": "Common",
"1": "Organizations",
"2": "Consumers"
Expand Down
7 changes: 4 additions & 3 deletions console/src/assets/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions console/src/assets/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -1703,6 +1703,7 @@
"2": "inactif"
},
"AZUREADTENANTTYPES": {
"3": "Tenant ID",
"0": "Common",
"1": "Organizations",
"2": "Consumers"
Expand Down

1 comment on commit e79e280

@vercel
Copy link

@vercel vercel bot commented on e79e280 Apr 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

docs – ./

docs-zitadel.vercel.app
zitadel-docs.vercel.app
docs-git-main-zitadel.vercel.app

Please sign in to comment.