diff --git a/console/.prettierrc b/console/.prettierrc index 4837ff3ca1..7a2a5d19e3 100644 --- a/console/.prettierrc +++ b/console/.prettierrc @@ -1,6 +1,5 @@ { "printWidth": 125, "singleQuote": true, - "trailingComma": "all", - "organizeImportsSkipDestructiveCodeActions": true + "trailingComma": "all" } diff --git a/console/src/app/guards/role.guard.ts b/console/src/app/guards/role.guard.ts index 24a9cf8da7..832a349961 100644 --- a/console/src/app/guards/role.guard.ts +++ b/console/src/app/guards/role.guard.ts @@ -1,7 +1,6 @@ import { Injectable } from '@angular/core'; import { ActivatedRouteSnapshot, CanActivate, RouterStateSnapshot } from '@angular/router'; import { Observable } from 'rxjs'; -import { filter, switchMap } from 'rxjs/operators'; import { GrpcAuthService } from '../services/grpc-auth.service'; diff --git a/console/src/app/modules/filter-events/filter-events.component.ts b/console/src/app/modules/filter-events/filter-events.component.ts index 1a6ad78c7c..381482bc50 100644 --- a/console/src/app/modules/filter-events/filter-events.component.ts +++ b/console/src/app/modules/filter-events/filter-events.component.ts @@ -1,8 +1,6 @@ import { ConnectedPosition, ConnectionPositionPair } from '@angular/cdk/overlay'; import { Component, EventEmitter, OnInit, Output } from '@angular/core'; import { AbstractControl, FormControl, FormGroup } from '@angular/forms'; -import { MatLegacyOptionSelectionChange } from '@angular/material/legacy-core'; -import { MatLegacySelectChange } from '@angular/material/legacy-select'; import { ActivatedRoute, Router } from '@angular/router'; import { Timestamp } from 'google-protobuf/google/protobuf/timestamp_pb'; import { take } from 'rxjs'; diff --git a/console/src/app/modules/footer/footer.component.ts b/console/src/app/modules/footer/footer.component.ts index eac84ec5a6..270128bdcf 100644 --- a/console/src/app/modules/footer/footer.component.ts +++ b/console/src/app/modules/footer/footer.component.ts @@ -1,5 +1,5 @@ -import { Component, Input } from '@angular/core'; -import { LabelPolicy, PrivacyPolicy } from 'src/app/proto/generated/zitadel/policy_pb'; +import { Component } from '@angular/core'; +import { PrivacyPolicy } from 'src/app/proto/generated/zitadel/policy_pb'; import { GrpcAuthService } from 'src/app/services/grpc-auth.service'; @Component({ diff --git a/console/src/app/modules/header/header.component.ts b/console/src/app/modules/header/header.component.ts index 282f43c6fd..25463e0c52 100644 --- a/console/src/app/modules/header/header.component.ts +++ b/console/src/app/modules/header/header.component.ts @@ -3,7 +3,6 @@ import { Component, ElementRef, EventEmitter, Input, OnDestroy, Output, ViewChil import { Router } from '@angular/router'; import { BehaviorSubject, Observable, of, Subject } from 'rxjs'; import { Org } from 'src/app/proto/generated/zitadel/org_pb'; -import { LabelPolicy } from 'src/app/proto/generated/zitadel/policy_pb'; import { User } from 'src/app/proto/generated/zitadel/user_pb'; import { AuthenticationService } from 'src/app/services/authentication.service'; import { BreadcrumbService, BreadcrumbType } from 'src/app/services/breadcrumb.service'; diff --git a/console/src/app/modules/metadata/metadata-dialog/metadata-dialog.component.ts b/console/src/app/modules/metadata/metadata-dialog/metadata-dialog.component.ts index 22bace3617..b6adf3c1e9 100644 --- a/console/src/app/modules/metadata/metadata-dialog/metadata-dialog.component.ts +++ b/console/src/app/modules/metadata/metadata-dialog/metadata-dialog.component.ts @@ -3,10 +3,8 @@ import { MatLegacyDialogRef as MatDialogRef, MAT_LEGACY_DIALOG_DATA as MAT_DIALOG_DATA, } from '@angular/material/legacy-dialog'; -import { Buffer } from 'buffer'; import { Timestamp } from 'google-protobuf/google/protobuf/timestamp_pb'; import { Metadata } from 'src/app/proto/generated/zitadel/metadata_pb'; -import { ManagementService } from 'src/app/services/mgmt.service'; import { ToastService } from 'src/app/services/toast.service'; @Component({ diff --git a/console/src/app/modules/nav/nav.component.ts b/console/src/app/modules/nav/nav.component.ts index d990bb5d82..4597f699b8 100644 --- a/console/src/app/modules/nav/nav.component.ts +++ b/console/src/app/modules/nav/nav.component.ts @@ -5,7 +5,7 @@ import { HttpClient } from '@angular/common/http'; import { Component, ElementRef, Input, OnDestroy, ViewChild } from '@angular/core'; import { UntypedFormControl } from '@angular/forms'; import { Router } from '@angular/router'; -import { BehaviorSubject, combineLatest, map, Observable, Subject, take, tap } from 'rxjs'; +import { BehaviorSubject, combineLatest, map, Observable, Subject, take } from 'rxjs'; import { Org } from 'src/app/proto/generated/zitadel/org_pb'; import { User } from 'src/app/proto/generated/zitadel/user_pb'; import { AdminService } from 'src/app/services/admin.service'; diff --git a/console/src/app/modules/onboarding-card/onboarding-card.module.ts b/console/src/app/modules/onboarding-card/onboarding-card.module.ts index 08eb413d08..520c806ae8 100644 --- a/console/src/app/modules/onboarding-card/onboarding-card.module.ts +++ b/console/src/app/modules/onboarding-card/onboarding-card.module.ts @@ -1,18 +1,12 @@ import { CommonModule } from '@angular/common'; import { NgModule } from '@angular/core'; -import { MatRippleModule } from '@angular/material/core'; import { MatIconModule } from '@angular/material/icon'; -import { MatLegacyButtonModule as MatButtonModule } from '@angular/material/legacy-button'; import { MatLegacyProgressSpinnerModule as MatProgressSpinnerModule } from '@angular/material/legacy-progress-spinner'; import { MatLegacyTooltipModule as MatTooltipModule } from '@angular/material/legacy-tooltip'; import { TranslateModule } from '@ngx-translate/core'; -import { HasRoleModule } from 'src/app/directives/has-role/has-role.module'; -import { ShortcutsModule } from 'src/app/modules/shortcuts/shortcuts.module'; import { RouterModule } from '@angular/router'; import { EventPipeModule } from 'src/app/pipes/event-pipe/event-pipe.module'; -import { LocalizedDatePipeModule } from 'src/app/pipes/localized-date-pipe/localized-date-pipe.module'; -import { TimestampToDatePipeModule } from 'src/app/pipes/timestamp-to-date-pipe/timestamp-to-date-pipe.module'; import { OnboardingCardComponent } from './onboarding-card.component'; @NgModule({ diff --git a/console/src/app/modules/org-table/org-table.component.ts b/console/src/app/modules/org-table/org-table.component.ts index ad2ffc3786..b60c049fd5 100644 --- a/console/src/app/modules/org-table/org-table.component.ts +++ b/console/src/app/modules/org-table/org-table.component.ts @@ -5,7 +5,7 @@ import { MatSort, Sort } from '@angular/material/sort'; import { Router } from '@angular/router'; import { TranslateService } from '@ngx-translate/core'; import { Timestamp } from 'google-protobuf/google/protobuf/timestamp_pb'; -import { BehaviorSubject, catchError, finalize, from, map, Observable, of, Subject, switchMap, take, takeUntil } from 'rxjs'; +import { BehaviorSubject, catchError, finalize, from, map, Observable, of, Subject, switchMap, takeUntil } from 'rxjs'; import { Org, OrgFieldName, OrgQuery, OrgState } from 'src/app/proto/generated/zitadel/org_pb'; import { GrpcAuthService } from 'src/app/services/grpc-auth.service'; import { ToastService } from 'src/app/services/toast.service'; diff --git a/console/src/app/modules/paginator/paginator.component.ts b/console/src/app/modules/paginator/paginator.component.ts index 764ed7c8f6..b4b406acda 100644 --- a/console/src/app/modules/paginator/paginator.component.ts +++ b/console/src/app/modules/paginator/paginator.component.ts @@ -1,5 +1,4 @@ import { Component, EventEmitter, Input, Output } from '@angular/core'; -import { EventManager } from '@angular/platform-browser'; import { Timestamp } from 'src/app/proto/generated/google/protobuf/timestamp_pb'; export interface PageEvent { diff --git a/console/src/app/modules/policies/notification-settings/notification-settings.component.ts b/console/src/app/modules/policies/notification-settings/notification-settings.component.ts index 24fac71167..2cf94dbecd 100644 --- a/console/src/app/modules/policies/notification-settings/notification-settings.component.ts +++ b/console/src/app/modules/policies/notification-settings/notification-settings.component.ts @@ -8,7 +8,6 @@ import { AddSMTPConfigResponse, UpdateSMSProviderTwilioRequest, UpdateSMTPConfigPasswordRequest, - UpdateSMTPConfigPasswordResponse, UpdateSMTPConfigRequest, UpdateSMTPConfigResponse, } from 'src/app/proto/generated/zitadel/admin_pb'; diff --git a/console/src/app/modules/project-roles-table/project-roles-table.component.ts b/console/src/app/modules/project-roles-table/project-roles-table.component.ts index 94579bb7ac..96ff9da551 100644 --- a/console/src/app/modules/project-roles-table/project-roles-table.component.ts +++ b/console/src/app/modules/project-roles-table/project-roles-table.component.ts @@ -1,5 +1,5 @@ import { SelectionModel } from '@angular/cdk/collections'; -import { ChangeDetectorRef, Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core'; +import { Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core'; import { MatLegacyDialog as MatDialog } from '@angular/material/legacy-dialog'; import { MatLegacyTable as MatTable } from '@angular/material/legacy-table'; import { Router } from '@angular/router'; diff --git a/console/src/app/modules/user-grant-role-dialog/user-grant-role-dialog.component.ts b/console/src/app/modules/user-grant-role-dialog/user-grant-role-dialog.component.ts index 2af76ddefa..ce91cfbd12 100644 --- a/console/src/app/modules/user-grant-role-dialog/user-grant-role-dialog.component.ts +++ b/console/src/app/modules/user-grant-role-dialog/user-grant-role-dialog.component.ts @@ -3,7 +3,6 @@ import { MatLegacyDialogRef as MatDialogRef, MAT_LEGACY_DIALOG_DATA as MAT_DIALOG_DATA, } from '@angular/material/legacy-dialog'; -import { Role } from 'src/app/proto/generated/zitadel/project_pb'; @Component({ selector: 'cnsl-user-grant-role-dialog', diff --git a/console/src/app/modules/user-grants/user-grants-datasource.ts b/console/src/app/modules/user-grants/user-grants-datasource.ts index 659b1e7304..3e8ceb8db7 100644 --- a/console/src/app/modules/user-grants/user-grants-datasource.ts +++ b/console/src/app/modules/user-grants/user-grants-datasource.ts @@ -1,33 +1,37 @@ import { DataSource } from '@angular/cdk/collections'; import { Timestamp } from 'google-protobuf/google/protobuf/timestamp_pb'; -import { BehaviorSubject, from, Observable, of } from 'rxjs'; -import { catchError, finalize, map } from 'rxjs/operators'; +import { BehaviorSubject, Observable } from 'rxjs'; +import { ListMyUserGrantsResponse, UserGrant as AuthUserGrant } from 'src/app/proto/generated/zitadel/auth_pb'; import { ListUserGrantResponse } from 'src/app/proto/generated/zitadel/management_pb'; import { - UserGrant, + UserGrant as MgmtUserGrant, UserGrantProjectGrantIDQuery, UserGrantProjectIDQuery, UserGrantQuery, UserGrantUserIDQuery, } from 'src/app/proto/generated/zitadel/user_pb'; +import { GrpcAuthService } from 'src/app/services/grpc-auth.service'; import { ManagementService } from 'src/app/services/mgmt.service'; export enum UserGrantContext { NONE = 'none', + AUTHUSER = 'authuser', USER = 'user', OWNED_PROJECT = 'owned', GRANTED_PROJECT = 'granted', } -export class UserGrantsDataSource extends DataSource { +type UserGrantAsObject = AuthUserGrant.AsObject | MgmtUserGrant.AsObject; + +export class UserGrantsDataSource extends DataSource { public totalResult: number = 0; public viewTimestamp!: Timestamp.AsObject; - public grantsSubject: BehaviorSubject = new BehaviorSubject([]); + public grantsSubject: BehaviorSubject> = new BehaviorSubject>([]); private loadingSubject: BehaviorSubject = new BehaviorSubject(false); public loading$: Observable = this.loadingSubject.asObservable(); - constructor(private userService: ManagementService) { + constructor(private authService: GrpcAuthService, private userService: ManagementService) { super(); } @@ -43,6 +47,13 @@ export class UserGrantsDataSource extends DataSource { queries?: UserGrantQuery[], ): void { switch (context) { + case UserGrantContext.AUTHUSER: + if (data && data.userId) { + this.loadingSubject.next(true); + const promise = this.authService.listMyUserGrants(pageSize, pageSize * pageIndex); + this.loadResponse(promise); + } + break; case UserGrantContext.USER: if (data && data.userId) { this.loadingSubject.next(true); @@ -114,34 +125,33 @@ export class UserGrantsDataSource extends DataSource { } } - private loadResponse(promise: Promise): void { - from(promise) - .pipe( - map((resp) => { - if (resp.details?.totalResult) { - this.totalResult = resp.details.totalResult; - } else { - this.totalResult = 0; - } - if (resp.details?.viewTimestamp) { + private loadResponse(promise: Promise): void { + promise + .then((resp) => { + this.loadingSubject.next(false); + if (resp.resultList) { + this.grantsSubject.next(resp.resultList); + } + if (resp.details) { + this.totalResult = resp.details.totalResult; + if (resp.details.viewTimestamp) { this.viewTimestamp = resp.details.viewTimestamp; } - return resp.resultList; - }), - catchError(() => of([])), - finalize(() => this.loadingSubject.next(false)), - ) - .subscribe((grants) => { - this.grantsSubject.next(grants); + } + }) + .catch((error) => { + console.error(error); + this.grantsSubject.next([]); + this.loadingSubject.next(false); }); } /** * Connect this data source to the table. The table will only update when - * the returned stream emits new items. - * @returns A stream of the items to be rendered. + * the returned stream emits new lists of items. + * @returns A stream of item lists to be rendered. */ - public connect(): Observable { + public connect(): Observable> { return this.grantsSubject.asObservable(); } diff --git a/console/src/app/modules/user-grants/user-grants.component.html b/console/src/app/modules/user-grants/user-grants.component.html index 80de03781a..320a37a7f2 100644 --- a/console/src/app/modules/user-grants/user-grants.component.html +++ b/console/src/app/modules/user-grants/user-grants.component.html @@ -155,6 +155,7 @@ actions matTooltip="{{ 'ACTIONS.REMOVE' | translate }}" color="warn" + [disabled]="disableDelete" (click)="deleteGrant($event, grant)" mat-icon-button > @@ -170,8 +171,8 @@ diff --git a/console/src/app/modules/user-grants/user-grants.component.ts b/console/src/app/modules/user-grants/user-grants.component.ts index d74d4c9cfa..b85a200306 100644 --- a/console/src/app/modules/user-grants/user-grants.component.ts +++ b/console/src/app/modules/user-grants/user-grants.component.ts @@ -2,13 +2,14 @@ import { SelectionModel } from '@angular/cdk/collections'; import { AfterViewInit, Component, Input, OnInit, ViewChild } from '@angular/core'; import { MatLegacyDialog as MatDialog } from '@angular/material/legacy-dialog'; import { MatLegacyInput as MatInput } from '@angular/material/legacy-input'; -import { MatLegacySelectChange as MatSelectChange } from '@angular/material/legacy-select'; import { MatLegacyTable as MatTable } from '@angular/material/legacy-table'; import { Router } from '@angular/router'; import { tap } from 'rxjs/operators'; import { enterAnimations } from 'src/app/animations'; +import { UserGrant as AuthUserGrant } from 'src/app/proto/generated/zitadel/auth_pb'; import { Role } from 'src/app/proto/generated/zitadel/project_pb'; -import { Type, UserGrant, UserGrantQuery } from 'src/app/proto/generated/zitadel/user_pb'; +import { Type, UserGrant as MgmtUserGrant, UserGrantQuery } from 'src/app/proto/generated/zitadel/user_pb'; +import { GrpcAuthService } from 'src/app/services/grpc-auth.service'; import { ManagementService } from 'src/app/services/mgmt.service'; import { ToastService } from 'src/app/services/toast.service'; @@ -24,6 +25,9 @@ export enum UserGrantListSearchKey { PROJECT_NAME, ROLE_KEY, } + +type UserGrantAsObject = AuthUserGrant.AsObject | MgmtUserGrant.AsObject; + @Component({ selector: 'cnsl-user-grants', templateUrl: './user-grants.component.html', @@ -38,10 +42,10 @@ export class UserGrantsComponent implements OnInit, AfterViewInit { @Input() context: UserGrantContext = UserGrantContext.NONE; @Input() refreshOnPreviousRoutes: string[] = []; - public dataSource: UserGrantsDataSource = new UserGrantsDataSource(this.userService); - public selection: SelectionModel = new SelectionModel(true, []); + public dataSource: UserGrantsDataSource = new UserGrantsDataSource(this.authService, this.userService); + public selection: SelectionModel = new SelectionModel(true, []); @ViewChild(PaginatorComponent) public paginator?: PaginatorComponent; - @ViewChild(MatTable) public table?: MatTable; + @ViewChild(MatTable) public table?: MatTable; @Input() disableWrite: boolean = false; @Input() disableDelete: boolean = false; @@ -66,6 +70,7 @@ export class UserGrantsComponent implements OnInit, AfterViewInit { public filterOpen: boolean = false; constructor( + private authService: GrpcAuthService, private userService: ManagementService, private toast: ToastService, private dialog: MatDialog, @@ -88,14 +93,12 @@ export class UserGrantsComponent implements OnInit, AfterViewInit { switch (this.context) { case UserGrantContext.OWNED_PROJECT: if (this.projectId) { - // this.getProjectRoleOptions(this.projectId); this.routerLink = ['/grant-create', 'project', this.projectId]; } break; case UserGrantContext.GRANTED_PROJECT: if (this.grantId) { this.routerLink = ['/grant-create', 'project', this.projectId, 'grant', this.grantId]; - // this.getGrantRoleOptions(this.grantId, this.projectId); } break; case UserGrantContext.USER: @@ -103,6 +106,11 @@ export class UserGrantsComponent implements OnInit, AfterViewInit { this.routerLink = ['/grant-create', 'user', this.userId]; } break; + case UserGrantContext.AUTHUSER: + if (this.grantId) { + this.routerLink = ['/grant-create', 'user', this.userId]; + } + break; case UserGrantContext.NONE: this.routerLink = ['/grant-create']; } @@ -119,7 +127,7 @@ export class UserGrantsComponent implements OnInit, AfterViewInit { this.loadGrantsPage(type); } - public getType(grant: UserGrant.AsObject): string { + public getType(grant: UserGrantAsObject): string { if (grant.projectGrantId) { return 'Project Grant'; } else if (grant.projectId) { @@ -161,11 +169,11 @@ export class UserGrantsComponent implements OnInit, AfterViewInit { : this.dataSource.grantsSubject.value.forEach((row) => this.selection.select(row)); } - public openEditDialog(grant: UserGrant.AsObject): void { + public openEditDialog(grant: UserGrantAsObject): void { const dialogRef = this.dialog.open(UserGrantRoleDialogComponent, { data: { projectId: grant.projectId, - grantId: grant.projectGrantId, + grantId: grant?.projectGrantId, selectedRoleKeysList: grant.roleKeysList, i18nTitle: 'GRANTS.EDIT.TITLE', }, @@ -175,7 +183,11 @@ export class UserGrantsComponent implements OnInit, AfterViewInit { dialogRef.afterClosed().subscribe((resp) => { if (resp && resp.roles) { this.userService - .updateUserGrant(grant.id, grant.userId, resp.roles) + .updateUserGrant( + (grant as MgmtUserGrant.AsObject).id ?? (grant as AuthUserGrant.AsObject).grantId, + grant.userId, + resp.roles, + ) .then(() => { this.toast.showInfo('GRANTS.TOAST.UPDATED', true); grant.roleKeysList = resp.roles; @@ -187,18 +199,7 @@ export class UserGrantsComponent implements OnInit, AfterViewInit { }); } - updateRoles(grant: UserGrant.AsObject, selectionChange: MatSelectChange): void { - this.userService - .updateUserGrant(grant.id, grant.userId, selectionChange.value) - .then(() => { - this.toast.showInfo('GRANTS.TOAST.UPDATED', true); - }) - .catch((error) => { - this.toast.showError(error); - }); - } - - public deleteGrant(event: any, grant: UserGrant.AsObject): void { + public deleteGrant(event: any, grant: MgmtUserGrant.AsObject): void { event.stopPropagation(); const dialogRef = this.dialog.open(WarnDialogComponent, { @@ -219,7 +220,9 @@ export class UserGrantsComponent implements OnInit, AfterViewInit { this.toast.showInfo('GRANTS.TOAST.REMOVED', true); const data = this.dataSource.grantsSubject.getValue(); - const index = data.findIndex((i) => i.id === grant.id); + const index = data.findIndex( + (i) => (i as MgmtUserGrant.AsObject).id && (i as MgmtUserGrant.AsObject).id === grant.id, + ); if (index > -1) { data.splice(index, 1); this.dataSource.grantsSubject.next(data); @@ -246,12 +249,12 @@ export class UserGrantsComponent implements OnInit, AfterViewInit { dialogRef.afterClosed().subscribe((resp) => { if (resp) { this.userService - .bulkRemoveUserGrant(this.selection.selected.map((grant) => grant.id)) + .bulkRemoveUserGrant(this.selection.selected.map((grant) => (grant as MgmtUserGrant.AsObject).id)) .then(() => { this.toast.showInfo('GRANTS.TOAST.BULKREMOVED', true); const data = this.dataSource.grantsSubject.getValue(); this.selection.selected.forEach((item) => { - const index = data.findIndex((i) => i.id === item.id); + const index = data.findIndex((i) => (i as MgmtUserGrant.AsObject).id === (item as MgmtUserGrant.AsObject).id); if (index > -1) { data.splice(index, 1); this.dataSource.grantsSubject.next(data); diff --git a/console/src/app/pages/app-create/app-create.component.ts b/console/src/app/pages/app-create/app-create.component.ts index 91bb577767..23dc292340 100644 --- a/console/src/app/pages/app-create/app-create.component.ts +++ b/console/src/app/pages/app-create/app-create.component.ts @@ -1,14 +1,6 @@ -import { animate, style, transition, trigger } from '@angular/animations'; -import { Location } from '@angular/common'; import { Component } from '@angular/core'; -import { AbstractControl, UntypedFormBuilder, UntypedFormGroup, ValidatorFn, Validators } from '@angular/forms'; -import { MatLegacySlideToggleChange as MatSlideToggleChange } from '@angular/material/legacy-slide-toggle'; import { Router } from '@angular/router'; -import { take } from 'rxjs/operators'; import { ProjectAutocompleteType } from 'src/app/modules/search-project-autocomplete/search-project-autocomplete.component'; -import { lowerCaseValidator, numberValidator, symbolValidator, upperCaseValidator } from 'src/app/pages/validators'; -import { SetUpOrgRequest } from 'src/app/proto/generated/zitadel/admin_pb'; -import { PasswordComplexityPolicy } from 'src/app/proto/generated/zitadel/policy_pb'; import { Project } from 'src/app/proto/generated/zitadel/project_pb'; import { Breadcrumb, BreadcrumbService, BreadcrumbType } from 'src/app/services/breadcrumb.service'; diff --git a/console/src/app/pages/events/events.component.ts b/console/src/app/pages/events/events.component.ts index 952c0225c7..d5e1a6ef14 100644 --- a/console/src/app/pages/events/events.component.ts +++ b/console/src/app/pages/events/events.component.ts @@ -1,9 +1,9 @@ import { LiveAnnouncer } from '@angular/cdk/a11y'; -import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core'; +import { Component, OnDestroy, ViewChild } from '@angular/core'; import { MatLegacyDialog as MatDialog } from '@angular/material/legacy-dialog'; import { MatLegacyTableDataSource as MatTableDataSource } from '@angular/material/legacy-table'; import { MatSort, Sort } from '@angular/material/sort'; -import { BehaviorSubject, distinctUntilChanged, Observable, Subject, takeUntil } from 'rxjs'; +import { BehaviorSubject, Observable, Subject, takeUntil } from 'rxjs'; import { DisplayJsonDialogComponent } from 'src/app/modules/display-json-dialog/display-json-dialog.component'; import { PaginatorComponent } from 'src/app/modules/paginator/paginator.component'; import { ListEventsRequest, ListEventsResponse } from 'src/app/proto/generated/zitadel/admin_pb'; diff --git a/console/src/app/pages/org-create/org-create.component.ts b/console/src/app/pages/org-create/org-create.component.ts index e6573736f9..3f7ebeb6eb 100644 --- a/console/src/app/pages/org-create/org-create.component.ts +++ b/console/src/app/pages/org-create/org-create.component.ts @@ -4,14 +4,12 @@ import { Component } from '@angular/core'; import { AbstractControl, UntypedFormBuilder, UntypedFormGroup, ValidatorFn, Validators } from '@angular/forms'; import { MatLegacySlideToggleChange as MatSlideToggleChange } from '@angular/material/legacy-slide-toggle'; import { Router } from '@angular/router'; -import { take } from 'rxjs/operators'; import { lowerCaseValidator, numberValidator, symbolValidator, upperCaseValidator } from 'src/app/pages/validators'; import { SetUpOrgRequest } from 'src/app/proto/generated/zitadel/admin_pb'; import { PasswordComplexityPolicy } from 'src/app/proto/generated/zitadel/policy_pb'; import { Gender } from 'src/app/proto/generated/zitadel/user_pb'; import { AdminService } from 'src/app/services/admin.service'; import { Breadcrumb, BreadcrumbService, BreadcrumbType } from 'src/app/services/breadcrumb.service'; -import { GrpcAuthService } from 'src/app/services/grpc-auth.service'; import { ManagementService } from 'src/app/services/mgmt.service'; import { ToastService } from 'src/app/services/toast.service'; diff --git a/console/src/app/pages/projects/owned-projects/project-grant-create/project-grant-create.component.ts b/console/src/app/pages/projects/owned-projects/project-grant-create/project-grant-create.component.ts index 01a9a87ce8..29cf44d169 100644 --- a/console/src/app/pages/projects/owned-projects/project-grant-create/project-grant-create.component.ts +++ b/console/src/app/pages/projects/owned-projects/project-grant-create/project-grant-create.component.ts @@ -3,7 +3,6 @@ import { Component, OnDestroy, OnInit } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; import { Subject, takeUntil } from 'rxjs'; import { Org } from 'src/app/proto/generated/zitadel/org_pb'; -import { Role } from 'src/app/proto/generated/zitadel/project_pb'; import { Breadcrumb, BreadcrumbService, BreadcrumbType } from 'src/app/services/breadcrumb.service'; import { ManagementService } from 'src/app/services/mgmt.service'; import { ToastService } from 'src/app/services/toast.service'; diff --git a/console/src/app/pages/user-grant-create/user-grant-create.component.ts b/console/src/app/pages/user-grant-create/user-grant-create.component.ts index 9b2f32b288..891d631d85 100644 --- a/console/src/app/pages/user-grant-create/user-grant-create.component.ts +++ b/console/src/app/pages/user-grant-create/user-grant-create.component.ts @@ -6,7 +6,7 @@ import { ProjectType } from 'src/app/modules/project-members/project-members-dat import { UserTarget } from 'src/app/modules/search-user-autocomplete/search-user-autocomplete.component'; import { UserGrantContext } from 'src/app/modules/user-grants/user-grants-datasource'; import { Org } from 'src/app/proto/generated/zitadel/org_pb'; -import { GrantedProject, Project, Role } from 'src/app/proto/generated/zitadel/project_pb'; +import { GrantedProject, Project } from 'src/app/proto/generated/zitadel/project_pb'; import { User } from 'src/app/proto/generated/zitadel/user_pb'; import { Breadcrumb, BreadcrumbService, BreadcrumbType } from 'src/app/services/breadcrumb.service'; import { ManagementService } from 'src/app/services/mgmt.service'; diff --git a/console/src/app/pages/users/user-create/user-create.component.ts b/console/src/app/pages/users/user-create/user-create.component.ts index ddc6eda4ae..811e57c174 100644 --- a/console/src/app/pages/users/user-create/user-create.component.ts +++ b/console/src/app/pages/users/user-create/user-create.component.ts @@ -2,7 +2,6 @@ import { Location } from '@angular/common'; import { ChangeDetectorRef, Component, OnDestroy, OnInit, ViewChild } from '@angular/core'; import { AbstractControl, UntypedFormBuilder, UntypedFormGroup, ValidatorFn, Validators } from '@angular/forms'; import { Router } from '@angular/router'; -import { CountryCode, parsePhoneNumber } from 'libphonenumber-js'; import { Subject } from 'rxjs'; import { AddHumanUserRequest } from 'src/app/proto/generated/zitadel/management_pb'; import { Domain } from 'src/app/proto/generated/zitadel/org_pb'; diff --git a/console/src/app/pages/users/user-detail/auth-user-detail/auth-user-detail.component.html b/console/src/app/pages/users/user-detail/auth-user-detail/auth-user-detail.component.html index 0daa8d0817..a73d9dca41 100644 --- a/console/src/app/pages/users/user-detail/auth-user-detail/auth-user-detail.component.html +++ b/console/src/app/pages/users/user-detail/auth-user-detail/auth-user-detail.component.html @@ -127,16 +127,7 @@ diff --git a/console/src/app/pages/users/user-detail/auth-user-detail/auth-user-detail.component.ts b/console/src/app/pages/users/user-detail/auth-user-detail/auth-user-detail.component.ts index ec1f4cff38..7eb7446cdd 100644 --- a/console/src/app/pages/users/user-detail/auth-user-detail/auth-user-detail.component.ts +++ b/console/src/app/pages/users/user-detail/auth-user-detail/auth-user-detail.component.ts @@ -42,7 +42,7 @@ export class AuthUserDetailComponent implements OnDestroy { public userLoginMustBeDomain: boolean = false; public UserState: any = UserState; - public USERGRANTCONTEXT: UserGrantContext = UserGrantContext.USER; + public USERGRANTCONTEXT: UserGrantContext = UserGrantContext.AUTHUSER; public refreshChanges$: EventEmitter = new EventEmitter(); public metadata: Metadata.AsObject[] = []; diff --git a/console/src/app/pages/users/user-detail/auth-user-detail/edit-dialog/edit-dialog.component.ts b/console/src/app/pages/users/user-detail/auth-user-detail/edit-dialog/edit-dialog.component.ts index 3efac78f42..ae0256fe53 100644 --- a/console/src/app/pages/users/user-detail/auth-user-detail/edit-dialog/edit-dialog.component.ts +++ b/console/src/app/pages/users/user-detail/auth-user-detail/edit-dialog/edit-dialog.component.ts @@ -4,7 +4,6 @@ import { MatLegacyDialogRef as MatDialogRef, MAT_LEGACY_DIALOG_DATA as MAT_DIALOG_DATA, } from '@angular/material/legacy-dialog'; -import { CountryCode, parsePhoneNumber } from 'libphonenumber-js'; import { CountryCallingCodesService, CountryPhoneCode } from 'src/app/services/country-calling-codes.service'; import { formatPhone } from 'src/app/utils/formatPhone'; diff --git a/console/src/app/pipes/to-payload/to-payload.pipe.ts b/console/src/app/pipes/to-payload/to-payload.pipe.ts index feb8480e50..e89c146382 100644 --- a/console/src/app/pipes/to-payload/to-payload.pipe.ts +++ b/console/src/app/pipes/to-payload/to-payload.pipe.ts @@ -1,5 +1,5 @@ import { Pipe, PipeTransform } from '@angular/core'; -import { JavaScriptValue, Struct } from 'google-protobuf/google/protobuf/struct_pb'; +import { JavaScriptValue } from 'google-protobuf/google/protobuf/struct_pb'; import { Event } from 'src/app/proto/generated/zitadel/event_pb'; @Pipe({ diff --git a/console/src/app/services/authentication.service.ts b/console/src/app/services/authentication.service.ts index 8f238efb2c..b4b24c30fd 100644 --- a/console/src/app/services/authentication.service.ts +++ b/console/src/app/services/authentication.service.ts @@ -1,7 +1,6 @@ import { Injectable } from '@angular/core'; import { AuthConfig, OAuthService } from 'angular-oauth2-oidc'; import { BehaviorSubject, from, lastValueFrom, Observable } from 'rxjs'; -import { GrpcAuthService } from './grpc-auth.service'; import { StatehandlerService } from './statehandler/statehandler.service'; diff --git a/console/src/app/services/grpc-auth.service.ts b/console/src/app/services/grpc-auth.service.ts index d7e2e15084..5ba2cd4e1c 100644 --- a/console/src/app/services/grpc-auth.service.ts +++ b/console/src/app/services/grpc-auth.service.ts @@ -9,10 +9,8 @@ import { finalize, map, mergeMap, - pairwise, switchMap, take, - tap, timeout, withLatestFrom, } from 'rxjs/operators'; @@ -29,7 +27,6 @@ import { GetMyEmailRequest, GetMyEmailResponse, GetMyLabelPolicyRequest, - GetMyLabelPolicyResponse, GetMyLoginPolicyRequest, GetMyLoginPolicyResponse, GetMyPasswordComplexityPolicyRequest, @@ -426,11 +423,7 @@ export class GrpcAuthService { return this.grpcService.auth.listMyUserSessions(req, null).then((resp) => resp.toObject()); } - public listMyUserGrants( - limit?: number, - offset?: number, - queryList?: ListQuery[], - ): Promise { + public listMyUserGrants(limit?: number, offset?: number, asc?: boolean): Promise { const req = new ListMyUserGrantsRequest(); const query = new ListQuery(); if (limit) { @@ -439,6 +432,9 @@ export class GrpcAuthService { if (offset) { query.setOffset(offset); } + if (asc !== undefined) { + query.setAsc(asc); + } req.setQuery(query); return this.grpcService.auth.listMyUserGrants(req, null).then((resp) => resp.toObject()); } diff --git a/console/src/app/services/mgmt.service.ts b/console/src/app/services/mgmt.service.ts index fb2b423905..79e9a94560 100644 --- a/console/src/app/services/mgmt.service.ts +++ b/console/src/app/services/mgmt.service.ts @@ -4,8 +4,6 @@ import { Empty } from 'google-protobuf/google/protobuf/empty_pb'; import { Timestamp } from 'google-protobuf/google/protobuf/timestamp_pb'; import { BehaviorSubject } from 'rxjs'; -import { FlowType, TriggerType } from '../proto/generated/zitadel/action_pb'; -import { RemoveLabelPolicyLogoDarkRequest } from '../proto/generated/zitadel/admin_pb'; import { AppQuery } from '../proto/generated/zitadel/app_pb'; import { KeyType } from '../proto/generated/zitadel/auth_n_key_pb'; import { ChangeQuery } from '../proto/generated/zitadel/change_pb'; diff --git a/console/src/app/services/theme.service.ts b/console/src/app/services/theme.service.ts index 858fea68f1..4151b4a56c 100644 --- a/console/src/app/services/theme.service.ts +++ b/console/src/app/services/theme.service.ts @@ -2,8 +2,6 @@ import { Injectable } from '@angular/core'; import { BehaviorSubject, Observable } from 'rxjs'; import { LabelPolicy } from '../proto/generated/zitadel/policy_pb'; -import { GrpcAuthService } from './grpc-auth.service'; - declare const tinycolor: any; export interface Color { diff --git a/internal/api/grpc/auth/user_grant.go b/internal/api/grpc/auth/user_grant.go index 93a7ee7a4c..7816e66476 100644 --- a/internal/api/grpc/auth/user_grant.go +++ b/internal/api/grpc/auth/user_grant.go @@ -43,5 +43,15 @@ func UserGrantToPb(grant *query.UserGrant) *auth_pb.UserGrant { ProjectId: grant.ProjectID, UserId: grant.UserID, Roles: grant.Roles, + Details: object.ToViewDetailsPb( + grant.Sequence, + grant.CreationDate, + grant.ChangeDate, + grant.ResourceOwner, + ), + OrgDomain: grant.OrgPrimaryDomain, + ProjectName: grant.ProjectName, + ProjectGrantId: grant.GrantID, + RoleKeys: grant.Roles, } } diff --git a/proto/zitadel/auth.proto b/proto/zitadel/auth.proto index eb6d4cd95d..d9ee2d105a 100644 --- a/proto/zitadel/auth.proto +++ b/proto/zitadel/auth.proto @@ -1429,9 +1429,10 @@ message UserGrant { example: "\"28746028909593987\"" } ]; + // Deprecated: user role_keys repeated string roles = 4 [ (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { - example: "[\"RoleKey1\", \"RoleKey2\"]" + example: "[\"RoleKey1\", \"RoleKey2\"]", } ]; string org_name = 5 [ @@ -1444,6 +1445,27 @@ message UserGrant { example: "\"\"" } ]; + zitadel.v1.ObjectDetails details = 7; + string org_domain = 8 [ + (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { + example: "\"zitadel.cloud\"" + } + ]; + string project_name = 9 [ + (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { + example: "\"ZITADEL\"" + } + ]; + string project_grant_id = 10 [ + (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { + example: "\"28746028909586246\"" + } + ]; + repeated string role_keys = 11 [ + (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { + example: "[\"RoleKey1\", \"RoleKey2\"]", + } + ]; } message ListMyProjectOrgsRequest {