mirror of
https://github.com/andwati/zitadel.git
synced 2026-10-18 05:52:51 +00:00
* show app redirect issues, action layout * refactor pagination * tos, privacy * new paginator everywhere * layout width and table optim * lint pt1 * lint config, ts * stylelint * chore(deps-dev): bump @angular/cli from 11.2.7 to 11.2.8 in /console (#1566) * fix: remove app name check on ChangeAPIApplication (#1561) * fix: remove app name check on ChangeAPIApplication * fix APIConfigInvalid message * chore(workflow): ignore tags for docs and codecov flows (#1564) * chore(deps-dev): bump @angular/cli from 11.2.7 to 11.2.8 in /console Bumps [@angular/cli](https://github.com/angular/angular-cli) from 11.2.7 to 11.2.8. - [Release notes](https://github.com/angular/angular-cli/releases) - [Commits](https://github.com/angular/angular-cli/compare/v11.2.7...v11.2.8) Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: Livio Amstutz <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps-dev): bump jasmine-spec-reporter from 6.0.0 to 7.0.0 in /console (#1573) * fix: remove app name check on ChangeAPIApplication (#1561) * fix: remove app name check on ChangeAPIApplication * fix APIConfigInvalid message * chore(workflow): ignore tags for docs and codecov flows (#1564) * chore(deps-dev): bump jasmine-spec-reporter in /console Bumps [jasmine-spec-reporter](https://github.com/bcaudan/jasmine-spec-reporter) from 6.0.0 to 7.0.0. - [Release notes](https://github.com/bcaudan/jasmine-spec-reporter/releases) - [Changelog](https://github.com/bcaudan/jasmine-spec-reporter/blob/master/CHANGELOG.md) - [Commits](https://github.com/bcaudan/jasmine-spec-reporter/compare/v6.0.0...v7.0.0) Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: Livio Amstutz <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps-dev): bump @angular-devkit/build-angular from 0.1102.7 to 0.1102.8 in /console (#1574) * fix: remove app name check on ChangeAPIApplication (#1561) * fix: remove app name check on ChangeAPIApplication * fix APIConfigInvalid message * chore(workflow): ignore tags for docs and codecov flows (#1564) * chore(deps-dev): bump @angular-devkit/build-angular in /console Bumps [@angular-devkit/build-angular](https://github.com/angular/angular-cli) from 0.1102.7 to 0.1102.8. - [Release notes](https://github.com/angular/angular-cli/releases) - [Commits](https://github.com/angular/angular-cli/commits) Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: Livio Amstutz <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Max Peintner <[email protected]> * chore(deps): bump @types/file-saver from 2.0.1 to 2.0.2 in /console (#1576) * fix: remove app name check on ChangeAPIApplication (#1561) * fix: remove app name check on ChangeAPIApplication * fix APIConfigInvalid message * chore(workflow): ignore tags for docs and codecov flows (#1564) * chore(deps): bump @types/file-saver from 2.0.1 to 2.0.2 in /console Bumps [@types/file-saver](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/file-saver) from 2.0.1 to 2.0.2. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/file-saver) Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: Livio Amstutz <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps-dev): bump @angular/language-service from 11.2.8 to 11.2.9 in /console (#1567) * fix: remove app name check on ChangeAPIApplication (#1561) * fix: remove app name check on ChangeAPIApplication * fix APIConfigInvalid message * chore(workflow): ignore tags for docs and codecov flows (#1564) * chore(deps-dev): bump @angular/language-service in /console Bumps [@angular/language-service](https://github.com/angular/angular/tree/HEAD/packages/language-service) from 11.2.8 to 11.2.9. - [Release notes](https://github.com/angular/angular/releases) - [Changelog](https://github.com/angular/angular/blob/master/CHANGELOG.md) - [Commits](https://github.com/angular/angular/commits/11.2.9/packages/language-service) Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: Livio Amstutz <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * update protobuf, libphone * chore(deps): bump rxjs from 6.6.3 to 6.6.7 in /console (#1488) Bumps [rxjs](https://github.com/reactivex/rxjs) from 6.6.3 to 6.6.7. - [Release notes](https://github.com/reactivex/rxjs/releases) - [Changelog](https://github.com/ReactiveX/rxjs/blob/6.6.7/CHANGELOG.md) - [Commits](https://github.com/reactivex/rxjs/compare/6.6.3...6.6.7) Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps-dev): bump @types/jasmine from 3.6.3 to 3.6.9 in /console (#1485) Bumps [@types/jasmine](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/jasmine) from 3.6.3 to 3.6.9. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/jasmine) Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Max Peintner <[email protected]> * chore(deps-dev): bump jasmine-core from 3.6.0 to 3.7.1 in /console (#1445) Bumps [jasmine-core](https://github.com/jasmine/jasmine) from 3.6.0 to 3.7.1. - [Release notes](https://github.com/jasmine/jasmine/releases) - [Changelog](https://github.com/jasmine/jasmine/blob/main/RELEASE.md) - [Commits](https://github.com/jasmine/jasmine/compare/v3.6.0...v3.7.1) Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Max Peintner <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Livio Amstutz <[email protected]>
261 lines
9.7 KiB
TypeScript
261 lines
9.7 KiB
TypeScript
import { COMMA, ENTER, SPACE } from '@angular/cdk/keycodes';
|
|
import { Location } from '@angular/common';
|
|
import { Component, Injector, OnDestroy, OnInit, Type } from '@angular/core';
|
|
import { AbstractControl, FormControl, FormGroup, Validators } from '@angular/forms';
|
|
import { MatChipInputEvent } from '@angular/material/chips';
|
|
import { ActivatedRoute, Params } from '@angular/router';
|
|
import { Subscription } from 'rxjs';
|
|
import { switchMap, take } from 'rxjs/operators';
|
|
import { UpdateIDPOIDCConfigRequest, UpdateIDPRequest } from 'src/app/proto/generated/zitadel/admin_pb';
|
|
import { IDPStylingType, OIDCMappingField } from 'src/app/proto/generated/zitadel/idp_pb';
|
|
import { UpdateOrgIDPOIDCConfigRequest, UpdateOrgIDPRequest } from 'src/app/proto/generated/zitadel/management_pb';
|
|
import { AdminService } from 'src/app/services/admin.service';
|
|
import { ManagementService } from 'src/app/services/mgmt.service';
|
|
import { ToastService } from 'src/app/services/toast.service';
|
|
|
|
import { PolicyComponentServiceType } from '../policies/policy-component-types.enum';
|
|
|
|
@Component({
|
|
selector: 'app-idp',
|
|
templateUrl: './idp.component.html',
|
|
styleUrls: ['./idp.component.scss'],
|
|
})
|
|
export class IdpComponent implements OnInit, OnDestroy {
|
|
public mappingFields: OIDCMappingField[] = [];
|
|
public styleFields: IDPStylingType[] = [];
|
|
|
|
public showIdSecretSection: boolean = false;
|
|
public serviceType: PolicyComponentServiceType = PolicyComponentServiceType.MGMT;
|
|
private service!: ManagementService | AdminService;
|
|
public readonly separatorKeysCodes: number[] = [ENTER, COMMA, SPACE];
|
|
|
|
private subscription?: Subscription;
|
|
public projectId: string = '';
|
|
|
|
public idpForm!: FormGroup;
|
|
public oidcConfigForm!: FormGroup;
|
|
|
|
constructor(
|
|
private toast: ToastService,
|
|
private injector: Injector,
|
|
private route: ActivatedRoute,
|
|
private _location: Location,
|
|
) {
|
|
this.idpForm = new FormGroup({
|
|
id: new FormControl({ disabled: true, value: '' }, [Validators.required]),
|
|
name: new FormControl('', [Validators.required]),
|
|
stylingType: new FormControl('', [Validators.required]),
|
|
});
|
|
|
|
this.oidcConfigForm = new FormGroup({
|
|
clientId: new FormControl('', [Validators.required]),
|
|
clientSecret: new FormControl(''),
|
|
issuer: new FormControl('', [Validators.required]),
|
|
scopesList: new FormControl([], []),
|
|
idpDisplayNameMapping: new FormControl(0),
|
|
usernameMapping: new FormControl(0),
|
|
});
|
|
|
|
this.route.data.pipe(switchMap(data => {
|
|
this.serviceType = data.serviceType;
|
|
switch (this.serviceType) {
|
|
case PolicyComponentServiceType.MGMT:
|
|
this.service = this.injector.get(ManagementService as Type<ManagementService>);
|
|
|
|
break;
|
|
case PolicyComponentServiceType.ADMIN:
|
|
this.service = this.injector.get(AdminService as Type<AdminService>);
|
|
|
|
break;
|
|
}
|
|
|
|
this.mappingFields = [
|
|
OIDCMappingField.OIDC_MAPPING_FIELD_PREFERRED_USERNAME,
|
|
OIDCMappingField.OIDC_MAPPING_FIELD_EMAIL];
|
|
this.styleFields = [
|
|
IDPStylingType.STYLING_TYPE_UNSPECIFIED,
|
|
IDPStylingType.STYLING_TYPE_GOOGLE];
|
|
|
|
return this.route.params.pipe(take(1));
|
|
})).subscribe((params) => {
|
|
const { id } = params;
|
|
if (id) {
|
|
if (this.serviceType === PolicyComponentServiceType.MGMT) {
|
|
(this.service as ManagementService).getOrgIDPByID(id).then(resp => {
|
|
if (resp.idp) {
|
|
const idpObject = resp.idp;
|
|
this.idpForm.patchValue(idpObject);
|
|
if (idpObject.oidcConfig) {
|
|
this.oidcConfigForm.patchValue(idpObject.oidcConfig);
|
|
}
|
|
}
|
|
});
|
|
} else if (this.serviceType === PolicyComponentServiceType.ADMIN) {
|
|
(this.service as AdminService).getIDPByID(id).then(resp => {
|
|
if (resp.idp) {
|
|
const idpObject = resp.idp;
|
|
this.idpForm.patchValue(idpObject);
|
|
if (idpObject.oidcConfig) {
|
|
this.oidcConfigForm.patchValue(idpObject.oidcConfig);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
public ngOnInit(): void {
|
|
this.subscription = this.route.params.subscribe(params => this.getData(params));
|
|
}
|
|
|
|
public ngOnDestroy(): void {
|
|
this.subscription?.unsubscribe();
|
|
}
|
|
|
|
private getData({ projectid }: Params): void {
|
|
this.projectId = projectid;
|
|
}
|
|
|
|
public updateIdp(): void {
|
|
if (this.serviceType === PolicyComponentServiceType.MGMT) {
|
|
const req = new UpdateOrgIDPRequest();
|
|
|
|
req.setIdpId(this.id?.value);
|
|
req.setName(this.name?.value);
|
|
req.setStylingType(this.stylingType?.value);
|
|
|
|
(this.service as ManagementService).updateOrgIDP(req).then(() => {
|
|
this.toast.showInfo('IDP.TOAST.SAVED', true);
|
|
// this.router.navigate(['idp', ]);
|
|
}).catch(error => {
|
|
this.toast.showError(error);
|
|
});
|
|
} else if (this.serviceType === PolicyComponentServiceType.ADMIN) {
|
|
const req = new UpdateIDPRequest();
|
|
|
|
req.setIdpId(this.id?.value);
|
|
req.setName(this.name?.value);
|
|
req.setStylingType(this.stylingType?.value);
|
|
|
|
(this.service as AdminService).updateIDP(req).then(() => {
|
|
this.toast.showInfo('IDP.TOAST.SAVED', true);
|
|
// this.router.navigate(['idp', ]);
|
|
}).catch(error => {
|
|
this.toast.showError(error);
|
|
});
|
|
}
|
|
}
|
|
|
|
public updateOidcConfig(): void {
|
|
if (this.serviceType === PolicyComponentServiceType.MGMT) {
|
|
const req = new UpdateOrgIDPOIDCConfigRequest();
|
|
|
|
req.setIdpId(this.id?.value);
|
|
req.setClientId(this.clientId?.value);
|
|
req.setClientSecret(this.clientSecret?.value);
|
|
req.setIssuer(this.issuer?.value);
|
|
req.setScopesList(this.scopesList?.value);
|
|
req.setUsernameMapping(this.usernameMapping?.value);
|
|
req.setDisplayNameMapping(this.idpDisplayNameMapping?.value);
|
|
|
|
(this.service as ManagementService).updateOrgIDPOIDCConfig(req).then((oidcConfig) => {
|
|
this.toast.showInfo('IDP.TOAST.SAVED', true);
|
|
// this.router.navigate(['idp', ]);
|
|
}).catch(error => {
|
|
this.toast.showError(error);
|
|
});
|
|
} else if (this.serviceType === PolicyComponentServiceType.ADMIN) {
|
|
const req = new UpdateIDPOIDCConfigRequest();
|
|
|
|
req.setIdpId(this.id?.value);
|
|
req.setClientId(this.clientId?.value);
|
|
req.setClientSecret(this.clientSecret?.value);
|
|
req.setIssuer(this.issuer?.value);
|
|
req.setScopesList(this.scopesList?.value);
|
|
req.setUsernameMapping(this.usernameMapping?.value);
|
|
req.setDisplayNameMapping(this.idpDisplayNameMapping?.value);
|
|
|
|
(this.service as AdminService).updateIDPOIDCConfig(req).then((oidcConfig) => {
|
|
this.toast.showInfo('IDP.TOAST.SAVED', true);
|
|
// this.router.navigate(['idp', ]);
|
|
}).catch(error => {
|
|
this.toast.showError(error);
|
|
});
|
|
}
|
|
}
|
|
|
|
public close(): void {
|
|
this._location.back();
|
|
}
|
|
|
|
public addScope(event: MatChipInputEvent): void {
|
|
const input = event.input;
|
|
const value = event.value.trim();
|
|
|
|
if (value !== '') {
|
|
if (this.scopesList?.value) {
|
|
this.scopesList.value.push(value);
|
|
if (input) {
|
|
input.value = '';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public removeScope(uri: string): void {
|
|
if (this.scopesList?.value) {
|
|
const index = this.scopesList?.value.indexOf(uri);
|
|
|
|
if (index !== undefined && index >= 0) {
|
|
this.scopesList?.value.splice(index, 1);
|
|
}
|
|
}
|
|
}
|
|
|
|
public get backroutes(): string[] {
|
|
switch (this.serviceType) {
|
|
case PolicyComponentServiceType.MGMT:
|
|
return ['/org', 'policy', 'login'];
|
|
case PolicyComponentServiceType.ADMIN:
|
|
return ['/iam', 'policy', 'login'];
|
|
}
|
|
}
|
|
|
|
public get id(): AbstractControl | null {
|
|
return this.idpForm.get('id');
|
|
}
|
|
|
|
public get name(): AbstractControl | null {
|
|
return this.idpForm.get('name');
|
|
}
|
|
|
|
public get stylingType(): AbstractControl | null {
|
|
return this.idpForm.get('stylingType');
|
|
}
|
|
|
|
public get clientId(): AbstractControl | null {
|
|
return this.oidcConfigForm.get('clientId');
|
|
}
|
|
|
|
public get clientSecret(): AbstractControl | null {
|
|
return this.oidcConfigForm.get('clientSecret');
|
|
}
|
|
|
|
public get issuer(): AbstractControl | null {
|
|
return this.oidcConfigForm.get('issuer');
|
|
}
|
|
|
|
public get scopesList(): AbstractControl | null {
|
|
return this.oidcConfigForm.get('scopesList');
|
|
}
|
|
|
|
public get idpDisplayNameMapping(): AbstractControl | null {
|
|
return this.oidcConfigForm.get('idpDisplayNameMapping');
|
|
}
|
|
|
|
public get usernameMapping(): AbstractControl | null {
|
|
return this.oidcConfigForm.get('usernameMapping');
|
|
}
|
|
}
|