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
@@ -13,26 +13,20 @@
<p class="events-desc cnsl-secondary-text">{{ 'DESCRIPTIONS.SETTINGS.FEATURES.DESCRIPTION' | translate }}</p>
<ng-template cnslHasRole [hasRole]="['iam.restrictions.write']">
<button color="warn" (click)="resetSettings()" mat-stroked-button>
<button color="warn" (click)="resetFeatures()" mat-stroked-button>
{{ 'SETTING.FEATURES.RESET' | translate }}
</button>
</ng-template>
<cnsl-card *ngIf="toggleStates && featureData">
<cnsl-card *ngIf="toggleStates$ | async as toggleStates">
<div class="features">
<cnsl-feature-toggle
*ngFor="let key of toggleStateKeys"
[featureData]="featureData"
[toggleStates]="toggleStates"
*ngFor="let key of FEATURE_KEYS"
[toggleStateKey]="key"
(toggleChange)="validateAndSave()"
[toggleState]="toggleStates[key]"
(toggleChange)="saveFeatures(key, $event)"
></cnsl-feature-toggle>
<cnsl-login-v2-feature-toggle [toggleState]="toggleStates.loginV2" (toggleChanged)="saveFeatures('loginV2', $event)" />
</div>
</cnsl-card>
</div>
<ng-template #sourceLabel let-source="source" let-last="last">
<span class="state" *ngIf="source === Source.SOURCE_SYSTEM">
{{ 'SETTING.FEATURES.SOURCE.' + source | translate }}
</span>
</ng-template>
@@ -19,16 +19,14 @@ import {
GetInstanceFeaturesResponse,
SetInstanceFeaturesRequestSchema,
} from '@zitadel/proto/zitadel/feature/v2/instance_pb';
import { FeatureFlag, Source } from '@zitadel/proto/zitadel/feature/v2/feature_pb';
import { Source } from '@zitadel/proto/zitadel/feature/v2/feature_pb';
import { MessageInitShape } from '@bufbuild/protobuf';
import { firstValueFrom, Observable, ReplaySubject, shareReplay, switchMap } from 'rxjs';
import { filter, map, startWith } from 'rxjs/operators';
import { LoginV2FeatureToggleComponent } from '../feature-toggle/login-v2-feature-toggle/login-v2-feature-toggle.component';
export enum ToggleState {
ENABLED = 'ENABLED',
DISABLED = 'DISABLED',
}
// TODO: to add a new feature, add the key here and in the FEATURE_KEYS array
const FEATURE_KEYS: ToggleStateKeys[] = [
// to add a new feature, add the key here and in the FEATURE_KEYS array
const FEATURE_KEYS = [
'actions',
'consoleUseV2UserApi',
'debugOidcParentError',
@@ -36,23 +34,24 @@ const FEATURE_KEYS: ToggleStateKeys[] = [
'enableBackChannelLogout',
// 'improvedPerformance',
'loginDefaultOrg',
// 'loginV2',
'oidcLegacyIntrospection',
'oidcSingleV1SessionTermination',
'oidcTokenExchange',
'oidcTriggerIntrospectionProjections',
'permissionCheckV2',
'userSchema',
// 'webKey',
];
type FeatureState = { source: Source; state: ToggleState };
export type ToggleStateKeys = Exclude<keyof GetInstanceFeaturesResponse, 'details' | '$typeName' | '$unknown'>;
'webKey',
] as const;
export type ToggleState = { source: Source; enabled: boolean };
export type ToggleStates = {
[key in ToggleStateKeys]: FeatureState;
[key in (typeof FEATURE_KEYS)[number]]: ToggleState;
} & {
loginV2: ToggleState & { baseUri: string };
};
export type ToggleStateKeys = keyof ToggleStates;
@Component({
imports: [
CommonModule,
@@ -68,6 +67,7 @@ export type ToggleStates = {
MatTooltipModule,
HasRoleModule,
FeatureToggleComponent,
LoginV2FeatureToggleComponent,
],
standalone: true,
selector: 'cnsl-features',
@@ -75,16 +75,15 @@ export type ToggleStates = {
styleUrls: ['./features.component.scss'],
})
export class FeaturesComponent {
protected featureData: GetInstanceFeaturesResponse | undefined;
protected toggleStates: ToggleStates | undefined;
protected Source: any = Source;
protected ToggleState: any = ToggleState;
private readonly refresh$ = new ReplaySubject<true>(1);
protected readonly toggleStates$: Observable<ToggleStates>;
protected readonly Source = Source;
protected readonly FEATURE_KEYS = FEATURE_KEYS;
constructor(
private featureService: NewFeatureService,
private breadcrumbService: BreadcrumbService,
private toast: ToastService,
private readonly featureService: NewFeatureService,
private readonly breadcrumbService: BreadcrumbService,
private readonly toast: ToastService,
) {
const breadcrumbs = [
new Breadcrumb({
@@ -95,74 +94,84 @@ export class FeaturesComponent {
];
this.breadcrumbService.setBreadcrumb(breadcrumbs);
this.getFeatures();
this.toggleStates$ = this.getToggleStates().pipe(shareReplay({ refCount: true, bufferSize: 1 }));
}
public validateAndSave() {
const req: MessageInitShape<typeof SetInstanceFeaturesRequestSchema> = {
actions: this.toggleStates?.actions?.state === ToggleState.ENABLED,
consoleUseV2UserApi: this.toggleStates?.consoleUseV2UserApi?.state === ToggleState.ENABLED,
debugOidcParentError: this.toggleStates?.debugOidcParentError?.state === ToggleState.ENABLED,
disableUserTokenEvent: this.toggleStates?.disableUserTokenEvent?.state === ToggleState.ENABLED,
enableBackChannelLogout: this.toggleStates?.enableBackChannelLogout?.state === ToggleState.ENABLED,
loginDefaultOrg: this.toggleStates?.loginDefaultOrg?.state === ToggleState.ENABLED,
oidcLegacyIntrospection: this.toggleStates?.oidcLegacyIntrospection?.state === ToggleState.ENABLED,
oidcSingleV1SessionTermination: this.toggleStates?.oidcSingleV1SessionTermination?.state === ToggleState.ENABLED,
oidcTokenExchange: this.toggleStates?.oidcTokenExchange?.state === ToggleState.ENABLED,
oidcTriggerIntrospectionProjections:
this.toggleStates?.oidcTriggerIntrospectionProjections?.state === ToggleState.ENABLED,
permissionCheckV2: this.toggleStates?.permissionCheckV2?.state === ToggleState.ENABLED,
userSchema: this.toggleStates?.userSchema?.state === ToggleState.ENABLED,
// webKey: this.toggleStates?.webKey?.state === ToggleState.ENABLED,
};
this.featureService
.setInstanceFeatures(req)
.then(() => {
this.toast.showInfo('POLICY.TOAST.SET', true);
})
.catch((error) => {
this.toast.showError(error);
});
}
private getFeatures() {
this.featureService.getInstanceFeatures().then((instanceFeaturesResponse) => {
this.featureData = instanceFeaturesResponse;
this.toggleStates = this.createToggleStates(this.featureData);
});
private getToggleStates() {
return this.refresh$.pipe(
startWith(true),
switchMap(async () => {
try {
return await this.featureService.getInstanceFeatures();
} catch (error) {
this.toast.showError(error);
return undefined;
}
}),
filter(Boolean),
map((res) => this.createToggleStates(res)),
);
}
private createToggleStates(featureData: GetInstanceFeaturesResponse): ToggleStates {
const toggleStates: Partial<ToggleStates> = {};
FEATURE_KEYS.forEach((key) => {
// TODO: Fix this type cast as not all keys are present as FeatureFlag
const feature = featureData[key] as unknown as FeatureFlag;
toggleStates[key] = {
source: feature?.source || Source.SYSTEM,
state: !!feature?.enabled ? ToggleState.ENABLED : ToggleState.DISABLED,
};
});
return toggleStates as ToggleStates;
return FEATURE_KEYS.reduce(
(acc, key) => {
const feature = featureData[key];
acc[key] = {
source: feature?.source ?? Source.SYSTEM,
enabled: !!feature?.enabled,
};
return acc;
},
{
// to add special feature flags they have to be mapped here
loginV2: {
source: featureData.loginV2?.source ?? Source.SYSTEM,
enabled: !!featureData.loginV2?.required,
baseUri: featureData.loginV2?.baseUri ?? '',
},
} as ToggleStates,
);
}
public resetSettings(): void {
this.featureService
.resetInstanceFeatures()
.then(() => {
this.toast.showInfo('POLICY.TOAST.RESETSUCCESS', true);
setTimeout(() => {
this.getFeatures();
}, 1000);
})
.catch((error) => {
this.toast.showError(error);
});
public async saveFeatures<TKey extends ToggleStateKeys, TValue extends ToggleStates[TKey]>(key: TKey, value: TValue) {
const toggleStates = { ...(await firstValueFrom(this.toggleStates$)), [key]: value };
const req = FEATURE_KEYS.reduce<MessageInitShape<typeof SetInstanceFeaturesRequestSchema>>((acc, key) => {
acc[key] = toggleStates[key].enabled;
return acc;
}, {});
// to save special flags they have to be handled here
req.loginV2 = {
required: toggleStates.loginV2.enabled,
baseUri: toggleStates.loginV2.baseUri,
};
try {
await this.featureService.setInstanceFeatures(req);
// needed because of eventual consistency
await new Promise((res) => setTimeout(res, 1000));
this.refresh$.next(true);
this.toast.showInfo('POLICY.TOAST.SET', true);
} catch (error) {
this.toast.showError(error);
}
}
public get toggleStateKeys() {
return Object.keys(this.toggleStates ?? {});
public async resetFeatures() {
try {
await this.featureService.resetInstanceFeatures();
// needed because of eventual consistency
await new Promise((res) => setTimeout(res, 1000));
this.refresh$.next(true);
this.toast.showInfo('POLICY.TOAST.RESETSUCCESS', true);
} catch (error) {
this.toast.showError(error);
}
}
}