chore!: Introduce ZITADEL v3 (#9645)

This PR summarizes multiple changes specifically only available with
ZITADEL v3:

- feat: Web Keys management
(https://github.com/zitadel/zitadel/pull/9526)
- fix(cmd): ensure proper working of mirror
(https://github.com/zitadel/zitadel/pull/9509)
- feat(Authz): system user support for permission check v2
(https://github.com/zitadel/zitadel/pull/9640)
- chore(license): change from Apache to AGPL
(https://github.com/zitadel/zitadel/pull/9597)
- feat(console): list v2 sessions
(https://github.com/zitadel/zitadel/pull/9539)
- fix(console): add loginV2 feature flag
(https://github.com/zitadel/zitadel/pull/9682)
- fix(feature flags): allow reading "own" flags
(https://github.com/zitadel/zitadel/pull/9649)
- feat(console): add Actions V2 UI
(https://github.com/zitadel/zitadel/pull/9591)

BREAKING CHANGE
- feat(webkey): migrate to v2beta API
(https://github.com/zitadel/zitadel/pull/9445)
- chore!: remove CockroachDB Support
(https://github.com/zitadel/zitadel/pull/9444)
- feat(actions): migrate to v2beta API
(https://github.com/zitadel/zitadel/pull/9489)

---------

Co-authored-by: Livio Spring <[email protected]>
Co-authored-by: Stefan Benz <[email protected]>
Co-authored-by: Silvan <[email protected]>
Co-authored-by: Ramon <[email protected]>
Co-authored-by: Elio Bischof <[email protected]>
Co-authored-by: Kenta Yamaguchi <[email protected]>
Co-authored-by: Harsha Reddy <[email protected]>
Co-authored-by: Livio Spring <[email protected]>
Co-authored-by: Max Peintner <[email protected]>
Co-authored-by: Iraq <[email protected]>
Co-authored-by: Florian Forster <[email protected]>
Co-authored-by: Tim Möhlmann <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Max Peintner <[email protected]>
This commit is contained in:
Fabienne Bühler
2025-04-02 16:53:06 +02:00
committed by GitHub
co-authored by Livio Spring Stefan Benz Silvan Ramon Elio Bischof Kenta Yamaguchi Harsha Reddy Livio Spring Max Peintner Iraq Florian Forster Tim Möhlmann Copilot Max Peintner
parent d14a23ae7e
commit 07ce3b6905
559 changed files with 14578 additions and 7622 deletions
@@ -1,7 +1,6 @@
<div class="accounts-card">
<div class="accounts-card" *ngIf="user$ | async as user">
<cnsl-avatar
(click)="editUserProfile()"
*ngIf="user"
class="avatar"
[ngClass]="{ 'iam-user': iamuser }"
[forColor]="user.preferredLoginName"
@@ -16,8 +15,8 @@
<button (click)="editUserProfile()" mat-stroked-button>{{ 'USER.EDITACCOUNT' | translate }}</button>
<div class="l-accounts">
<mat-progress-bar *ngIf="loadingUsers" color="primary" mode="indeterminate"></mat-progress-bar>
<a class="row" *ngFor="let session of sessions" (click)="selectAccount(session.loginName)">
<mat-progress-bar *ngIf="(sessions$ | async) === null" color="primary" mode="indeterminate"></mat-progress-bar>
<a class="row" *ngFor="let session of sessions$ | async" (click)="selectAccount(session.loginName)">
<cnsl-avatar
*ngIf="session && session.displayName"
class="small-avatar"
@@ -31,7 +30,7 @@
<div class="col">
<span class="user-title">{{ session.displayName ? session.displayName : session.userName }} </span>
<span class="loginname">{{ session.loginName }}</span>
<span class="state inactive" *ngIf="session.authState === UserState.USER_STATE_INACTIVE">{{
<span class="state inactive" *ngIf="$any(session.authState) === UserState.USER_STATE_INACTIVE">{{
'USER.STATE.' + session.authState | translate
}}</span>
</div>
@@ -1,64 +1,156 @@
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { Router } from '@angular/router';
import { AuthConfig } from 'angular-oauth2-oidc';
import { Session, User, UserState } from 'src/app/proto/generated/zitadel/user_pb';
import { SessionState as V1SessionState, User, UserState } from 'src/app/proto/generated/zitadel/user_pb';
import { AuthenticationService } from 'src/app/services/authentication.service';
import { GrpcAuthService } from 'src/app/services/grpc-auth.service';
import { toSignal } from '@angular/core/rxjs-interop';
import { SessionService } from 'src/app/services/session.service';
import {
catchError,
defer,
from,
map,
mergeMap,
Observable,
of,
ReplaySubject,
shareReplay,
switchMap,
timeout,
TimeoutError,
toArray,
} from 'rxjs';
import { NewFeatureService } from 'src/app/services/new-feature.service';
import { ToastService } from 'src/app/services/toast.service';
import { SessionState as V2SessionState } from '@zitadel/proto/zitadel/user_pb';
import { filter, withLatestFrom } from 'rxjs/operators';
interface V1AndV2Session {
displayName: string;
avatarUrl: string;
loginName: string;
userName: string;
authState: V1SessionState | V2SessionState;
}
@Component({
selector: 'cnsl-accounts-card',
templateUrl: './accounts-card.component.html',
styleUrls: ['./accounts-card.component.scss'],
})
export class AccountsCardComponent implements OnInit {
@Input() public user?: User.AsObject;
@Input() public iamuser: boolean | null = false;
@Output() public closedCard: EventEmitter<void> = new EventEmitter();
public sessions: Session.AsObject[] = [];
public loadingUsers: boolean = false;
public UserState: any = UserState;
private labelpolicy = toSignal(this.userService.labelpolicy$, { initialValue: undefined });
constructor(
public authService: AuthenticationService,
private router: Router,
private userService: GrpcAuthService,
) {
this.userService
.listMyUserSessions()
.then((sessions) => {
this.sessions = sessions.resultList.filter((user) => user.loginName !== this.user?.preferredLoginName);
this.loadingUsers = false;
})
.catch(() => {
this.loadingUsers = false;
});
export class AccountsCardComponent {
@Input({ required: true })
public set user(user: User.AsObject) {
this.user$.next(user);
}
ngOnInit(): void {
this.loadingUsers = true;
@Input() public iamuser: boolean | null = false;
@Output() public closedCard = new EventEmitter<void>();
protected readonly user$ = new ReplaySubject<User.AsObject>(1);
protected readonly UserState = UserState;
private readonly labelpolicy = toSignal(this.userService.labelpolicy$, { initialValue: undefined });
protected readonly sessions$: Observable<V1AndV2Session[] | undefined>;
constructor(
protected readonly authService: AuthenticationService,
private readonly router: Router,
private readonly userService: GrpcAuthService,
private readonly sessionService: SessionService,
private readonly featureService: NewFeatureService,
private readonly toast: ToastService,
) {
this.sessions$ = this.getSessions().pipe(shareReplay({ refCount: true, bufferSize: 1 }));
}
private getUseLoginV2() {
return defer(() => this.featureService.getInstanceFeatures()).pipe(
map(({ loginV2 }) => loginV2?.required ?? false),
timeout(1000),
catchError((err) => {
if (!(err instanceof TimeoutError)) {
this.toast.showError(err);
}
return of(false);
}),
);
}
private getSessions(): Observable<V1AndV2Session[]> {
const useLoginV2$ = this.getUseLoginV2();
return useLoginV2$.pipe(
switchMap((useLoginV2) => {
if (useLoginV2) {
return this.getV2Sessions();
} else {
return this.getV1Sessions();
}
}),
catchError((err) => {
this.toast.showError(err);
return of([]);
}),
);
}
private getV1Sessions(): Observable<V1AndV2Session[]> {
return defer(() => this.userService.listMyUserSessions()).pipe(
mergeMap(({ resultList }) => from(resultList)),
withLatestFrom(this.user$),
filter(([{ loginName }, user]) => loginName !== user.preferredLoginName),
map(([s]) => ({
displayName: s.displayName,
avatarUrl: s.avatarUrl,
loginName: s.loginName,
authState: s.authState,
userName: s.userName,
})),
toArray(),
);
}
private getV2Sessions(): Observable<V1AndV2Session[]> {
return defer(() =>
this.sessionService.listSessions({
queries: [
{
query: {
case: 'userAgentQuery',
value: {},
},
},
],
}),
).pipe(
mergeMap(({ sessions }) => from(sessions)),
withLatestFrom(this.user$),
filter(([s, user]) => s.factors?.user?.loginName !== user.preferredLoginName),
map(([s]) => ({
displayName: s.factors?.user?.displayName ?? '',
avatarUrl: '',
loginName: s.factors?.user?.loginName ?? '',
authState: V2SessionState.ACTIVE,
userName: s.factors?.user?.loginName ?? '',
})),
toArray(),
);
}
public editUserProfile(): void {
this.router.navigate(['users/me']);
this.router.navigate(['users/me']).then();
this.closedCard.emit();
}
public closeCard(element: HTMLElement): void {
if (!element.classList.contains('dontcloseonclick')) {
this.closedCard.emit();
}
}
public selectAccount(loginHint: string): void {
const configWithPrompt: Partial<AuthConfig> = {
customQueryParams: {
login_hint: loginHint,
},
};
this.authService.authenticate(configWithPrompt);
this.authService.authenticate(configWithPrompt).then();
}
public selectNewAccount(): void {
@@ -67,7 +159,7 @@ export class AccountsCardComponent implements OnInit {
prompt: 'login',
} as any,
};
this.authService.authenticate(configWithPrompt);
this.authService.authenticate(configWithPrompt).then();
}
public logout(): void {