mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-25 22:08:46 +00:00
feat(console): guide users when configuring IDPs (#7572)
* feat(console): show external idp remote config * reuse copy-row * finish google and saml sp * finish apps * add next steps modal * rollout * activate * fix saml urls * fix saml provider * complete providers * translate * update google docs * update entra id oidc docs * update entra id saml docs * update github docs * update gitlab docs * update apple docs * update okta oidc docs * update okta saml docs * update keycloak docs * update mocksaml * cleanup * lint * lint * fix overriden classes * encapsulate styles * fix icon classes --------- Co-authored-by: peintnermax <[email protected]>
This commit is contained in:
co-authored by
peintnermax
parent
84644214d7
commit
d26391a642
@@ -0,0 +1,77 @@
|
||||
<div class="cnsl-provider-next">
|
||||
<cnsl-card
|
||||
[title]="'DESCRIPTIONS.SETTINGS.IDPS.NEXT' | translate"
|
||||
[expanded]="!!expanded"
|
||||
*ngIf="configureProvider || autofillLink || activateLink"
|
||||
>
|
||||
<cnsl-info-section *ngIf="activateLink">
|
||||
<div class="title-row">
|
||||
<div class="left">
|
||||
<h2 class="title">{{ 'DESCRIPTIONS.SETTINGS.IDPS.ACTIVATE.TITLE' | translate }}</h2>
|
||||
<div>
|
||||
<a
|
||||
mat-icon-button
|
||||
*ngIf="activateLink"
|
||||
card-actions
|
||||
mat-icon-button
|
||||
[href]="activateLink"
|
||||
rel="noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
<mat-icon class="next-icon">info_outline</mat-icon>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="right">
|
||||
<button color="primary" mat-raised-button class="continue-button" (click)="activate.emit()">
|
||||
{{ 'ACTIONS.ACTIVATE' | translate }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<p class="cnsl-secondary-text description">{{ 'DESCRIPTIONS.SETTINGS.IDPS.ACTIVATE.DESCRIPTION' | translate }}</p>
|
||||
</cnsl-info-section>
|
||||
<div class="section" *ngIf="configureProvider">
|
||||
<div class="title-row">
|
||||
<div class="left">
|
||||
<h2 class="title">{{ configureTitle }}</h2>
|
||||
<a
|
||||
mat-icon-button
|
||||
*ngIf="configureLink"
|
||||
card-actions
|
||||
mat-icon-button
|
||||
[href]="configureLink"
|
||||
rel="noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
<mat-icon class="next-icon">info_outline</mat-icon>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<p class="cnsl-secondary-text description">{{ configureDescription }}</p>
|
||||
<cnsl-copy-row *ngFor="let row of copyUrls" [label]="row.label" [value]="row.url" labelMinWidth="200px">
|
||||
<a *ngIf="row.downloadable" class="download-button" mat-stroked-button [href]="row.url" download>{{
|
||||
'ACTIONS.DOWNLOAD' | translate
|
||||
}}</a>
|
||||
</cnsl-copy-row>
|
||||
</div>
|
||||
<div class="section" *ngIf="autofillLink">
|
||||
<div class="title-row">
|
||||
<div class="left">
|
||||
<h2 class="title">{{ 'DESCRIPTIONS.SETTINGS.IDPS.AUTOFILL.TITLE' | translate }}</h2>
|
||||
<a
|
||||
mat-icon-button
|
||||
*ngIf="autofillLink"
|
||||
card-actions
|
||||
mat-icon-button
|
||||
[href]="autofillLink"
|
||||
rel="noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
<mat-icon class="next-icon">info_outline</mat-icon>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<p class="cnsl-secondary-text description">{{ 'DESCRIPTIONS.SETTINGS.IDPS.AUTOFILL.DESCRIPTION' | translate }}</p>
|
||||
</div>
|
||||
</cnsl-card>
|
||||
</div>
|
||||
@@ -0,0 +1,69 @@
|
||||
.cnsl-provider-next {
|
||||
.section {
|
||||
background-color: #8795a110;
|
||||
border: 1px solid #8795a160;
|
||||
border-radius: 4px;
|
||||
padding: 0.25rem 1rem;
|
||||
margin: 0.25rem 0rem;
|
||||
.box {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
.right {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.title-row {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
|
||||
.left {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.right {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.title {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.next-icon {
|
||||
font-size: 1.2rem;
|
||||
height: 1.2rem;
|
||||
width: 1.2rem;
|
||||
}
|
||||
}
|
||||
|
||||
.description {
|
||||
margin-block-start: 0;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.download-button {
|
||||
margin-left: 1rem;
|
||||
}
|
||||
}
|
||||
|
||||
@mixin provider-next-theme($theme) {
|
||||
$foreground: map-get($theme, foreground);
|
||||
$button-text-color: map-get($foreground, text);
|
||||
$button-disabled-text-color: map-get($foreground, disabled-button);
|
||||
.cnsl-provider-next {
|
||||
.section {
|
||||
color: $button-text-color;
|
||||
|
||||
&[disabled] {
|
||||
color: $button-disabled-text-color;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
import { Component, EventEmitter, Input, Output } from '@angular/core';
|
||||
|
||||
export interface CopyUrl {
|
||||
label: string;
|
||||
url: string;
|
||||
downloadable?: boolean;
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'cnsl-provider-next',
|
||||
templateUrl: './provider-next.component.html',
|
||||
styleUrls: ['./provider-next.component.scss'],
|
||||
})
|
||||
export class ProviderNextComponent {
|
||||
@Input() copyUrls?: CopyUrl[] | null;
|
||||
@Input() autofillLink?: string | null;
|
||||
@Input() activateLink?: string | null;
|
||||
@Input() configureProvider?: boolean | null;
|
||||
@Input() configureTitle?: string;
|
||||
@Input() configureDescription?: string;
|
||||
@Input() configureLink?: string;
|
||||
@Input() expanded?: boolean;
|
||||
@Output() activate = new EventEmitter<void>();
|
||||
|
||||
constructor() {}
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
import { Injectable, Injector, Type } from '@angular/core';
|
||||
import { BehaviorSubject, combineLatestWith, from, Observable, of, shareReplay, switchMap, take } from 'rxjs';
|
||||
import { filter, map, tap } from 'rxjs/operators';
|
||||
import { EnvironmentService } from '../../../services/environment.service';
|
||||
import { CopyUrl } from './provider-next.component';
|
||||
import { ManagementService } from '../../../services/mgmt.service';
|
||||
import { AdminService } from '../../../services/admin.service';
|
||||
import { IDPOwnerType } from '../../../proto/generated/zitadel/idp_pb';
|
||||
import { ToastService } from '../../../services/toast.service';
|
||||
import { Data, ParamMap } from '@angular/router';
|
||||
import { ActivateIdpService } from '../../../services/activate-idp.service';
|
||||
import { PolicyComponentServiceType } from '../../policies/policy-component-types.enum';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class ProviderNextService {
|
||||
constructor(
|
||||
private env: EnvironmentService,
|
||||
private toast: ToastService,
|
||||
private addIdpSvc: ActivateIdpService,
|
||||
private injector: Injector,
|
||||
) {}
|
||||
|
||||
service(routeData: Observable<Data>): Observable<ManagementService | AdminService> {
|
||||
return routeData.pipe(
|
||||
map((data) => {
|
||||
switch (data['serviceType']) {
|
||||
case PolicyComponentServiceType.MGMT:
|
||||
return this.injector.get(ManagementService as Type<ManagementService>);
|
||||
case PolicyComponentServiceType.ADMIN:
|
||||
return this.injector.get(AdminService as Type<AdminService>);
|
||||
default:
|
||||
throw new Error('Unknown Service Type');
|
||||
}
|
||||
}),
|
||||
shareReplay(1),
|
||||
);
|
||||
}
|
||||
|
||||
id(paramMap: Observable<ParamMap>, justCreated$: Observable<string>): Observable<string | null> {
|
||||
return paramMap.pipe(
|
||||
// The ID observable should also emit when the IDP was just created
|
||||
combineLatestWith(justCreated$),
|
||||
map(([params, created]) => (created ? created : params.get('id'))),
|
||||
shareReplay(1),
|
||||
);
|
||||
}
|
||||
|
||||
exists(id$: Observable<string | null>): Observable<boolean> {
|
||||
return id$.pipe(
|
||||
map((id) => !!id),
|
||||
shareReplay(1),
|
||||
);
|
||||
}
|
||||
autofillLink(id$: Observable<string | null>, link: string): Observable<string> {
|
||||
return id$.pipe(
|
||||
filter((id) => !!id),
|
||||
map(() => link),
|
||||
shareReplay(1),
|
||||
);
|
||||
}
|
||||
|
||||
activateLink(
|
||||
id$: Observable<string | null>,
|
||||
justActivated$: Observable<boolean>,
|
||||
link: string,
|
||||
service$: Observable<ManagementService | AdminService>,
|
||||
): Observable<string> {
|
||||
return id$.pipe(
|
||||
combineLatestWith(justActivated$, service$),
|
||||
// Because we also want to emit when the IDP is not active, we return an empty string if the IDP does not exist
|
||||
switchMap(([id, activated, service]) =>
|
||||
(!id || activated
|
||||
? of(false)
|
||||
: from(service.getLoginPolicy()).pipe(map((policy) => !policy.policy?.idpsList.find((idp) => idp.idpId === id)))
|
||||
).pipe(map((show) => (!show ? '' : link))),
|
||||
),
|
||||
shareReplay(1),
|
||||
);
|
||||
}
|
||||
|
||||
callbackUrls(): Observable<CopyUrl[]> {
|
||||
return this.env.env.pipe(
|
||||
map((env) => [
|
||||
{
|
||||
label: 'ZITADEL Callback URL',
|
||||
url: `${env.issuer}/ui/login/login/externalidp/callback`,
|
||||
},
|
||||
]),
|
||||
);
|
||||
}
|
||||
|
||||
expandWhatNow(
|
||||
id$: Observable<string | null>,
|
||||
activateLink$: Observable<string>,
|
||||
justCreated$: Observable<string>,
|
||||
): Observable<boolean> {
|
||||
return id$.pipe(
|
||||
combineLatestWith(activateLink$, justCreated$),
|
||||
map(([id, activateLink, created]) => !id || activateLink || created),
|
||||
map((expand) => !!expand),
|
||||
shareReplay(1),
|
||||
);
|
||||
}
|
||||
|
||||
activate(
|
||||
id$: Observable<string | null>,
|
||||
emitActivated$: BehaviorSubject<boolean>,
|
||||
service$: Observable<ManagementService | AdminService>,
|
||||
): void {
|
||||
id$
|
||||
.pipe(
|
||||
combineLatestWith(service$),
|
||||
take(1),
|
||||
switchMap(([id, service]) => {
|
||||
if (!id) {
|
||||
throw new Error('No ID');
|
||||
}
|
||||
return this.addIdpSvc.activateIdp(
|
||||
service,
|
||||
id,
|
||||
service instanceof AdminService ? IDPOwnerType.IDP_OWNER_TYPE_SYSTEM : IDPOwnerType.IDP_OWNER_TYPE_ORG,
|
||||
);
|
||||
}),
|
||||
)
|
||||
.subscribe({
|
||||
next: () => {
|
||||
this.toast.showInfo('POLICY.LOGIN_POLICY.PROVIDER_ADDED', true);
|
||||
emitActivated$.next(true);
|
||||
},
|
||||
error: (error) => this.toast.showError(error),
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user