mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-13 18:32:10 +00:00
feat(console): grpc web interceptors, cleanup services (#631)
* managementservice, authservice, change all refs * refactor grpc auth * fix references * interceptor logic * new interceptor * appinitializers, environment loader, interceptors * remove circular dep * init authconfig in grpc service * authconfig * lint * update mgmt service * fix references * update clientid, fix interceptor * rm unused authconfig * todo auth interceptor
This commit is contained in:
@@ -3,8 +3,7 @@ import { AbstractControl, FormBuilder, FormGroup, Validators } from '@angular/fo
|
||||
import { Router } from '@angular/router';
|
||||
import { Subscription } from 'rxjs';
|
||||
import { CreateUserRequest, Gender, User } from 'src/app/proto/generated/management_pb';
|
||||
import { MgmtUserService } from 'src/app/services/mgmt-user.service';
|
||||
import { OrgService } from 'src/app/services/org.service';
|
||||
import { ManagementService } from 'src/app/services/mgmt.service';
|
||||
import { ToastService } from 'src/app/services/toast.service';
|
||||
|
||||
function noEmailValidator(c: AbstractControl): any {
|
||||
@@ -44,12 +43,12 @@ export class UserCreateComponent implements OnDestroy {
|
||||
constructor(
|
||||
private router: Router,
|
||||
private toast: ToastService,
|
||||
public userService: MgmtUserService,
|
||||
public userService: ManagementService,
|
||||
private fb: FormBuilder,
|
||||
private orgService: OrgService,
|
||||
private mgmtService: ManagementService,
|
||||
) {
|
||||
this.loading = true;
|
||||
this.orgService.GetMyOrgIamPolicy().then((iampolicy) => {
|
||||
this.mgmtService.GetMyOrgIamPolicy().then((iampolicy) => {
|
||||
this.userLoginMustBeDomain = iampolicy.toObject().userLoginMustBeDomain;
|
||||
this.initForm();
|
||||
this.loading = false;
|
||||
|
||||
@@ -4,7 +4,7 @@ import { TranslateService } from '@ngx-translate/core';
|
||||
import { Subscription } from 'rxjs';
|
||||
import { ChangeType } from 'src/app/modules/changes/changes.component';
|
||||
import { Gender, UserAddress, UserEmail, UserPhone, UserProfile, UserView } from 'src/app/proto/generated/auth_pb';
|
||||
import { AuthUserService } from 'src/app/services/auth-user.service';
|
||||
import { GrpcAuthService } from 'src/app/services/grpc-auth.service';
|
||||
import { ToastService } from 'src/app/services/toast.service';
|
||||
|
||||
import { CodeDialogComponent } from './code-dialog/code-dialog.component';
|
||||
@@ -35,7 +35,7 @@ export class AuthUserDetailComponent implements OnDestroy {
|
||||
constructor(
|
||||
public translate: TranslateService,
|
||||
private toast: ToastService,
|
||||
private userService: AuthUserService,
|
||||
private userService: GrpcAuthService,
|
||||
private dialog: MatDialog,
|
||||
) {
|
||||
this.loading = true;
|
||||
|
||||
@@ -4,7 +4,7 @@ import { MatSort } from '@angular/material/sort';
|
||||
import { MatTable, MatTableDataSource } from '@angular/material/table';
|
||||
import { BehaviorSubject, Observable } from 'rxjs';
|
||||
import { MfaOtpResponse, MFAState, MfaType, MultiFactor } from 'src/app/proto/generated/auth_pb';
|
||||
import { AuthUserService } from 'src/app/services/auth-user.service';
|
||||
import { GrpcAuthService } from 'src/app/services/grpc-auth.service';
|
||||
import { ToastService } from 'src/app/services/toast.service';
|
||||
|
||||
import { DialogOtpComponent } from '../dialog-otp/dialog-otp.component';
|
||||
@@ -28,7 +28,7 @@ export class AuthUserMfaComponent implements OnInit, OnDestroy {
|
||||
|
||||
public error: string = '';
|
||||
public otpAvailable: boolean = false;
|
||||
constructor(private service: AuthUserService, private toast: ToastService, private dialog: MatDialog) { }
|
||||
constructor(private service: GrpcAuthService, private toast: ToastService, private dialog: MatDialog) { }
|
||||
|
||||
public ngOnInit(): void {
|
||||
this.getOTP();
|
||||
@@ -48,7 +48,7 @@ export class AuthUserMfaComponent implements OnInit, OnDestroy {
|
||||
|
||||
dialogRef.afterClosed().subscribe((code) => {
|
||||
if (code) {
|
||||
(this.service as AuthUserService).VerifyMfaOTP(code).then(() => {
|
||||
this.service.VerifyMfaOTP(code).then(() => {
|
||||
this.getOTP();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { Timestamp } from 'google-protobuf/google/protobuf/timestamp_pb';
|
||||
import { BehaviorSubject, from, Observable, of } from 'rxjs';
|
||||
import { catchError, finalize, map } from 'rxjs/operators';
|
||||
import { UserMembershipView } from 'src/app/proto/generated/management_pb';
|
||||
import { MgmtUserService } from 'src/app/services/mgmt-user.service';
|
||||
import { ManagementService } from 'src/app/services/mgmt.service';
|
||||
|
||||
export class MembershipDetailDataSource extends DataSource<UserMembershipView.AsObject> {
|
||||
public totalResult: number = 0;
|
||||
@@ -13,7 +13,7 @@ export class MembershipDetailDataSource extends DataSource<UserMembershipView.As
|
||||
private loadingSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
|
||||
public loading$: Observable<boolean> = this.loadingSubject.asObservable();
|
||||
|
||||
constructor(private mgmtUserService: MgmtUserService) {
|
||||
constructor(private mgmtUserService: ManagementService) {
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
@@ -8,9 +8,7 @@ import { tap } from 'rxjs/operators';
|
||||
import { CreationType, MemberCreateDialogComponent } from 'src/app/modules/add-member-dialog/member-create-dialog.component';
|
||||
import { User, UserMembershipSearchResponse, UserMembershipView, UserView } from 'src/app/proto/generated/management_pb';
|
||||
import { AdminService } from 'src/app/services/admin.service';
|
||||
import { MgmtUserService } from 'src/app/services/mgmt-user.service';
|
||||
import { OrgService } from 'src/app/services/org.service';
|
||||
import { ProjectService } from 'src/app/services/project.service';
|
||||
import { ManagementService } from 'src/app/services/mgmt.service';
|
||||
import { ToastService } from 'src/app/services/toast.service';
|
||||
|
||||
import { MembershipDetailDataSource } from './membership-detail-datasource';
|
||||
@@ -38,20 +36,18 @@ export class MembershipDetailComponent implements AfterViewInit {
|
||||
public memberships!: UserMembershipSearchResponse.AsObject;
|
||||
|
||||
constructor(
|
||||
private mgmtUserService: MgmtUserService,
|
||||
activatedRoute: ActivatedRoute,
|
||||
private dialog: MatDialog,
|
||||
private toast: ToastService,
|
||||
private projectService: ProjectService,
|
||||
private orgService: OrgService,
|
||||
private mgmtService: ManagementService,
|
||||
private adminService: AdminService,
|
||||
) {
|
||||
activatedRoute.params.subscribe(data => {
|
||||
const { id } = data;
|
||||
if (id) {
|
||||
this.mgmtUserService.GetUserByID(id).then(user => {
|
||||
this.mgmtService.GetUserByID(id).then(user => {
|
||||
this.user = user.toObject();
|
||||
this.dataSource = new MembershipDetailDataSource(this.mgmtUserService);
|
||||
this.dataSource = new MembershipDetailDataSource(this.mgmtService);
|
||||
this.dataSource.loadMemberships(
|
||||
this.user.id,
|
||||
0,
|
||||
@@ -80,19 +76,6 @@ export class MembershipDetailComponent implements AfterViewInit {
|
||||
);
|
||||
}
|
||||
|
||||
// public removeSelectedMemberships(): void {
|
||||
// Promise.all(this.selection.selected.map(membership => {
|
||||
// switch (membership.memberType) {
|
||||
// case MemberType.MEMBERTYPE_ORGANISATION:
|
||||
// return this.orgService.RemoveMyOrgMember(membership.objectId);
|
||||
// case MemberType.MEMBERTYPE_PROJECT:
|
||||
// return this.projectService.RemoveProjectMember(membership.objectId, this.user.id);
|
||||
// // case MemberType.MEMBERTYPE_PROJECT_GRANT:
|
||||
// // return this.projectService.RemoveProjectGrantMember(membership.objectId, this.user.id);
|
||||
// }
|
||||
// }));
|
||||
// }
|
||||
|
||||
public isAllSelected(): boolean {
|
||||
const numSelected = this.selection.selected.length;
|
||||
const numRows = this.dataSource.membersSubject.value.length;
|
||||
@@ -134,7 +117,7 @@ export class MembershipDetailComponent implements AfterViewInit {
|
||||
}
|
||||
|
||||
public async loadManager(userId: string): Promise<void> {
|
||||
this.mgmtUserService.SearchUserMemberships(userId, 100, 0, []).then(response => {
|
||||
this.mgmtService.SearchUserMemberships(userId, 100, 0, []).then(response => {
|
||||
this.memberships = response.toObject();
|
||||
this.loading = false;
|
||||
});
|
||||
@@ -161,7 +144,7 @@ export class MembershipDetailComponent implements AfterViewInit {
|
||||
|
||||
if (users && users.length && roles && roles.length) {
|
||||
Promise.all(users.map(user => {
|
||||
return this.orgService.AddMyOrgMember(user.id, roles);
|
||||
return this.mgmtService.AddMyOrgMember(user.id, roles);
|
||||
})).then(() => {
|
||||
this.toast.showInfo('ORG.TOAST.MEMBERADDED', true);
|
||||
}).catch(error => {
|
||||
@@ -176,7 +159,7 @@ export class MembershipDetailComponent implements AfterViewInit {
|
||||
|
||||
if (users && users.length && roles && roles.length) {
|
||||
users.forEach(user => {
|
||||
return this.projectService.AddProjectGrantMember(
|
||||
return this.mgmtService.AddProjectGrantMember(
|
||||
response.projectId,
|
||||
response.grantId,
|
||||
user.id,
|
||||
@@ -196,7 +179,7 @@ export class MembershipDetailComponent implements AfterViewInit {
|
||||
|
||||
if (users && users.length && roles && roles.length) {
|
||||
users.forEach(user => {
|
||||
return this.projectService.AddProjectMember(response.projectId, user.id, roles)
|
||||
return this.mgmtService.AddProjectMember(response.projectId, user.id, roles)
|
||||
.then(() => {
|
||||
this.toast.showInfo('PROJECT.TOAST.MEMBERADDED', true);
|
||||
}).catch(error => {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<div class="membership-groups">
|
||||
<span class="header">{{ 'USER.MEMBERSHIPS.TITLE' | translate }}</span>
|
||||
<!-- <span class="sub-header">{{ 'USER,' }}</span> -->
|
||||
<div class="people" *ngIf="memberships">
|
||||
<div class="img-list" [@cardAnimation]="memberships.totalResult">
|
||||
<mat-spinner class="spinner" diameter="20" *ngIf="loading"></mat-spinner>
|
||||
|
||||
@@ -5,9 +5,7 @@ import { Router } from '@angular/router';
|
||||
import { CreationType, MemberCreateDialogComponent } from 'src/app/modules/add-member-dialog/member-create-dialog.component';
|
||||
import { MemberType, UserView, UserMembershipSearchResponse } from 'src/app/proto/generated/management_pb';
|
||||
import { AdminService } from 'src/app/services/admin.service';
|
||||
import { MgmtUserService } from 'src/app/services/mgmt-user.service';
|
||||
import { OrgService } from 'src/app/services/org.service';
|
||||
import { ProjectService } from 'src/app/services/project.service';
|
||||
import { ManagementService } from 'src/app/services/mgmt.service';
|
||||
import { ToastService } from 'src/app/services/toast.service';
|
||||
|
||||
@Component({
|
||||
@@ -39,9 +37,7 @@ export class MembershipsComponent implements OnInit {
|
||||
public MemberType: any = MemberType;
|
||||
|
||||
constructor(
|
||||
private orgService: OrgService,
|
||||
private projectService: ProjectService,
|
||||
private mgmtUserService: MgmtUserService,
|
||||
private mgmtService: ManagementService,
|
||||
private adminService: AdminService,
|
||||
private dialog: MatDialog,
|
||||
private toast: ToastService,
|
||||
@@ -53,7 +49,7 @@ export class MembershipsComponent implements OnInit {
|
||||
}
|
||||
|
||||
public async loadManager(userId: string): Promise<void> {
|
||||
this.mgmtUserService.SearchUserMemberships(userId, 100, 0, []).then(response => {
|
||||
this.mgmtService.SearchUserMemberships(userId, 100, 0, []).then(response => {
|
||||
this.memberships = response.toObject();
|
||||
this.loading = false;
|
||||
});
|
||||
@@ -112,7 +108,7 @@ export class MembershipsComponent implements OnInit {
|
||||
|
||||
if (users && users.length && roles && roles.length) {
|
||||
Promise.all(users.map(user => {
|
||||
return this.orgService.AddMyOrgMember(user.id, roles);
|
||||
return this.mgmtService.AddMyOrgMember(user.id, roles);
|
||||
})).then(() => {
|
||||
this.toast.showInfo('ORG.TOAST.MEMBERADDED', true);
|
||||
}).catch(error => {
|
||||
@@ -127,7 +123,7 @@ export class MembershipsComponent implements OnInit {
|
||||
|
||||
if (users && users.length && roles && roles.length) {
|
||||
users.forEach(user => {
|
||||
return this.projectService.AddProjectGrantMember(
|
||||
return this.mgmtService.AddProjectGrantMember(
|
||||
response.projectId,
|
||||
response.grantId,
|
||||
user.id,
|
||||
@@ -147,7 +143,7 @@ export class MembershipsComponent implements OnInit {
|
||||
|
||||
if (users && users.length && roles && roles.length) {
|
||||
users.forEach(user => {
|
||||
return this.projectService.AddProjectMember(response.projectId, user.id, roles)
|
||||
return this.mgmtService.AddProjectMember(response.projectId, user.id, roles)
|
||||
.then(() => {
|
||||
this.toast.showInfo('PROJECT.TOAST.MEMBERADDED', true);
|
||||
}).catch(error => {
|
||||
|
||||
@@ -4,8 +4,8 @@ import { ActivatedRoute } from '@angular/router';
|
||||
import { Subscription } from 'rxjs';
|
||||
import { lowerCaseValidator, numberValidator, symbolValidator, upperCaseValidator } from 'src/app/pages/validators';
|
||||
import { PasswordComplexityPolicy } from 'src/app/proto/generated/auth_pb';
|
||||
import { AuthUserService } from 'src/app/services/auth-user.service';
|
||||
import { MgmtUserService } from 'src/app/services/mgmt-user.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';
|
||||
|
||||
function passwordConfirmValidator(c: AbstractControl): any {
|
||||
@@ -39,11 +39,10 @@ export class PasswordComponent implements OnDestroy {
|
||||
constructor(
|
||||
activatedRoute: ActivatedRoute,
|
||||
private fb: FormBuilder,
|
||||
private userService: AuthUserService,
|
||||
private mgmtUserService: MgmtUserService,
|
||||
private authService: GrpcAuthService,
|
||||
private mgmtUserService: ManagementService,
|
||||
private toast: ToastService,
|
||||
) {
|
||||
|
||||
activatedRoute.params.subscribe(data => {
|
||||
const { id } = data;
|
||||
if (id) {
|
||||
@@ -51,7 +50,7 @@ export class PasswordComponent implements OnDestroy {
|
||||
}
|
||||
|
||||
const validators: Validators[] = [Validators.required];
|
||||
this.userService.GetMyPasswordComplexityPolicy().then(complexity => {
|
||||
this.authService.GetMyPasswordComplexityPolicy().then(complexity => {
|
||||
this.policy = complexity.toObject();
|
||||
if (this.policy.minLength) {
|
||||
validators.push(Validators.minLength(this.policy.minLength));
|
||||
@@ -110,8 +109,8 @@ export class PasswordComponent implements OnDestroy {
|
||||
if (this.passwordForm.valid && this.currentPassword &&
|
||||
this.currentPassword.value &&
|
||||
this.newPassword && this.newPassword.value && this.newPassword.valid) {
|
||||
this.userService
|
||||
.ChangeMyPassword(this.currentPassword.value, this.newPassword.value).then((data: any) => {
|
||||
this.authService.ChangeMyPassword(this.currentPassword.value, this.newPassword.value)
|
||||
.then((data: any) => {
|
||||
this.toast.showInfo('USER.TOAST.PASSWORDCHANGED', true);
|
||||
window.history.back();
|
||||
}).catch(error => {
|
||||
|
||||
@@ -13,8 +13,7 @@ import {
|
||||
UserState,
|
||||
UserView,
|
||||
} from 'src/app/proto/generated/management_pb';
|
||||
import { MgmtUserService } from 'src/app/services/mgmt-user.service';
|
||||
import { ProjectService } from 'src/app/services/project.service';
|
||||
import { ManagementService } from 'src/app/services/mgmt.service';
|
||||
import { ToastService } from 'src/app/services/toast.service';
|
||||
|
||||
@Component({
|
||||
@@ -41,9 +40,9 @@ export class UserDetailComponent implements OnInit, OnDestroy {
|
||||
public translate: TranslateService,
|
||||
private route: ActivatedRoute,
|
||||
private toast: ToastService,
|
||||
private mgmtUserService: MgmtUserService,
|
||||
private mgmtUserService: ManagementService,
|
||||
private _location: Location,
|
||||
public projectService: ProjectService,
|
||||
public mgmtService: ManagementService,
|
||||
) { }
|
||||
|
||||
public ngOnInit(): void {
|
||||
|
||||
@@ -3,7 +3,7 @@ import { MatSort } from '@angular/material/sort';
|
||||
import { MatTable, MatTableDataSource } from '@angular/material/table';
|
||||
import { BehaviorSubject, Observable } from 'rxjs';
|
||||
import { MFAState, MfaType, MultiFactor, UserView } from 'src/app/proto/generated/management_pb';
|
||||
import { MgmtUserService } from 'src/app/services/mgmt-user.service';
|
||||
import { ManagementService } from 'src/app/services/mgmt.service';
|
||||
|
||||
|
||||
export interface MFAItem {
|
||||
@@ -31,7 +31,7 @@ export class UserMfaComponent implements OnInit, OnDestroy {
|
||||
public MFAState: any = MFAState;
|
||||
|
||||
public error: string = '';
|
||||
constructor(private mgmtUserService: MgmtUserService) { }
|
||||
constructor(private mgmtUserService: ManagementService) { }
|
||||
|
||||
public ngOnInit(): void {
|
||||
this.getOTP();
|
||||
|
||||
@@ -6,7 +6,7 @@ import { ActivatedRoute } from '@angular/router';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { BehaviorSubject, Observable, Subscription } from 'rxjs';
|
||||
import { User, UserSearchResponse } from 'src/app/proto/generated/management_pb';
|
||||
import { MgmtUserService } from 'src/app/services/mgmt-user.service';
|
||||
import { ManagementService } from 'src/app/services/mgmt.service';
|
||||
import { ToastService } from 'src/app/services/toast.service';
|
||||
|
||||
@Component({
|
||||
@@ -26,7 +26,7 @@ export class UserListComponent implements OnDestroy {
|
||||
|
||||
private subscription?: Subscription;
|
||||
|
||||
constructor(public translate: TranslateService, private route: ActivatedRoute, private userService: MgmtUserService,
|
||||
constructor(public translate: TranslateService, private route: ActivatedRoute, private userService: ManagementService,
|
||||
private toast: ToastService) {
|
||||
this.subscription = this.route.params.subscribe(() => this.getData(10, 0));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user