mirror of
https://github.com/zitadel/zitadel.git
synced 2025-02-28 23:37:23 +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:
parent
40b8faaddd
commit
eeea1f1c4b
@ -52,7 +52,7 @@
|
||||
[opened]="!(isHandset$ | async)">
|
||||
<div class="side-column">
|
||||
<div class="list">
|
||||
<ng-container *ngIf="authService.authenticationChanged | async">
|
||||
<ng-container *ngIf="authenticationService.authenticationChanged | async">
|
||||
<a @navitem class="nav-item" [routerLinkActive]="['active']"
|
||||
[routerLinkActiveOptions]="{ exact: true }" [routerLink]="['/users/me']">
|
||||
<i class="icon las la-user-circle"></i>
|
||||
|
@ -12,9 +12,9 @@ import { map } from 'rxjs/operators';
|
||||
|
||||
import { accountCard, navAnimations, routeAnimations, toolbarAnimation } from './animations';
|
||||
import { Org, UserProfileView } from './proto/generated/auth_pb';
|
||||
import { AuthUserService } from './services/auth-user.service';
|
||||
import { AuthService } from './services/auth.service';
|
||||
import { ProjectService } from './services/project.service';
|
||||
import { AuthenticationService } from './services/authentication.service';
|
||||
import { GrpcAuthService } from './services/grpc-auth.service';
|
||||
import { ManagementService } from './services/mgmt.service';
|
||||
import { ThemeService } from './services/theme.service';
|
||||
import { ToastService } from './services/toast.service';
|
||||
import { UpdateService } from './services/update.service';
|
||||
@ -31,8 +31,7 @@ import { UpdateService } from './services/update.service';
|
||||
],
|
||||
})
|
||||
export class AppComponent implements OnDestroy {
|
||||
@ViewChild('drawer')
|
||||
public drawer!: MatDrawer;
|
||||
@ViewChild('drawer') public drawer!: MatDrawer;
|
||||
public isHandset$: Observable<boolean> = this.breakpointObserver
|
||||
.observe('(max-width: 599px)')
|
||||
.pipe(map(result => {
|
||||
@ -60,12 +59,12 @@ export class AppComponent implements OnDestroy {
|
||||
public viewPortScroller: ViewportScroller,
|
||||
@Inject('windowObject') public window: Window,
|
||||
public translate: TranslateService,
|
||||
public authService: AuthService,
|
||||
public authenticationService: AuthenticationService,
|
||||
public authService: GrpcAuthService,
|
||||
private breakpointObserver: BreakpointObserver,
|
||||
public overlayContainer: OverlayContainer,
|
||||
private themeService: ThemeService,
|
||||
public userService: AuthUserService,
|
||||
private projectService: ProjectService,
|
||||
private mgmtService: ManagementService,
|
||||
public matIconRegistry: MatIconRegistry,
|
||||
public domSanitizer: DomSanitizer,
|
||||
private toast: ToastService,
|
||||
@ -145,7 +144,7 @@ export class AppComponent implements OnDestroy {
|
||||
this.getProjectCount();
|
||||
});
|
||||
|
||||
this.authSub = this.authService.authenticationChanged.subscribe((authenticated) => {
|
||||
this.authSub = this.authenticationService.authenticationChanged.subscribe((authenticated) => {
|
||||
if (authenticated) {
|
||||
this.authService.GetActiveOrg().then(org => {
|
||||
this.org = org;
|
||||
@ -170,7 +169,7 @@ export class AppComponent implements OnDestroy {
|
||||
|
||||
public loadOrgs(): void {
|
||||
this.orgLoading = true;
|
||||
this.userService.SearchMyProjectOrgs(10, 0).then(res => {
|
||||
this.authService.SearchMyProjectOrgs(10, 0).then(res => {
|
||||
this.orgs = res.toObject().resultList;
|
||||
this.orgLoading = false;
|
||||
}).catch(error => {
|
||||
@ -215,11 +214,11 @@ export class AppComponent implements OnDestroy {
|
||||
private getProjectCount(): void {
|
||||
this.authService.isAllowed(['project.read']).subscribe((allowed) => {
|
||||
if (allowed) {
|
||||
this.projectService.SearchProjects(0, 0).then(res => {
|
||||
this.mgmtService.SearchProjects(0, 0).then(res => {
|
||||
this.ownedProjectsCount = res.toObject().totalResult;
|
||||
});
|
||||
|
||||
this.projectService.SearchGrantedProjects(0, 0).then(res => {
|
||||
this.mgmtService.SearchGrantedProjects(0, 0).then(res => {
|
||||
this.grantedProjectsCount = res.toObject().totalResult;
|
||||
});
|
||||
}
|
||||
|
@ -32,12 +32,11 @@ import { AvatarModule } from './modules/avatar/avatar.module';
|
||||
import { WarnDialogModule } from './modules/warn-dialog/warn-dialog.module';
|
||||
import { SignedoutComponent } from './pages/signedout/signedout.component';
|
||||
import { HasRolePipeModule } from './pipes/has-role-pipe.module';
|
||||
import { AuthUserService } from './services/auth-user.service';
|
||||
import { AuthService } from './services/auth.service';
|
||||
import { GrpcAuthService } from './services/grpc-auth.service';
|
||||
import { GrpcService } from './services/grpc.service';
|
||||
import { GrpcAuthInterceptor } from './services/interceptors/grpc-auth.interceptor';
|
||||
import { AuthInterceptor } from './services/interceptors/auth.interceptor';
|
||||
import { GRPC_INTERCEPTORS } from './services/interceptors/grpc-interceptor';
|
||||
import { GrpcOrgInterceptor } from './services/interceptors/grpc-org.interceptor';
|
||||
import { OrgInterceptor } from './services/interceptors/org.interceptor';
|
||||
import { StatehandlerProcessorService, StatehandlerProcessorServiceImpl } from './services/statehandler-processor.service';
|
||||
import { StatehandlerService, StatehandlerServiceImpl } from './services/statehandler.service';
|
||||
import { StorageService } from './services/storage.service';
|
||||
@ -146,21 +145,20 @@ const authConfig: AuthConfig = {
|
||||
{
|
||||
provide: GRPC_INTERCEPTORS,
|
||||
multi: true,
|
||||
useClass: GrpcAuthInterceptor,
|
||||
useClass: AuthInterceptor,
|
||||
},
|
||||
{
|
||||
provide: GRPC_INTERCEPTORS,
|
||||
multi: true,
|
||||
useClass: GrpcOrgInterceptor,
|
||||
useClass: OrgInterceptor,
|
||||
},
|
||||
GrpcService,
|
||||
AuthService,
|
||||
AuthUserService,
|
||||
GrpcAuthService,
|
||||
{ provide: 'windowObject', useValue: window },
|
||||
],
|
||||
bootstrap: [AppComponent],
|
||||
})
|
||||
export class AppModule {
|
||||
|
||||
export class AppModule {
|
||||
constructor() { }
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { Directive, Input, TemplateRef, ViewContainerRef } from '@angular/core';
|
||||
import { AuthService } from 'src/app/services/auth.service';
|
||||
import { GrpcAuthService } from 'src/app/services/grpc-auth.service';
|
||||
|
||||
|
||||
@Directive({
|
||||
@ -23,7 +23,7 @@ export class HasRoleDirective {
|
||||
}
|
||||
|
||||
constructor(
|
||||
private authService: AuthService,
|
||||
private authService: GrpcAuthService,
|
||||
protected templateRef: TemplateRef<any>,
|
||||
protected viewContainerRef: ViewContainerRef,
|
||||
) { }
|
||||
|
@ -2,14 +2,14 @@ import { Injectable } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot, CanActivate, RouterStateSnapshot } from '@angular/router';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
import { AuthService } from '../services/auth.service';
|
||||
import { AuthenticationService } from '../services/authentication.service';
|
||||
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class AuthGuard implements CanActivate {
|
||||
constructor(private auth: AuthService) { }
|
||||
constructor(private auth: AuthenticationService) { }
|
||||
|
||||
public canActivate(
|
||||
_: ActivatedRouteSnapshot,
|
||||
|
@ -2,14 +2,14 @@ import { Injectable } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot, CanActivate, RouterStateSnapshot } from '@angular/router';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
import { AuthService } from '../services/auth.service';
|
||||
import { GrpcAuthService } from '../services/grpc-auth.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class RoleGuard implements CanActivate {
|
||||
|
||||
constructor(private authService: AuthService) { }
|
||||
constructor(private authService: GrpcAuthService) { }
|
||||
|
||||
public canActivate(
|
||||
route: ActivatedRouteSnapshot,
|
||||
|
@ -2,8 +2,8 @@ import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import { AuthConfig } from 'angular-oauth2-oidc';
|
||||
import { UserProfileView, UserSessionView } from 'src/app/proto/generated/auth_pb';
|
||||
import { AuthUserService } from 'src/app/services/auth-user.service';
|
||||
import { AuthService } from 'src/app/services/auth.service';
|
||||
import { AuthenticationService } from 'src/app/services/authentication.service';
|
||||
import { GrpcAuthService } from 'src/app/services/grpc-auth.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-accounts-card',
|
||||
@ -17,7 +17,7 @@ export class AccountsCardComponent implements OnInit {
|
||||
@Output() public close: EventEmitter<void> = new EventEmitter();
|
||||
public users: UserSessionView.AsObject[] = [];
|
||||
public loadingUsers: boolean = false;
|
||||
constructor(public authService: AuthService, private router: Router, private userService: AuthUserService) {
|
||||
constructor(public authService: AuthenticationService, private router: Router, private userService: GrpcAuthService) {
|
||||
this.userService.getMyUserSessions().then(sessions => {
|
||||
this.users = sessions.toObject().userSessionsList;
|
||||
const index = this.users.findIndex(user => user.loginName === this.profile.preferredLoginName);
|
||||
|
@ -2,7 +2,7 @@ import { Component, Inject } from '@angular/core';
|
||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||
import { ProjectGrantView, ProjectRole, ProjectView, UserView } from 'src/app/proto/generated/management_pb';
|
||||
import { AdminService } from 'src/app/services/admin.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 { ProjectAutocompleteType } from '../search-project-autocomplete/search-project-autocomplete.component';
|
||||
@ -39,7 +39,7 @@ export class MemberCreateDialogComponent {
|
||||
|
||||
public showCreationTypeSelector: boolean = false;
|
||||
constructor(
|
||||
private projectService: ProjectService,
|
||||
private mgmtService: ManagementService,
|
||||
private adminService: AdminService,
|
||||
public dialogRef: MatDialogRef<MemberCreateDialogComponent>,
|
||||
@Inject(MAT_DIALOG_DATA) public data: any,
|
||||
@ -64,14 +64,14 @@ export class MemberCreateDialogComponent {
|
||||
public loadRoles(): void {
|
||||
switch (this.creationType) {
|
||||
case CreationType.PROJECT_GRANTED:
|
||||
this.projectService.GetProjectGrantMemberRoles().then(resp => {
|
||||
this.mgmtService.GetProjectGrantMemberRoles().then(resp => {
|
||||
this.memberRoleOptions = resp.toObject().rolesList;
|
||||
}).catch(error => {
|
||||
this.toastService.showError(error);
|
||||
});
|
||||
break;
|
||||
case CreationType.PROJECT_OWNED:
|
||||
this.projectService.GetProjectMemberRoles().then(resp => {
|
||||
this.mgmtService.GetProjectMemberRoles().then(resp => {
|
||||
this.memberRoleOptions = resp.toObject().rolesList;
|
||||
}).catch(error => {
|
||||
this.toastService.showError(error);
|
||||
|
@ -2,8 +2,8 @@ import { Component, Input, OnInit } from '@angular/core';
|
||||
import { BehaviorSubject, from, Observable, of } from 'rxjs';
|
||||
import { catchError, scan, take, tap } from 'rxjs/operators';
|
||||
import { Change, Changes } from 'src/app/proto/generated/management_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';
|
||||
|
||||
export enum ChangeType {
|
||||
MYUSER = 'myuser',
|
||||
@ -30,7 +30,7 @@ export class ChangesComponent implements OnInit {
|
||||
loading: Observable<boolean> = this._loading.asObservable();
|
||||
public data!: Observable<Change.AsObject[]>;
|
||||
public changes!: Changes.AsObject;
|
||||
constructor(private mgmtUserService: MgmtUserService, private authUserService: AuthUserService) { }
|
||||
constructor(private mgmtUserService: ManagementService, private authUserService: GrpcAuthService) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
this.init();
|
||||
|
@ -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 { ProjectMember, ProjectMemberSearchResponse, ProjectType } from 'src/app/proto/generated/management_pb';
|
||||
import { ProjectService } from 'src/app/services/project.service';
|
||||
import { ManagementService } from 'src/app/services/mgmt.service';
|
||||
|
||||
/**
|
||||
* Data source for the ProjectMembers view. This class should
|
||||
@ -18,7 +18,7 @@ export class ProjectMembersDataSource extends DataSource<ProjectMember.AsObject>
|
||||
private loadingSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
|
||||
public loading$: Observable<boolean> = this.loadingSubject.asObservable();
|
||||
|
||||
constructor(private projectService: ProjectService) {
|
||||
constructor(private mgmtService: ManagementService) {
|
||||
super();
|
||||
}
|
||||
|
||||
@ -31,9 +31,9 @@ export class ProjectMembersDataSource extends DataSource<ProjectMember.AsObject>
|
||||
|
||||
const promise: Promise<ProjectMemberSearchResponse> | undefined =
|
||||
projectType === ProjectType.PROJECTTYPE_OWNED ?
|
||||
this.projectService.SearchProjectMembers(projectId, pageSize, offset) :
|
||||
this.mgmtService.SearchProjectMembers(projectId, pageSize, offset) :
|
||||
projectType === ProjectType.PROJECTTYPE_GRANTED && grantId ?
|
||||
this.projectService.SearchProjectGrantMembers(projectId,
|
||||
this.mgmtService.SearchProjectGrantMembers(projectId,
|
||||
grantId, pageSize, offset) : undefined;
|
||||
if (promise) {
|
||||
from(promise).pipe(
|
||||
|
@ -7,7 +7,7 @@ import { MatTable } from '@angular/material/table';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { take } from 'rxjs/operators';
|
||||
import { ProjectGrantView, ProjectMember, ProjectType, ProjectView, UserView } from 'src/app/proto/generated/management_pb';
|
||||
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 { CreationType, MemberCreateDialogComponent } from '../add-member-dialog/member-create-dialog.component';
|
||||
@ -36,7 +36,7 @@ export class ProjectMembersComponent {
|
||||
public displayedColumns: string[] = ['select', 'userId', 'firstname', 'lastname', 'username', 'email', 'roles'];
|
||||
|
||||
constructor(
|
||||
private projectService: ProjectService,
|
||||
private mgmtService: ManagementService,
|
||||
private dialog: MatDialog,
|
||||
private toast: ToastService,
|
||||
private route: ActivatedRoute) {
|
||||
@ -48,17 +48,17 @@ export class ProjectMembersComponent {
|
||||
this.route.params.subscribe(params => {
|
||||
this.grantId = params.grantid;
|
||||
if (this.projectType === ProjectType.PROJECTTYPE_OWNED) {
|
||||
this.projectService.GetProjectById(params.projectid).then(project => {
|
||||
this.mgmtService.GetProjectById(params.projectid).then(project => {
|
||||
this.project = project.toObject();
|
||||
this.projectName = this.project.name;
|
||||
this.dataSource = new ProjectMembersDataSource(this.projectService);
|
||||
this.dataSource = new ProjectMembersDataSource(this.mgmtService);
|
||||
this.dataSource.loadMembers(this.project.projectId, this.projectType, 0, this.INITIALPAGESIZE);
|
||||
});
|
||||
} else if (this.projectType === ProjectType.PROJECTTYPE_GRANTED) {
|
||||
this.projectService.GetGrantedProjectByID(params.projectid, params.grantid).then(project => {
|
||||
this.mgmtService.GetGrantedProjectByID(params.projectid, params.grantid).then(project => {
|
||||
this.project = project.toObject();
|
||||
this.projectName = this.project.projectName;
|
||||
this.dataSource = new ProjectMembersDataSource(this.projectService);
|
||||
this.dataSource = new ProjectMembersDataSource(this.mgmtService);
|
||||
this.dataSource.loadMembers(this.project.projectId,
|
||||
this.projectType,
|
||||
0,
|
||||
@ -73,13 +73,13 @@ export class ProjectMembersComponent {
|
||||
|
||||
public getRoleOptions(): void {
|
||||
if (this.projectType === ProjectType.PROJECTTYPE_GRANTED) {
|
||||
this.projectService.GetProjectGrantMemberRoles().then(resp => {
|
||||
this.mgmtService.GetProjectGrantMemberRoles().then(resp => {
|
||||
this.memberRoleOptions = resp.toObject().rolesList;
|
||||
}).catch(error => {
|
||||
this.toast.showError(error);
|
||||
});
|
||||
} else if (this.projectType === ProjectType.PROJECTTYPE_OWNED) {
|
||||
this.projectService.GetProjectMemberRoles().then(resp => {
|
||||
this.mgmtService.GetProjectMemberRoles().then(resp => {
|
||||
this.memberRoleOptions = resp.toObject().rolesList;
|
||||
}).catch(error => {
|
||||
this.toast.showError(error);
|
||||
@ -90,13 +90,13 @@ export class ProjectMembersComponent {
|
||||
public removeProjectMemberSelection(): void {
|
||||
Promise.all(this.selection.selected.map(member => {
|
||||
if (this.projectType === ProjectType.PROJECTTYPE_OWNED) {
|
||||
return this.projectService.RemoveProjectMember(this.project.projectId, member.userId).then(() => {
|
||||
return this.mgmtService.RemoveProjectMember(this.project.projectId, member.userId).then(() => {
|
||||
this.toast.showInfo('PROJECT.TOAST.MEMBERREMOVED', true);
|
||||
}).catch(error => {
|
||||
this.toast.showError(error);
|
||||
});
|
||||
} else if (this.projectType === ProjectType.PROJECTTYPE_GRANTED) {
|
||||
return this.projectService.RemoveProjectGrantMember(this.project.projectId, this.grantId,
|
||||
return this.mgmtService.RemoveProjectGrantMember(this.project.projectId, this.grantId,
|
||||
member.userId).then(() => {
|
||||
this.toast.showInfo('PROJECT.TOAST.MEMBERREMOVED', true);
|
||||
}).catch(error => {
|
||||
@ -134,10 +134,10 @@ export class ProjectMembersComponent {
|
||||
if (users && users.length && roles && roles.length) {
|
||||
Promise.all(users.map(user => {
|
||||
if (this.projectType === ProjectType.PROJECTTYPE_OWNED) {
|
||||
return this.projectService.AddProjectMember(this.project.projectId, user.id, roles);
|
||||
return this.mgmtService.AddProjectMember(this.project.projectId, user.id, roles);
|
||||
|
||||
} else if (this.projectType === ProjectType.PROJECTTYPE_GRANTED) {
|
||||
return this.projectService.AddProjectGrantMember(this.project.projectId, this.grantId,
|
||||
return this.mgmtService.AddProjectGrantMember(this.project.projectId, this.grantId,
|
||||
user.id, roles);
|
||||
}
|
||||
})).then(() => {
|
||||
@ -152,14 +152,14 @@ export class ProjectMembersComponent {
|
||||
|
||||
updateRoles(member: ProjectMember.AsObject, selectionChange: MatSelectChange): void {
|
||||
if (this.projectType === ProjectType.PROJECTTYPE_OWNED) {
|
||||
this.projectService.ChangeProjectMember(this.project.projectId, member.userId, selectionChange.value)
|
||||
this.mgmtService.ChangeProjectMember(this.project.projectId, member.userId, selectionChange.value)
|
||||
.then((newmember: ProjectMember) => {
|
||||
this.toast.showInfo('PROJECT.TOAST.MEMBERCHANGED', true);
|
||||
}).catch(error => {
|
||||
this.toast.showError(error);
|
||||
});
|
||||
} else if (this.projectType === ProjectType.PROJECTTYPE_GRANTED) {
|
||||
this.projectService.ChangeProjectGrantMember(this.project.projectId,
|
||||
this.mgmtService.ChangeProjectGrantMember(this.project.projectId,
|
||||
this.grantId, member.userId, selectionChange.value)
|
||||
.then((newmember: ProjectMember) => {
|
||||
this.toast.showInfo('PROJECT.TOAST.MEMBERCHANGED', true);
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { Component, Inject, OnInit } from '@angular/core';
|
||||
import { AbstractControl, FormControl, FormGroup, Validators } from '@angular/forms';
|
||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||
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({
|
||||
@ -13,7 +13,7 @@ export class ProjectRoleDetailComponent implements OnInit {
|
||||
public projectId: string = '';
|
||||
|
||||
public formGroup!: FormGroup;
|
||||
constructor(private projectService: ProjectService, private toast: ToastService,
|
||||
constructor(private mgmtService: ManagementService, private toast: ToastService,
|
||||
public dialogRef: MatDialogRef<ProjectRoleDetailComponent>,
|
||||
@Inject(MAT_DIALOG_DATA) public data: any) {
|
||||
|
||||
@ -32,7 +32,7 @@ export class ProjectRoleDetailComponent implements OnInit {
|
||||
|
||||
submitForm(): void {
|
||||
if (this.formGroup.valid && this.key?.value && this.group?.value && this.displayName?.value) {
|
||||
this.projectService.ChangeProjectRole(this.projectId, this.key.value, this.key.value, this.group.value)
|
||||
this.mgmtService.ChangeProjectRole(this.projectId, this.key.value, this.key.value, this.group.value)
|
||||
.then(() => {
|
||||
this.toast.showInfo('PROJECT.TOAST.ROLECHANGED', true);
|
||||
this.dialogRef.close(true);
|
||||
|
@ -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 { ProjectRole } from 'src/app/proto/generated/management_pb';
|
||||
import { ProjectService } from 'src/app/services/project.service';
|
||||
import { ManagementService } from 'src/app/services/mgmt.service';
|
||||
|
||||
/**
|
||||
* Data source for the ProjectMembers view. This class should
|
||||
@ -18,7 +18,7 @@ export class ProjectRolesDataSource extends DataSource<ProjectRole.AsObject> {
|
||||
private loadingSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
|
||||
public loading$: Observable<boolean> = this.loadingSubject.asObservable();
|
||||
|
||||
constructor(private projectService: ProjectService) {
|
||||
constructor(private mgmtService: ManagementService) {
|
||||
super();
|
||||
}
|
||||
|
||||
@ -26,7 +26,7 @@ export class ProjectRolesDataSource extends DataSource<ProjectRole.AsObject> {
|
||||
const offset = pageIndex * pageSize;
|
||||
|
||||
this.loadingSubject.next(true);
|
||||
from(this.projectService.SearchProjectRoles(projectId, pageSize, offset)).pipe(
|
||||
from(this.mgmtService.SearchProjectRoles(projectId, pageSize, offset)).pipe(
|
||||
map(resp => {
|
||||
const response = resp.toObject();
|
||||
this.totalResult = response.totalResult;
|
||||
|
@ -5,7 +5,7 @@ import { MatPaginator } from '@angular/material/paginator';
|
||||
import { MatTable } from '@angular/material/table';
|
||||
import { tap } from 'rxjs/operators';
|
||||
import { ProjectRole } from 'src/app/proto/generated/management_pb';
|
||||
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 { ProjectRoleDetailComponent } from './project-role-detail/project-role-detail.component';
|
||||
@ -30,8 +30,8 @@ export class ProjectRolesComponent implements AfterViewInit, OnInit {
|
||||
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
|
||||
public displayedColumns: string[] = ['select', 'key', 'displayname', 'group', 'creationDate'];
|
||||
|
||||
constructor(private projectService: ProjectService, private toast: ToastService, private dialog: MatDialog) {
|
||||
this.dataSource = new ProjectRolesDataSource(this.projectService);
|
||||
constructor(private mgmtService: ManagementService, private toast: ToastService, private dialog: MatDialog) {
|
||||
this.dataSource = new ProjectRolesDataSource(this.mgmtService);
|
||||
}
|
||||
|
||||
public ngOnInit(): void {
|
||||
@ -83,7 +83,7 @@ export class ProjectRolesComponent implements AfterViewInit, OnInit {
|
||||
});
|
||||
|
||||
return Promise.all(this.selection.selected.map(role => {
|
||||
return this.projectService.RemoveProjectRole(role.projectId, role.key);
|
||||
return this.mgmtService.RemoveProjectRole(role.projectId, role.key);
|
||||
})).then(() => {
|
||||
this.toast.showInfo('PROJECT.TOAST.ROLEREMOVED', true);
|
||||
indexes.forEach(index => {
|
||||
@ -99,7 +99,7 @@ export class ProjectRolesComponent implements AfterViewInit, OnInit {
|
||||
}
|
||||
|
||||
public removeRole(role: ProjectRole.AsObject, index: number): void {
|
||||
this.projectService
|
||||
this.mgmtService
|
||||
.RemoveProjectRole(role.projectId, role.key)
|
||||
.then(() => {
|
||||
this.toast.showInfo('PROJECT.TOAST.ROLEREMOVED', true);
|
||||
|
@ -14,7 +14,7 @@ import {
|
||||
ProjectView,
|
||||
SearchMethod,
|
||||
} from 'src/app/proto/generated/management_pb';
|
||||
import { ProjectService } from 'src/app/services/project.service';
|
||||
import { ManagementService } from 'src/app/services/mgmt.service';
|
||||
|
||||
|
||||
export enum ProjectAutocompleteType {
|
||||
@ -47,7 +47,7 @@ export class SearchProjectAutocompleteComponent {
|
||||
| ProjectView.AsObject
|
||||
| ProjectView.AsObject[]
|
||||
> = new EventEmitter();
|
||||
constructor(private projectService: ProjectService) {
|
||||
constructor(private mgmtService: ManagementService) {
|
||||
this.myControl.valueChanges
|
||||
.pipe(
|
||||
debounceTime(200),
|
||||
@ -60,13 +60,13 @@ export class SearchProjectAutocompleteComponent {
|
||||
|
||||
switch (this.autocompleteType) {
|
||||
case ProjectAutocompleteType.PROJECT_GRANTED:
|
||||
return from(this.projectService.SearchGrantedProjects(10, 0, [query]));
|
||||
return from(this.mgmtService.SearchGrantedProjects(10, 0, [query]));
|
||||
case ProjectAutocompleteType.PROJECT_OWNED:
|
||||
return from(this.projectService.SearchProjects(10, 0, [query]));
|
||||
return from(this.mgmtService.SearchProjects(10, 0, [query]));
|
||||
default:
|
||||
return forkJoin([
|
||||
from(this.projectService.SearchGrantedProjects(10, 0, [query])),
|
||||
from(this.projectService.SearchProjects(10, 0, [query])),
|
||||
from(this.mgmtService.SearchGrantedProjects(10, 0, [query])),
|
||||
from(this.mgmtService.SearchProjects(10, 0, [query])),
|
||||
]);
|
||||
}
|
||||
}),
|
||||
|
@ -11,7 +11,7 @@ import {
|
||||
ProjectRoleSearchQuery,
|
||||
SearchMethod,
|
||||
} from 'src/app/proto/generated/management_pb';
|
||||
import { ProjectService } from 'src/app/services/project.service';
|
||||
import { ManagementService } from 'src/app/services/mgmt.service';
|
||||
import { ToastService } from 'src/app/services/toast.service';
|
||||
|
||||
|
||||
@ -35,7 +35,7 @@ export class SearchRolesAutocompleteComponent {
|
||||
@Input() public projectId: string = '';
|
||||
@Input() public singleOutput: boolean = false;
|
||||
@Output() public selectionChanged: EventEmitter<ProjectRole.AsObject[] | ProjectRole.AsObject> = new EventEmitter();
|
||||
constructor(private projectService: ProjectService, private toast: ToastService) {
|
||||
constructor(private mgmtService: ManagementService, private toast: ToastService) {
|
||||
this.myControl.valueChanges
|
||||
.pipe(
|
||||
debounceTime(200),
|
||||
@ -45,7 +45,7 @@ export class SearchRolesAutocompleteComponent {
|
||||
query.setKey(ProjectRoleSearchKey.PROJECTROLESEARCHKEY_DISPLAY_NAME);
|
||||
query.setMethod(SearchMethod.SEARCHMETHOD_CONTAINS_IGNORE_CASE);
|
||||
query.setValue(value);
|
||||
return from(this.projectService.SearchProjectRoles(this.projectId, 10, 0, [query]));
|
||||
return from(this.mgmtService.SearchProjectRoles(this.projectId, 10, 0, [query]));
|
||||
}),
|
||||
).subscribe((roles) => {
|
||||
this.isLoading = false;
|
||||
|
@ -5,8 +5,8 @@ import { MatAutocomplete, MatAutocompleteSelectedEvent } from '@angular/material
|
||||
import { MatChipInputEvent } from '@angular/material/chips';
|
||||
import { from, of, Subject } from 'rxjs';
|
||||
import { debounceTime, switchMap, takeUntil, tap } from 'rxjs/operators';
|
||||
import { SearchMethod, UserView, UserSearchKey, UserSearchQuery } from 'src/app/proto/generated/management_pb';
|
||||
import { MgmtUserService } from 'src/app/services/mgmt-user.service';
|
||||
import { SearchMethod, UserSearchKey, UserSearchQuery, UserView } from 'src/app/proto/generated/management_pb';
|
||||
import { ManagementService } from 'src/app/services/mgmt.service';
|
||||
import { ToastService } from 'src/app/services/toast.service';
|
||||
|
||||
export enum UserTarget {
|
||||
@ -41,7 +41,7 @@ export class SearchUserAutocompleteComponent {
|
||||
@Input() public singleOutput: boolean = false;
|
||||
|
||||
private unsubscribed$: Subject<void> = new Subject();
|
||||
constructor(private userService: MgmtUserService, private toast: ToastService) {
|
||||
constructor(private userService: ManagementService, private toast: ToastService) {
|
||||
this.getFilteredResults();
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@ import {
|
||||
UserGrantSearchResponse,
|
||||
UserGrantView,
|
||||
} 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 enum UserGrantContext {
|
||||
// AUTHUSER = 'authuser',
|
||||
@ -27,7 +27,7 @@ export class UserGrantsDataSource extends DataSource<UserGrant.AsObject> {
|
||||
private loadingSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
|
||||
public loading$: Observable<boolean> = this.loadingSubject.asObservable();
|
||||
|
||||
constructor(private userService: MgmtUserService) {
|
||||
constructor(private userService: ManagementService) {
|
||||
super();
|
||||
}
|
||||
|
||||
|
@ -12,8 +12,7 @@ import {
|
||||
UserGrantSearchQuery,
|
||||
UserGrantView,
|
||||
} 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';
|
||||
|
||||
import { UserGrantContext, UserGrantsDataSource } from './user-grants-datasource';
|
||||
@ -51,8 +50,8 @@ export class UserGrantsComponent implements OnInit, AfterViewInit {
|
||||
public UserGrantContext: any = UserGrantContext;
|
||||
|
||||
constructor(
|
||||
private userService: MgmtUserService,
|
||||
private projectService: ProjectService,
|
||||
private userService: ManagementService,
|
||||
private mgmtService: ManagementService,
|
||||
private toast: ToastService,
|
||||
) { }
|
||||
|
||||
@ -125,7 +124,7 @@ export class UserGrantsComponent implements OnInit, AfterViewInit {
|
||||
}
|
||||
|
||||
public getGrantRoleOptions(grantId: string, projectId: string): void {
|
||||
this.projectService.GetGrantedProjectByID(projectId, grantId).then(resp => {
|
||||
this.mgmtService.GetGrantedProjectByID(projectId, grantId).then(resp => {
|
||||
this.loadedGrantId = projectId;
|
||||
this.grantRoleOptions = resp.toObject().roleKeysList;
|
||||
}).catch(error => {
|
||||
@ -134,7 +133,7 @@ export class UserGrantsComponent implements OnInit, AfterViewInit {
|
||||
}
|
||||
|
||||
public getProjectRoleOptions(projectId: string): void {
|
||||
this.projectService.SearchProjectRoles(projectId, 100, 0).then(resp => {
|
||||
this.mgmtService.SearchProjectRoles(projectId, 100, 0).then(resp => {
|
||||
this.loadedProjectId = projectId;
|
||||
this.projectRoleOptions = resp.toObject().resultList;
|
||||
});
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { AuthService } from 'src/app/services/auth.service';
|
||||
import { GrpcAuthService } from 'src/app/services/grpc-auth.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-home',
|
||||
@ -8,9 +8,8 @@ import { AuthService } from 'src/app/services/auth.service';
|
||||
})
|
||||
export class HomeComponent {
|
||||
public dark: boolean = true;
|
||||
constructor(public authService: AuthService) {
|
||||
constructor(public authService: GrpcAuthService) {
|
||||
const theme = localStorage.getItem('theme');
|
||||
this.dark = theme === 'dark-theme' ? true : theme === 'light-theme' ? false : true;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -9,8 +9,8 @@ import { lowerCaseValidator, numberValidator, symbolValidator, upperCaseValidato
|
||||
import { CreateOrgRequest, CreateUserRequest, Gender, OrgSetUpResponse } from 'src/app/proto/generated/admin_pb';
|
||||
import { PasswordComplexityPolicy } from 'src/app/proto/generated/auth_pb';
|
||||
import { AdminService } from 'src/app/services/admin.service';
|
||||
import { AuthService } from 'src/app/services/auth.service';
|
||||
import { OrgService } from 'src/app/services/org.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 {
|
||||
@ -67,8 +67,8 @@ export class OrgCreateComponent {
|
||||
private adminService: AdminService,
|
||||
private _location: Location,
|
||||
private fb: FormBuilder,
|
||||
private orgService: OrgService,
|
||||
private authService: AuthService,
|
||||
private mgmtService: ManagementService,
|
||||
private authService: GrpcAuthService,
|
||||
) {
|
||||
this.authService.isAllowed(['iam.write']).pipe(take(1)).subscribe((allowed) => {
|
||||
if (allowed) {
|
||||
@ -139,7 +139,7 @@ export class OrgCreateComponent {
|
||||
const validators: Validators[] = [Validators.required];
|
||||
|
||||
if (this.usePassword) {
|
||||
this.orgService.GetDefaultPasswordComplexityPolicy().then(data => {
|
||||
this.mgmtService.GetDefaultPasswordComplexityPolicy().then(data => {
|
||||
this.policy = data.toObject();
|
||||
|
||||
if (this.policy.minLength) {
|
||||
@ -194,7 +194,7 @@ export class OrgCreateComponent {
|
||||
|
||||
public createOrgForSelf(): void {
|
||||
if (this.name && this.name.value) {
|
||||
this.orgService.CreateOrg(this.name.value).then((org) => {
|
||||
this.mgmtService.CreateOrg(this.name.value).then((org) => {
|
||||
this.router.navigate(['orgs', org.toObject().id]);
|
||||
}).catch(error => {
|
||||
this.toast.showError(error);
|
||||
|
@ -2,7 +2,7 @@ import { Component, Inject } from '@angular/core';
|
||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||
import { saveAs } from 'file-saver';
|
||||
import { OrgDomainValidationResponse, OrgDomainValidationType, OrgDomainView } from 'src/app/proto/generated/management_pb';
|
||||
import { OrgService } from 'src/app/services/org.service';
|
||||
import { ManagementService } from 'src/app/services/mgmt.service';
|
||||
import { ToastService } from 'src/app/services/toast.service';
|
||||
|
||||
@Component({
|
||||
@ -23,19 +23,19 @@ export class DomainVerificationComponent {
|
||||
private toast: ToastService,
|
||||
public dialogRef: MatDialogRef<DomainVerificationComponent>,
|
||||
@Inject(MAT_DIALOG_DATA) public data: any,
|
||||
private orgService: OrgService,
|
||||
private mgmtService: ManagementService,
|
||||
) {
|
||||
this.domain = data.domain;
|
||||
}
|
||||
|
||||
async loadHttpToken(): Promise<void> {
|
||||
this.http = (await this.orgService.GenerateMyOrgDomainValidation(
|
||||
this.http = (await this.mgmtService.GenerateMyOrgDomainValidation(
|
||||
this.domain.domain,
|
||||
OrgDomainValidationType.ORGDOMAINVALIDATIONTYPE_HTTP)).toObject();
|
||||
}
|
||||
|
||||
async loadDnsToken(): Promise<void> {
|
||||
this.dns = (await this.orgService.GenerateMyOrgDomainValidation(
|
||||
this.dns = (await this.mgmtService.GenerateMyOrgDomainValidation(
|
||||
this.domain.domain,
|
||||
OrgDomainValidationType.ORGDOMAINVALIDATIONTYPE_DNS)).toObject();
|
||||
}
|
||||
@ -45,7 +45,7 @@ export class DomainVerificationComponent {
|
||||
}
|
||||
|
||||
public validate(): void {
|
||||
this.orgService.ValidateMyOrgDomain(this.domain.domain).then(() => {
|
||||
this.mgmtService.ValidateMyOrgDomain(this.domain.domain).then(() => {
|
||||
this.dialogRef.close(false);
|
||||
}).catch((error) => {
|
||||
this.toast.showError(error);
|
||||
|
@ -19,7 +19,7 @@ import {
|
||||
OrgState,
|
||||
User,
|
||||
} from 'src/app/proto/generated/management_pb';
|
||||
import { OrgService } from 'src/app/services/org.service';
|
||||
import { ManagementService } from 'src/app/services/mgmt.service';
|
||||
import { ToastService } from 'src/app/services/toast.service';
|
||||
|
||||
import { AddDomainDialogComponent } from './add-domain-dialog/add-domain-dialog.component';
|
||||
@ -56,7 +56,7 @@ export class OrgDetailComponent implements OnInit, OnDestroy {
|
||||
constructor(
|
||||
private dialog: MatDialog,
|
||||
public translate: TranslateService,
|
||||
private orgService: OrgService,
|
||||
private mgmtService: ManagementService,
|
||||
private toast: ToastService,
|
||||
private router: Router,
|
||||
) { }
|
||||
@ -70,14 +70,14 @@ export class OrgDetailComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
private async getData(): Promise<void> {
|
||||
this.orgService.GetMyOrg().then((org: Org) => {
|
||||
this.mgmtService.GetMyOrg().then((org: Org) => {
|
||||
this.org = org.toObject();
|
||||
}).catch(error => {
|
||||
this.toast.showError(error);
|
||||
});
|
||||
|
||||
this.loadingSubject.next(true);
|
||||
from(this.orgService.SearchMyOrgMembers(100, 0)).pipe(
|
||||
from(this.mgmtService.SearchMyOrgMembers(100, 0)).pipe(
|
||||
map(resp => {
|
||||
this.totalMemberResult = resp.toObject().totalResult;
|
||||
return resp.toObject().resultList;
|
||||
@ -88,7 +88,7 @@ export class OrgDetailComponent implements OnInit, OnDestroy {
|
||||
this.membersSubject.next(members);
|
||||
});
|
||||
|
||||
this.orgService.SearchMyOrgDomains(0, 100).then(result => {
|
||||
this.mgmtService.SearchMyOrgDomains(0, 100).then(result => {
|
||||
this.domains = result.toObject().resultList;
|
||||
this.primaryDomain = this.domains.find(domain => domain.primary)?.domain ?? '';
|
||||
});
|
||||
@ -96,13 +96,13 @@ export class OrgDetailComponent implements OnInit, OnDestroy {
|
||||
|
||||
public changeState(event: MatButtonToggleChange | any): void {
|
||||
if (event.value === OrgState.ORGSTATE_ACTIVE) {
|
||||
this.orgService.ReactivateMyOrg().then(() => {
|
||||
this.mgmtService.ReactivateMyOrg().then(() => {
|
||||
this.toast.showInfo('ORG.TOAST.REACTIVATED', true);
|
||||
}).catch((error) => {
|
||||
this.toast.showError(error);
|
||||
});
|
||||
} else if (event.value === OrgState.ORGSTATE_INACTIVE) {
|
||||
this.orgService.DeactivateMyOrg().then(() => {
|
||||
this.mgmtService.DeactivateMyOrg().then(() => {
|
||||
this.toast.showInfo('ORG.TOAST.DEACTIVATED', true);
|
||||
}).catch((error) => {
|
||||
this.toast.showError(error);
|
||||
@ -118,7 +118,7 @@ export class OrgDetailComponent implements OnInit, OnDestroy {
|
||||
|
||||
dialogRef.afterClosed().subscribe(resp => {
|
||||
if (resp) {
|
||||
this.orgService.AddMyOrgDomain(resp).then(domain => {
|
||||
this.mgmtService.AddMyOrgDomain(resp).then(domain => {
|
||||
const newDomain = domain;
|
||||
|
||||
const newDomainView = new OrgDomainView();
|
||||
@ -150,7 +150,7 @@ export class OrgDetailComponent implements OnInit, OnDestroy {
|
||||
|
||||
dialogRef.afterClosed().subscribe(resp => {
|
||||
if (resp) {
|
||||
this.orgService.RemoveMyOrgDomain(domain).then(() => {
|
||||
this.mgmtService.RemoveMyOrgDomain(domain).then(() => {
|
||||
this.toast.showInfo('ORG.TOAST.DOMAINREMOVED', true);
|
||||
const index = this.domains.findIndex(d => d.domain === domain);
|
||||
if (index > -1) {
|
||||
@ -178,7 +178,7 @@ export class OrgDetailComponent implements OnInit, OnDestroy {
|
||||
|
||||
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 => {
|
||||
|
@ -4,8 +4,7 @@ import { Router } from '@angular/router';
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { switchMap, take } from 'rxjs/operators';
|
||||
import { Org } from 'src/app/proto/generated/auth_pb';
|
||||
import { AuthUserService } from 'src/app/services/auth-user.service';
|
||||
import { AuthService } from 'src/app/services/auth.service';
|
||||
import { GrpcAuthService } from 'src/app/services/grpc-auth.service';
|
||||
import { ToastService } from 'src/app/services/toast.service';
|
||||
|
||||
@Component({
|
||||
@ -24,15 +23,14 @@ export class OrgGridComponent {
|
||||
public notPinned: Array<Org.AsObject> = [];
|
||||
|
||||
constructor(
|
||||
public authService: AuthService,
|
||||
private userService: AuthUserService,
|
||||
private userService: GrpcAuthService,
|
||||
private toast: ToastService,
|
||||
private router: Router,
|
||||
) {
|
||||
this.loading = true;
|
||||
this.getData(10, 0);
|
||||
|
||||
this.authService.GetActiveOrg().then(org => this.activeOrg = org);
|
||||
this.userService.GetActiveOrg().then(org => this.activeOrg = org);
|
||||
|
||||
this.selection.changed.subscribe(selection => {
|
||||
this.setPrefixedItem('pinned-orgs', JSON.stringify(
|
||||
@ -71,7 +69,7 @@ export class OrgGridComponent {
|
||||
}
|
||||
|
||||
private getPrefixedItem(key: string): Observable<string | null> {
|
||||
return this.authService.user.pipe(
|
||||
return this.userService.user.pipe(
|
||||
take(1),
|
||||
switchMap(user => {
|
||||
return of(localStorage.getItem(`${user.id}:${key}`));
|
||||
@ -80,7 +78,7 @@ export class OrgGridComponent {
|
||||
}
|
||||
|
||||
private setPrefixedItem(key: string, value: any): Observable<void> {
|
||||
return this.authService.user.pipe(
|
||||
return this.userService.user.pipe(
|
||||
take(1),
|
||||
switchMap(user => {
|
||||
return of(localStorage.setItem(`${user.id}:${key}`, value));
|
||||
@ -103,7 +101,7 @@ export class OrgGridComponent {
|
||||
|
||||
public selectOrg(item: Org.AsObject, event?: any): void {
|
||||
if (event && !event.target.classList.contains('mat-icon')) {
|
||||
this.authService.setActiveOrg(item);
|
||||
this.userService.setActiveOrg(item);
|
||||
this.routeToOrg(item);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { Component, ElementRef, EventEmitter, Output, ViewChild } from '@angular/core';
|
||||
import { FormControl } from '@angular/forms';
|
||||
import { MatAutocomplete } from '@angular/material/autocomplete';
|
||||
import { OrgService } from 'src/app/services/org.service';
|
||||
import { ManagementService } from 'src/app/services/mgmt.service';
|
||||
import { ToastService } from 'src/app/services/toast.service';
|
||||
|
||||
@Component({
|
||||
@ -18,8 +18,8 @@ export class OrgMemberRolesAutocompleteComponent {
|
||||
@ViewChild('nameInput') public nameInput!: ElementRef<HTMLInputElement>;
|
||||
@ViewChild('auto') public matAutocomplete!: MatAutocomplete;
|
||||
@Output() public selectionChanged: EventEmitter<string[]> = new EventEmitter();
|
||||
constructor(private orgService: OrgService, private toast: ToastService) {
|
||||
this.orgService.GetOrgMemberRoles().then(resp => {
|
||||
constructor(private mgmtService: ManagementService, private toast: ToastService) {
|
||||
this.mgmtService.GetOrgMemberRoles().then(resp => {
|
||||
this.allRoles = resp.toObject().rolesList;
|
||||
}).catch(error => {
|
||||
this.toast.showError(error);
|
||||
|
@ -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 { OrgMemberView } from 'src/app/proto/generated/management_pb';
|
||||
import { OrgService } from 'src/app/services/org.service';
|
||||
import { ManagementService } from 'src/app/services/mgmt.service';
|
||||
|
||||
export class OrgMembersDataSource extends DataSource<OrgMemberView.AsObject> {
|
||||
public totalResult: number = 0;
|
||||
@ -12,7 +12,7 @@ export class OrgMembersDataSource extends DataSource<OrgMemberView.AsObject> {
|
||||
private loadingSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
|
||||
public loading$: Observable<boolean> = this.loadingSubject.asObservable();
|
||||
|
||||
constructor(private orgService: OrgService) {
|
||||
constructor(private mgmtService: ManagementService) {
|
||||
super();
|
||||
}
|
||||
|
||||
@ -20,7 +20,7 @@ export class OrgMembersDataSource extends DataSource<OrgMemberView.AsObject> {
|
||||
const offset = pageIndex * pageSize;
|
||||
|
||||
this.loadingSubject.next(true);
|
||||
from(this.orgService.SearchMyOrgMembers(pageSize, offset)).pipe(
|
||||
from(this.mgmtService.SearchMyOrgMembers(pageSize, offset)).pipe(
|
||||
map(resp => {
|
||||
const response = resp.toObject();
|
||||
this.totalResult = response.totalResult;
|
||||
|
@ -6,7 +6,7 @@ import { MatSelectChange } from '@angular/material/select';
|
||||
import { tap } from 'rxjs/operators';
|
||||
import { CreationType, MemberCreateDialogComponent } from 'src/app/modules/add-member-dialog/member-create-dialog.component';
|
||||
import { Org, OrgMemberView, ProjectType, User } from 'src/app/proto/generated/management_pb';
|
||||
import { OrgService } from 'src/app/services/org.service';
|
||||
import { ManagementService } from 'src/app/services/mgmt.service';
|
||||
import { ToastService } from 'src/app/services/toast.service';
|
||||
|
||||
import { OrgMembersDataSource } from './org-members-datasource';
|
||||
@ -30,13 +30,13 @@ export class OrgMembersComponent implements AfterViewInit {
|
||||
public displayedColumns: string[] = ['select', 'firstname', 'lastname', 'username', 'email', 'roles'];
|
||||
|
||||
constructor(
|
||||
private orgService: OrgService,
|
||||
private mgmtService: ManagementService,
|
||||
private dialog: MatDialog,
|
||||
private toast: ToastService,
|
||||
) {
|
||||
this.orgService.GetMyOrg().then(org => {
|
||||
this.mgmtService.GetMyOrg().then(org => {
|
||||
this.org = org.toObject();
|
||||
this.dataSource = new OrgMembersDataSource(this.orgService);
|
||||
this.dataSource = new OrgMembersDataSource(this.mgmtService);
|
||||
this.dataSource.loadMembers(0, 25);
|
||||
});
|
||||
|
||||
@ -52,7 +52,7 @@ export class OrgMembersComponent implements AfterViewInit {
|
||||
}
|
||||
|
||||
public getRoleOptions(): void {
|
||||
this.orgService.GetOrgMemberRoles().then(resp => {
|
||||
this.mgmtService.GetOrgMemberRoles().then(resp => {
|
||||
this.memberRoleOptions = resp.toObject().rolesList;
|
||||
}).catch(error => {
|
||||
this.toast.showError(error);
|
||||
@ -60,7 +60,7 @@ export class OrgMembersComponent implements AfterViewInit {
|
||||
}
|
||||
|
||||
updateRoles(member: OrgMemberView.AsObject, selectionChange: MatSelectChange): void {
|
||||
this.orgService.ChangeMyOrgMember(member.userId, selectionChange.value)
|
||||
this.mgmtService.ChangeMyOrgMember(member.userId, selectionChange.value)
|
||||
.then(() => {
|
||||
this.toast.showInfo('ORG.TOAST.MEMBERCHANGED', true);
|
||||
}).catch(error => {
|
||||
@ -77,7 +77,7 @@ export class OrgMembersComponent implements AfterViewInit {
|
||||
|
||||
public removeProjectMemberSelection(): void {
|
||||
Promise.all(this.selection.selected.map(member => {
|
||||
return this.orgService.RemoveMyOrgMember(member.userId).then(() => {
|
||||
return this.mgmtService.RemoveMyOrgMember(member.userId).then(() => {
|
||||
this.toast.showInfo('ORG.TOAST.MEMBERREMOVED', true);
|
||||
}).catch(error => {
|
||||
this.toast.showError(error);
|
||||
@ -112,7 +112,7 @@ export class OrgMembersComponent 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 => {
|
||||
|
@ -10,7 +10,7 @@ import {
|
||||
PasswordLockoutPolicy,
|
||||
} from 'src/app/proto/generated/management_pb';
|
||||
import { AdminService } from 'src/app/services/admin.service';
|
||||
import { OrgService } from 'src/app/services/org.service';
|
||||
import { ManagementService } from 'src/app/services/mgmt.service';
|
||||
import { StorageService } from 'src/app/services/storage.service';
|
||||
import { ToastService } from 'src/app/services/toast.service';
|
||||
|
||||
@ -55,7 +55,7 @@ export class PasswordPolicyComponent implements OnInit, OnDestroy {
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private adminService: AdminService,
|
||||
private orgService: OrgService,
|
||||
private mgmtService: ManagementService,
|
||||
private router: Router,
|
||||
private toast: ToastService,
|
||||
private sessionStorage: StorageService,
|
||||
@ -121,40 +121,40 @@ export class PasswordPolicyComponent implements OnInit, OnDestroy {
|
||||
case PolicyComponentType.LOCKOUT:
|
||||
this.title = 'ORG.POLICY.PWD_LOCKOUT.TITLE';
|
||||
this.desc = 'ORG.POLICY.PWD_LOCKOUT.DESCRIPTION';
|
||||
return this.orgService.GetPasswordLockoutPolicy();
|
||||
return this.mgmtService.GetPasswordLockoutPolicy();
|
||||
case PolicyComponentType.AGE:
|
||||
this.title = 'ORG.POLICY.PWD_AGE.TITLE';
|
||||
this.desc = 'ORG.POLICY.PWD_AGE.DESCRIPTION';
|
||||
return this.orgService.GetPasswordAgePolicy();
|
||||
return this.mgmtService.GetPasswordAgePolicy();
|
||||
case PolicyComponentType.COMPLEXITY:
|
||||
this.title = 'ORG.POLICY.PWD_COMPLEXITY.TITLE';
|
||||
this.desc = 'ORG.POLICY.PWD_COMPLEXITY.DESCRIPTION';
|
||||
return this.orgService.GetPasswordComplexityPolicy();
|
||||
return this.mgmtService.GetPasswordComplexityPolicy();
|
||||
case PolicyComponentType.IAM_POLICY:
|
||||
this.title = 'ORG.POLICY.IAM_POLICY.TITLECREATE';
|
||||
this.desc = 'ORG.POLICY.IAM_POLICY.DESCRIPTIONCREATE';
|
||||
return this.orgService.GetMyOrgIamPolicy();
|
||||
return this.mgmtService.GetMyOrgIamPolicy();
|
||||
}
|
||||
}
|
||||
|
||||
public deletePolicy(): void {
|
||||
switch (this.policyType) {
|
||||
case PolicyComponentType.LOCKOUT:
|
||||
this.orgService.DeletePasswordLockoutPolicy(this.lockoutData.id).then(() => {
|
||||
this.mgmtService.DeletePasswordLockoutPolicy(this.lockoutData.id).then(() => {
|
||||
this.toast.showInfo('Successfully deleted');
|
||||
}).catch(error => {
|
||||
this.toast.showError(error);
|
||||
});
|
||||
break;
|
||||
case PolicyComponentType.AGE:
|
||||
this.orgService.DeletePasswordAgePolicy(this.ageData.id).then(() => {
|
||||
this.mgmtService.DeletePasswordAgePolicy(this.ageData.id).then(() => {
|
||||
this.toast.showInfo('Successfully deleted');
|
||||
}).catch(error => {
|
||||
this.toast.showError(error);
|
||||
});
|
||||
break;
|
||||
case PolicyComponentType.COMPLEXITY:
|
||||
this.orgService.DeletePasswordComplexityPolicy(this.complexityData.id).then(() => {
|
||||
this.mgmtService.DeletePasswordComplexityPolicy(this.complexityData.id).then(() => {
|
||||
this.toast.showInfo('Successfully deleted');
|
||||
}).catch(error => {
|
||||
this.toast.showError(error);
|
||||
@ -215,7 +215,7 @@ export class PasswordPolicyComponent implements OnInit, OnDestroy {
|
||||
if (this.componentAction === PolicyComponentAction.CREATE) {
|
||||
switch (this.policyType) {
|
||||
case PolicyComponentType.LOCKOUT:
|
||||
this.orgService.CreatePasswordLockoutPolicy(
|
||||
this.mgmtService.CreatePasswordLockoutPolicy(
|
||||
this.lockoutData.description,
|
||||
this.lockoutData.maxAttempts,
|
||||
this.lockoutData.showLockOutFailures,
|
||||
@ -227,7 +227,7 @@ export class PasswordPolicyComponent implements OnInit, OnDestroy {
|
||||
|
||||
break;
|
||||
case PolicyComponentType.AGE:
|
||||
this.orgService.CreatePasswordAgePolicy(
|
||||
this.mgmtService.CreatePasswordAgePolicy(
|
||||
this.ageData.description,
|
||||
this.ageData.maxAgeDays,
|
||||
this.ageData.expireWarnDays,
|
||||
@ -239,7 +239,7 @@ export class PasswordPolicyComponent implements OnInit, OnDestroy {
|
||||
|
||||
break;
|
||||
case PolicyComponentType.COMPLEXITY:
|
||||
this.orgService.CreatePasswordComplexityPolicy(
|
||||
this.mgmtService.CreatePasswordComplexityPolicy(
|
||||
this.complexityData.description,
|
||||
this.complexityData.hasLowercase,
|
||||
this.complexityData.hasUppercase,
|
||||
@ -271,7 +271,7 @@ export class PasswordPolicyComponent implements OnInit, OnDestroy {
|
||||
} else if (this.componentAction === PolicyComponentAction.MODIFY) {
|
||||
switch (this.policyType) {
|
||||
case PolicyComponentType.LOCKOUT:
|
||||
this.orgService.UpdatePasswordLockoutPolicy(
|
||||
this.mgmtService.UpdatePasswordLockoutPolicy(
|
||||
this.lockoutData.description,
|
||||
this.lockoutData.maxAttempts,
|
||||
this.lockoutData.showLockOutFailures,
|
||||
@ -283,7 +283,7 @@ export class PasswordPolicyComponent implements OnInit, OnDestroy {
|
||||
|
||||
break;
|
||||
case PolicyComponentType.AGE:
|
||||
this.orgService.UpdatePasswordAgePolicy(
|
||||
this.mgmtService.UpdatePasswordAgePolicy(
|
||||
this.ageData.description,
|
||||
this.ageData.maxAgeDays,
|
||||
this.ageData.expireWarnDays,
|
||||
@ -295,7 +295,7 @@ export class PasswordPolicyComponent implements OnInit, OnDestroy {
|
||||
|
||||
break;
|
||||
case PolicyComponentType.COMPLEXITY:
|
||||
this.orgService.UpdatePasswordComplexityPolicy(
|
||||
this.mgmtService.UpdatePasswordComplexityPolicy(
|
||||
this.complexityData.description,
|
||||
this.complexityData.hasLowercase,
|
||||
this.complexityData.hasUppercase,
|
||||
|
@ -6,8 +6,8 @@ import {
|
||||
PasswordLockoutPolicy,
|
||||
PolicyState,
|
||||
} from 'src/app/proto/generated/management_pb';
|
||||
import { AuthUserService } from 'src/app/services/auth-user.service';
|
||||
import { OrgService } from 'src/app/services/org.service';
|
||||
import { GrpcAuthService } from 'src/app/services/grpc-auth.service';
|
||||
import { ManagementService } from 'src/app/services/mgmt.service';
|
||||
|
||||
import { PolicyComponentType } from '../password-policy/password-policy.component';
|
||||
|
||||
@ -26,14 +26,14 @@ export class PolicyGridComponent {
|
||||
public PolicyComponentType: any = PolicyComponentType;
|
||||
|
||||
constructor(
|
||||
private orgService: OrgService,
|
||||
public authUserService: AuthUserService,
|
||||
private mgmtService: ManagementService,
|
||||
public authUserService: GrpcAuthService,
|
||||
) {
|
||||
this.getData();
|
||||
}
|
||||
|
||||
private getData(): void {
|
||||
this.orgService.GetPasswordComplexityPolicy().then(data => this.complexityPolicy = data.toObject());
|
||||
this.orgService.GetMyOrgIamPolicy().then(data => this.iamPolicy = data.toObject());
|
||||
this.mgmtService.GetPasswordComplexityPolicy().then(data => this.complexityPolicy = data.toObject());
|
||||
this.mgmtService.GetMyOrgIamPolicy().then(data => this.iamPolicy = data.toObject());
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import { MatAutocomplete, MatAutocompleteSelectedEvent } from '@angular/material
|
||||
import { MatChipInputEvent } from '@angular/material/chips';
|
||||
import { debounceTime, tap } from 'rxjs/operators';
|
||||
import { Org } from 'src/app/proto/generated/management_pb';
|
||||
import { OrgService } from 'src/app/services/org.service';
|
||||
import { ManagementService } from 'src/app/services/mgmt.service';
|
||||
import { ToastService } from 'src/app/services/toast.service';
|
||||
|
||||
@Component({
|
||||
@ -27,9 +27,9 @@ export class SearchOrgAutocompleteComponent {
|
||||
@ViewChild('auto') public matAutocomplete!: MatAutocomplete;
|
||||
@Input() public singleOutput: boolean = false;
|
||||
@Output() public selectionChanged: EventEmitter<Org.AsObject | Org.AsObject[]> = new EventEmitter();
|
||||
constructor(private orgService: OrgService, private toast: ToastService) {
|
||||
constructor(private mgmtService: ManagementService, private toast: ToastService) {
|
||||
this.myControl.valueChanges.pipe(debounceTime(200), tap(() => this.isLoading = true)).subscribe(value => {
|
||||
return this.orgService.getOrgByDomainGlobal(value).then((org) => {
|
||||
return this.mgmtService.getOrgByDomainGlobal(value).then((org) => {
|
||||
this.isLoading = false;
|
||||
if (org) {
|
||||
this.filteredOrgs = [org.toObject()];
|
||||
|
@ -15,7 +15,7 @@ import {
|
||||
OIDCGrantType,
|
||||
OIDCResponseType,
|
||||
} from 'src/app/proto/generated/management_pb';
|
||||
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 { AppSecretDialogComponent } from '../app-secret-dialog/app-secret-dialog.component';
|
||||
@ -84,7 +84,7 @@ export class AppCreateComponent implements OnInit, OnDestroy {
|
||||
private route: ActivatedRoute,
|
||||
private toast: ToastService,
|
||||
private dialog: MatDialog,
|
||||
private projectService: ProjectService,
|
||||
private mgmtService: ManagementService,
|
||||
private fb: FormBuilder,
|
||||
private _location: Location,
|
||||
) {
|
||||
@ -186,7 +186,7 @@ export class AppCreateComponent implements OnInit, OnDestroy {
|
||||
|
||||
public saveOIDCApp(): void {
|
||||
this.loading = true;
|
||||
this.projectService
|
||||
this.mgmtService
|
||||
.CreateOIDCApp(this.oidcApp)
|
||||
.then((data: Application) => {
|
||||
this.loading = false;
|
||||
|
@ -18,8 +18,7 @@ import {
|
||||
OIDCResponseType,
|
||||
ZitadelDocs,
|
||||
} from 'src/app/proto/generated/management_pb';
|
||||
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 { AppSecretDialogComponent } from '../app-secret-dialog/app-secret-dialog.component';
|
||||
@ -88,11 +87,10 @@ export class AppDetailComponent implements OnInit, OnDestroy {
|
||||
public translate: TranslateService,
|
||||
private route: ActivatedRoute,
|
||||
private toast: ToastService,
|
||||
private projectService: ProjectService,
|
||||
private fb: FormBuilder,
|
||||
private _location: Location,
|
||||
private dialog: MatDialog,
|
||||
private orgService: OrgService,
|
||||
private mgmtService: ManagementService,
|
||||
) {
|
||||
this.appNameForm = this.fb.group({
|
||||
state: ['', []],
|
||||
@ -118,11 +116,11 @@ export class AppDetailComponent implements OnInit, OnDestroy {
|
||||
|
||||
private async getData({ projectid, id }: Params): Promise<void> {
|
||||
this.projectId = projectid;
|
||||
this.orgService.GetIam().then(iam => {
|
||||
this.mgmtService.GetIam().then(iam => {
|
||||
this.isZitadel = iam.toObject().iamProjectId === this.projectId;
|
||||
});
|
||||
|
||||
this.projectService.GetApplicationById(projectid, id).then(app => {
|
||||
this.mgmtService.GetApplicationById(projectid, id).then(app => {
|
||||
this.app = app.toObject();
|
||||
this.appNameForm.patchValue(this.app);
|
||||
|
||||
@ -151,18 +149,18 @@ export class AppDetailComponent implements OnInit, OnDestroy {
|
||||
this.errorMessage = error.message;
|
||||
});
|
||||
|
||||
this.docs = (await this.projectService.GetZitadelDocs()).toObject();
|
||||
this.docs = (await this.mgmtService.GetZitadelDocs()).toObject();
|
||||
}
|
||||
|
||||
public changeState(event: MatButtonToggleChange): void {
|
||||
if (event.value === AppState.APPSTATE_ACTIVE) {
|
||||
this.projectService.ReactivateApplication(this.projectId, this.app.id).then(() => {
|
||||
this.mgmtService.ReactivateApplication(this.projectId, this.app.id).then(() => {
|
||||
this.toast.showInfo('APP.TOAST.REACTIVATED', true);
|
||||
}).catch((error: any) => {
|
||||
this.toast.showError(error);
|
||||
});
|
||||
} else if (event.value === AppState.APPSTATE_INACTIVE) {
|
||||
this.projectService.DeactivateApplication(this.projectId, this.app.id).then(() => {
|
||||
this.mgmtService.DeactivateApplication(this.projectId, this.app.id).then(() => {
|
||||
this.toast.showInfo('APP.TOAST.REACTIVATED', true);
|
||||
}).catch((error: any) => {
|
||||
this.toast.showError(error);
|
||||
@ -230,7 +228,7 @@ export class AppDetailComponent implements OnInit, OnDestroy {
|
||||
this.app.oidcConfig.postLogoutRedirectUrisList = this.postLogoutRedirectUrisList;
|
||||
this.app.oidcConfig.devMode = this.devMode?.value;
|
||||
|
||||
this.projectService
|
||||
this.mgmtService
|
||||
.UpdateOIDCAppConfig(this.projectId, this.app.id, this.app.oidcConfig)
|
||||
.then(() => {
|
||||
this.toast.showInfo('APP.TOAST.OIDCUPDATED', true);
|
||||
@ -243,7 +241,7 @@ export class AppDetailComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
public regenerateOIDCClientSecret(): void {
|
||||
this.projectService.RegenerateOIDCClientSecret(this.app.id, this.projectId).then((data: OIDCConfig) => {
|
||||
this.mgmtService.RegenerateOIDCClientSecret(this.app.id, this.projectId).then((data: OIDCConfig) => {
|
||||
this.toast.showInfo('APP.TOAST.OIDCCLIENTSECRETREGENERATED', true);
|
||||
this.dialog.open(AppSecretDialogComponent, {
|
||||
data: {
|
||||
|
@ -24,8 +24,7 @@ import {
|
||||
User,
|
||||
UserGrantSearchKey,
|
||||
} from 'src/app/proto/generated/management_pb';
|
||||
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({
|
||||
@ -78,9 +77,8 @@ export class GrantedProjectDetailComponent implements OnInit, OnDestroy {
|
||||
public translate: TranslateService,
|
||||
private route: ActivatedRoute,
|
||||
private toast: ToastService,
|
||||
private projectService: ProjectService,
|
||||
private mgmtService: ManagementService,
|
||||
private _location: Location,
|
||||
private orgService: OrgService,
|
||||
private router: Router,
|
||||
private dialog: MatDialog,
|
||||
) {
|
||||
@ -98,20 +96,18 @@ export class GrantedProjectDetailComponent implements OnInit, OnDestroy {
|
||||
this.projectId = id;
|
||||
this.grantId = grantId;
|
||||
|
||||
console.log(id, grantId);
|
||||
|
||||
this.orgService.GetIam().then(iam => {
|
||||
this.mgmtService.GetIam().then(iam => {
|
||||
this.isZitadel = iam.toObject().iamProjectId === this.projectId;
|
||||
});
|
||||
|
||||
if (this.projectId && this.grantId) {
|
||||
this.projectService.GetGrantedProjectByID(this.projectId, this.grantId).then(proj => {
|
||||
this.mgmtService.GetGrantedProjectByID(this.projectId, this.grantId).then(proj => {
|
||||
this.project = proj.toObject();
|
||||
}).catch(error => {
|
||||
this.toast.showError(error);
|
||||
});
|
||||
|
||||
from(this.projectService.SearchProjectGrantMembers(this.projectId,
|
||||
from(this.mgmtService.SearchProjectGrantMembers(this.projectId,
|
||||
this.grantId, 100, 0)).pipe(
|
||||
map(resp => {
|
||||
this.totalMemberResult = resp.toObject().totalResult;
|
||||
@ -144,7 +140,7 @@ export class GrantedProjectDetailComponent implements OnInit, OnDestroy {
|
||||
|
||||
if (users && users.length && roles && roles.length) {
|
||||
users.forEach(user => {
|
||||
return this.projectService.AddProjectGrantMember(
|
||||
return this.mgmtService.AddProjectGrantMember(
|
||||
this.projectId,
|
||||
this.grantId,
|
||||
user.id,
|
||||
|
@ -8,7 +8,7 @@ import { TranslateService } from '@ngx-translate/core';
|
||||
import { Timestamp } from 'google-protobuf/google/protobuf/timestamp_pb';
|
||||
import { BehaviorSubject, Observable, Subscription } from 'rxjs';
|
||||
import { ProjectGrantView } from 'src/app/proto/generated/management_pb';
|
||||
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({
|
||||
@ -55,7 +55,7 @@ export class GrantedProjectListComponent implements OnInit, OnDestroy {
|
||||
|
||||
constructor(private router: Router,
|
||||
public translate: TranslateService,
|
||||
private projectService: ProjectService,
|
||||
private mgmtService: ManagementService,
|
||||
private toast: ToastService,
|
||||
) { }
|
||||
|
||||
@ -89,7 +89,7 @@ export class GrantedProjectListComponent implements OnInit, OnDestroy {
|
||||
|
||||
private async getData(limit: number, offset: number): Promise<void> {
|
||||
this.loadingSubject.next(true);
|
||||
this.projectService.SearchGrantedProjects(limit, offset).then(res => {
|
||||
this.mgmtService.SearchGrantedProjects(limit, offset).then(res => {
|
||||
const response = res.toObject();
|
||||
this.grantedProjectList = response.resultList;
|
||||
this.totalResult = response.totalResult;
|
||||
|
@ -2,7 +2,7 @@ import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
||||
import { BehaviorSubject, from, Observable, of } from 'rxjs';
|
||||
import { catchError, finalize, map } from 'rxjs/operators';
|
||||
import { Application } from 'src/app/proto/generated/management_pb';
|
||||
import { ProjectService } from 'src/app/services/project.service';
|
||||
import { ManagementService } from 'src/app/services/mgmt.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-application-grid',
|
||||
@ -17,14 +17,14 @@ export class ApplicationGridComponent implements OnInit {
|
||||
private loadingSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(true);
|
||||
public loading$: Observable<boolean> = this.loadingSubject.asObservable();
|
||||
|
||||
constructor(private projectService: ProjectService) { }
|
||||
constructor(private mgmtService: ManagementService) { }
|
||||
|
||||
public ngOnInit(): void {
|
||||
this.loadApps();
|
||||
}
|
||||
|
||||
public loadApps(): void {
|
||||
from(this.projectService.SearchApplications(this.projectId, 100, 0)).pipe(
|
||||
from(this.mgmtService.SearchApplications(this.projectId, 100, 0)).pipe(
|
||||
map(resp => {
|
||||
return resp.toObject().resultList;
|
||||
}),
|
||||
|
@ -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 { Application } from 'src/app/proto/generated/management_pb';
|
||||
import { ProjectService } from 'src/app/services/project.service';
|
||||
import { ManagementService } from 'src/app/services/mgmt.service';
|
||||
|
||||
/**
|
||||
* Data source for the ProjectMembers view. This class should
|
||||
@ -18,7 +18,7 @@ export class ProjectApplicationsDataSource extends DataSource<Application.AsObje
|
||||
private loadingSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
|
||||
public loading$: Observable<boolean> = this.loadingSubject.asObservable();
|
||||
|
||||
constructor(private projectService: ProjectService) {
|
||||
constructor(private mgmtService: ManagementService) {
|
||||
super();
|
||||
}
|
||||
|
||||
@ -26,7 +26,7 @@ export class ProjectApplicationsDataSource extends DataSource<Application.AsObje
|
||||
const offset = pageIndex * pageSize;
|
||||
|
||||
this.loadingSubject.next(true);
|
||||
from(this.projectService.SearchApplications(projectId, pageSize, offset)).pipe(
|
||||
from(this.mgmtService.SearchApplications(projectId, pageSize, offset)).pipe(
|
||||
map(resp => {
|
||||
const response = resp.toObject();
|
||||
this.totalResult = response.totalResult;
|
||||
|
@ -6,7 +6,7 @@ import { MatTable } from '@angular/material/table';
|
||||
import { merge, of } from 'rxjs';
|
||||
import { tap } from 'rxjs/operators';
|
||||
import { Application } from 'src/app/proto/generated/management_pb';
|
||||
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 { ProjectApplicationsDataSource } from './applications-datasource';
|
||||
@ -28,10 +28,10 @@ export class ApplicationsComponent implements AfterViewInit, OnInit {
|
||||
|
||||
public displayedColumns: string[] = ['select', 'name'];
|
||||
|
||||
constructor(private projectService: ProjectService, private toast: ToastService) { }
|
||||
constructor(private mgmtService: ManagementService, private toast: ToastService) { }
|
||||
|
||||
public ngOnInit(): void {
|
||||
this.dataSource = new ProjectApplicationsDataSource(this.projectService);
|
||||
this.dataSource = new ProjectApplicationsDataSource(this.mgmtService);
|
||||
this.dataSource.loadApps(this.projectId, 0, 25);
|
||||
}
|
||||
|
||||
|
@ -25,8 +25,7 @@ import {
|
||||
UserView,
|
||||
UserGrantSearchKey,
|
||||
} from 'src/app/proto/generated/management_pb';
|
||||
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({
|
||||
@ -79,9 +78,8 @@ export class OwnedProjectDetailComponent implements OnInit, OnDestroy {
|
||||
public translate: TranslateService,
|
||||
private route: ActivatedRoute,
|
||||
private toast: ToastService,
|
||||
private projectService: ProjectService,
|
||||
private mgmtService: ManagementService,
|
||||
private _location: Location,
|
||||
private orgService: OrgService,
|
||||
private dialog: MatDialog,
|
||||
private router: Router,
|
||||
) {
|
||||
@ -98,18 +96,18 @@ export class OwnedProjectDetailComponent implements OnInit, OnDestroy {
|
||||
private async getData({ id }: Params): Promise<void> {
|
||||
this.projectId = id;
|
||||
|
||||
this.orgService.GetIam().then(iam => {
|
||||
this.mgmtService.GetIam().then(iam => {
|
||||
this.isZitadel = iam.toObject().iamProjectId === this.projectId;
|
||||
});
|
||||
|
||||
this.projectService.GetProjectById(id).then(proj => {
|
||||
this.mgmtService.GetProjectById(id).then(proj => {
|
||||
this.project = proj.toObject();
|
||||
}).catch(error => {
|
||||
console.error(error);
|
||||
this.toast.showError(error);
|
||||
});
|
||||
|
||||
from(this.projectService.SearchProjectMembers(this.projectId, 100, 0)).pipe(
|
||||
from(this.mgmtService.SearchProjectMembers(this.projectId, 100, 0)).pipe(
|
||||
map(resp => {
|
||||
this.totalMemberResult = resp.toObject().totalResult;
|
||||
return resp.toObject().resultList;
|
||||
@ -134,7 +132,7 @@ export class OwnedProjectDetailComponent implements OnInit, OnDestroy {
|
||||
});
|
||||
dialogRef.afterClosed().subscribe(resp => {
|
||||
if (resp) {
|
||||
this.projectService.ReactivateProject(this.projectId).then(() => {
|
||||
this.mgmtService.ReactivateProject(this.projectId).then(() => {
|
||||
this.toast.showInfo('PROJECT.TOAST.REACTIVATED', true);
|
||||
this.project.state = ProjectState.PROJECTSTATE_ACTIVE;
|
||||
}).catch(error => {
|
||||
@ -155,7 +153,7 @@ export class OwnedProjectDetailComponent implements OnInit, OnDestroy {
|
||||
});
|
||||
dialogRef.afterClosed().subscribe(resp => {
|
||||
if (resp) {
|
||||
this.projectService.DeactivateProject(this.projectId).then(() => {
|
||||
this.mgmtService.DeactivateProject(this.projectId).then(() => {
|
||||
this.toast.showInfo('PROJECT.TOAST.DEACTIVATED', true);
|
||||
this.project.state = ProjectState.PROJECTSTATE_INACTIVE;
|
||||
}).catch(error => {
|
||||
@ -178,7 +176,7 @@ export class OwnedProjectDetailComponent implements OnInit, OnDestroy {
|
||||
});
|
||||
dialogRef.afterClosed().subscribe(resp => {
|
||||
if (resp) {
|
||||
this.projectService.RemoveProject(this.projectId).then(() => {
|
||||
this.mgmtService.RemoveProject(this.projectId).then(() => {
|
||||
this.toast.showInfo('PROJECT.TOAST.DELETED', true);
|
||||
this.router.navigate(['/projects']);
|
||||
}).catch(error => {
|
||||
@ -189,7 +187,7 @@ export class OwnedProjectDetailComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
public saveProject(): void {
|
||||
this.projectService.UpdateProject(this.project.projectId, this.project.name).then(() => {
|
||||
this.mgmtService.UpdateProject(this.project.projectId, this.project.name).then(() => {
|
||||
this.toast.showInfo('PROJECT.TOAST.UPDATED', true);
|
||||
}).catch(error => {
|
||||
this.toast.showError(error);
|
||||
@ -221,7 +219,7 @@ export class OwnedProjectDetailComponent implements OnInit, OnDestroy {
|
||||
|
||||
if (users && users.length && roles && roles.length) {
|
||||
users.forEach(user => {
|
||||
return this.projectService.AddProjectMember(this.projectId, user.id, roles)
|
||||
return this.mgmtService.AddProjectMember(this.projectId, user.id, roles)
|
||||
.then(() => {
|
||||
this.toast.showInfo('PROJECT.TOAST.MEMBERADDED', true);
|
||||
}).catch(error => {
|
||||
|
@ -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 { ProjectGrant } from 'src/app/proto/generated/management_pb';
|
||||
import { ProjectService } from 'src/app/services/project.service';
|
||||
import { ManagementService } from 'src/app/services/mgmt.service';
|
||||
|
||||
/**
|
||||
* Data source for the ProjectMembers view. This class should
|
||||
@ -17,7 +17,7 @@ export class ProjectGrantsDataSource extends DataSource<ProjectGrant.AsObject> {
|
||||
private loadingSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
|
||||
public loading$: Observable<boolean> = this.loadingSubject.asObservable();
|
||||
|
||||
constructor(private projectService: ProjectService) {
|
||||
constructor(private mgmtService: ManagementService) {
|
||||
super();
|
||||
}
|
||||
|
||||
@ -25,7 +25,7 @@ export class ProjectGrantsDataSource extends DataSource<ProjectGrant.AsObject> {
|
||||
const offset = pageIndex * pageSize;
|
||||
|
||||
this.loadingSubject.next(true);
|
||||
from(this.projectService.SearchProjectGrants(projectId, pageSize, offset)).pipe(
|
||||
from(this.mgmtService.SearchProjectGrants(projectId, pageSize, offset)).pipe(
|
||||
map(resp => {
|
||||
const response = resp.toObject();
|
||||
this.totalResult = response.totalResult;
|
||||
|
@ -6,7 +6,7 @@ import { MatSelectChange } from '@angular/material/select';
|
||||
import { MatTable } from '@angular/material/table';
|
||||
import { tap } from 'rxjs/operators';
|
||||
import { ProjectGrant, ProjectRoleView } from 'src/app/proto/generated/management_pb';
|
||||
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 { ProjectGrantsDataSource } from './project-grants-datasource';
|
||||
@ -35,10 +35,10 @@ export class ProjectGrantsComponent implements OnInit, AfterViewInit {
|
||||
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
|
||||
public displayedColumns: string[] = ['select', 'grantedOrgName', 'creationDate', 'changeDate', 'roleNamesList'];
|
||||
|
||||
constructor(private projectService: ProjectService, private toast: ToastService) { }
|
||||
constructor(private mgmtService: ManagementService, private toast: ToastService) { }
|
||||
|
||||
public ngOnInit(): void {
|
||||
this.dataSource = new ProjectGrantsDataSource(this.projectService);
|
||||
this.dataSource = new ProjectGrantsDataSource(this.mgmtService);
|
||||
this.dataSource.loadGrants(this.projectId, 0, 25, 'asc');
|
||||
this.getRoleOptions(this.projectId);
|
||||
}
|
||||
@ -73,13 +73,13 @@ export class ProjectGrantsComponent implements OnInit, AfterViewInit {
|
||||
}
|
||||
|
||||
public getRoleOptions(projectId: string): void {
|
||||
this.projectService.SearchProjectRoles(projectId, 100, 0).then(resp => {
|
||||
this.mgmtService.SearchProjectRoles(projectId, 100, 0).then(resp => {
|
||||
this.memberRoleOptions = resp.toObject().resultList;
|
||||
});
|
||||
}
|
||||
|
||||
updateRoles(grant: ProjectGrant.AsObject, selectionChange: MatSelectChange): void {
|
||||
this.projectService.UpdateProjectGrant(grant.id, grant.projectId, selectionChange.value)
|
||||
this.mgmtService.UpdateProjectGrant(grant.id, grant.projectId, selectionChange.value)
|
||||
.then((newgrant: ProjectGrant) => {
|
||||
this.toast.showInfo('PROJECT.GRANT.TOAST.PROJECTGRANTCHANGED', true);
|
||||
}).catch(error => {
|
||||
@ -89,7 +89,7 @@ export class ProjectGrantsComponent implements OnInit, AfterViewInit {
|
||||
|
||||
deleteSelectedGrants(): void {
|
||||
const promises = this.selection.selected.map(grant => {
|
||||
return this.projectService.RemoveProjectGrant(grant.id, grant.projectId);
|
||||
return this.mgmtService.RemoveProjectGrant(grant.id, grant.projectId);
|
||||
});
|
||||
|
||||
Promise.all(promises).then(() => {
|
||||
|
@ -4,7 +4,7 @@ import { Component, EventEmitter, Input, OnChanges, Output, SimpleChanges } from
|
||||
import { Router } from '@angular/router';
|
||||
import { Org } from 'src/app/proto/generated/auth_pb';
|
||||
import { ProjectState, ProjectType, ProjectView } from 'src/app/proto/generated/management_pb';
|
||||
import { AuthService } from 'src/app/services/auth.service';
|
||||
import { AuthenticationService } from 'src/app/services/authentication.service';
|
||||
import { StorageKey, StorageService } from 'src/app/services/storage.service';
|
||||
|
||||
@Component({
|
||||
@ -49,7 +49,7 @@ export class OwnedProjectGridComponent implements OnChanges {
|
||||
public ProjectState: any = ProjectState;
|
||||
public ProjectType: any = ProjectType;
|
||||
|
||||
constructor(private router: Router, private authService: AuthService, private storage: StorageService) {
|
||||
constructor(private router: Router, private authService: AuthenticationService, private storage: StorageService) {
|
||||
this.selection.changed.subscribe(selection => {
|
||||
this.setPrefixedItem('pinned-projects', JSON.stringify(
|
||||
this.selection.selected.map(item => item.projectId),
|
||||
|
@ -8,7 +8,7 @@ import { TranslateService } from '@ngx-translate/core';
|
||||
import { Timestamp } from 'google-protobuf/google/protobuf/timestamp_pb';
|
||||
import { BehaviorSubject, Observable, Subscription } from 'rxjs';
|
||||
import { ProjectView } from 'src/app/proto/generated/management_pb';
|
||||
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({
|
||||
@ -56,7 +56,7 @@ export class OwnedProjectListComponent implements OnInit, OnDestroy {
|
||||
|
||||
constructor(private router: Router,
|
||||
public translate: TranslateService,
|
||||
private projectService: ProjectService,
|
||||
private mgmtService: ManagementService,
|
||||
private toast: ToastService,
|
||||
) { }
|
||||
|
||||
@ -90,7 +90,7 @@ export class OwnedProjectListComponent implements OnInit, OnDestroy {
|
||||
|
||||
private async getData(limit: number, offset: number): Promise<void> {
|
||||
this.loadingSubject.next(true);
|
||||
this.projectService.SearchProjects(limit, offset).then(res => {
|
||||
this.mgmtService.SearchProjects(limit, offset).then(res => {
|
||||
const response = res.toObject();
|
||||
this.ownedProjectList = response.resultList;
|
||||
this.totalResult = response.totalResult;
|
||||
@ -113,7 +113,7 @@ export class OwnedProjectListComponent implements OnInit, OnDestroy {
|
||||
|
||||
public reactivateSelectedProjects(): void {
|
||||
const promises = this.selection.selected.map(project => {
|
||||
this.projectService.ReactivateProject(project.projectId);
|
||||
this.mgmtService.ReactivateProject(project.projectId);
|
||||
});
|
||||
|
||||
Promise.all(promises).then(() => {
|
||||
@ -126,7 +126,7 @@ export class OwnedProjectListComponent implements OnInit, OnDestroy {
|
||||
|
||||
public deactivateSelectedProjects(): void {
|
||||
const promises = this.selection.selected.map(project => {
|
||||
this.projectService.DeactivateProject(project.projectId);
|
||||
this.mgmtService.DeactivateProject(project.projectId);
|
||||
});
|
||||
|
||||
Promise.all(promises).then(() => {
|
||||
|
@ -2,7 +2,7 @@ import { DataSource } from '@angular/cdk/collections';
|
||||
import { BehaviorSubject, from, Observable, of } from 'rxjs';
|
||||
import { catchError, finalize, map } from 'rxjs/operators';
|
||||
import { ProjectMemberView } from 'src/app/proto/generated/management_pb';
|
||||
import { ProjectService } from 'src/app/services/project.service';
|
||||
import { ManagementService } from 'src/app/services/mgmt.service';
|
||||
|
||||
/**
|
||||
* Data source for the ProjectMembers view. This class should
|
||||
@ -16,7 +16,7 @@ export class ProjectGrantDetailDataSource extends DataSource<ProjectMemberView.A
|
||||
private loadingSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
|
||||
public loading$: Observable<boolean> = this.loadingSubject.asObservable();
|
||||
|
||||
constructor(private projectService: ProjectService) {
|
||||
constructor(private mgmtService: ManagementService) {
|
||||
super();
|
||||
}
|
||||
|
||||
@ -26,7 +26,7 @@ export class ProjectGrantDetailDataSource extends DataSource<ProjectMemberView.A
|
||||
|
||||
this.loadingSubject.next(true);
|
||||
|
||||
from(this.projectService.SearchProjectGrantMembers(projectId, grantId, pageSize, offset)).pipe(
|
||||
from(this.mgmtService.SearchProjectGrantMembers(projectId, grantId, pageSize, offset)).pipe(
|
||||
map(resp => {
|
||||
this.totalResult = resp.toObject().totalResult;
|
||||
return resp.toObject().resultList;
|
||||
|
@ -8,8 +8,7 @@ import {
|
||||
ProjectRoleView,
|
||||
ProjectType,
|
||||
} from 'src/app/proto/generated/management_pb';
|
||||
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({
|
||||
@ -31,8 +30,7 @@ export class ProjectGrantDetailComponent {
|
||||
public memberRoleOptions: ProjectRoleView.AsObject[] = [];
|
||||
|
||||
constructor(
|
||||
private orgService: OrgService,
|
||||
private projectService: ProjectService,
|
||||
private mgmtService: ManagementService,
|
||||
private route: ActivatedRoute,
|
||||
private toast: ToastService,
|
||||
) {
|
||||
@ -40,13 +38,13 @@ export class ProjectGrantDetailComponent {
|
||||
this.projectid = params.projectid;
|
||||
this.grantid = params.grantid;
|
||||
|
||||
this.orgService.GetIam().then(iam => {
|
||||
this.mgmtService.GetIam().then(iam => {
|
||||
this.isZitadel = iam.toObject().iamProjectId === this.projectid;
|
||||
});
|
||||
|
||||
this.getRoleOptions(params.projectid);
|
||||
|
||||
this.projectService.ProjectGrantByID(this.grantid, this.projectid).then((grant) => {
|
||||
this.mgmtService.ProjectGrantByID(this.grantid, this.projectid).then((grant) => {
|
||||
this.grant = grant.toObject();
|
||||
});
|
||||
});
|
||||
@ -54,14 +52,14 @@ export class ProjectGrantDetailComponent {
|
||||
|
||||
public changeState(newState: ProjectGrantState): void {
|
||||
if (newState === ProjectGrantState.PROJECTGRANTSTATE_ACTIVE) {
|
||||
this.projectService.ReactivateProjectGrant(this.grantid, this.projectid).then(() => {
|
||||
this.mgmtService.ReactivateProjectGrant(this.grantid, this.projectid).then(() => {
|
||||
this.toast.showInfo('PROJECT.TOAST.REACTIVATED', true);
|
||||
this.grant.state = newState;
|
||||
}).catch(error => {
|
||||
this.toast.showError(error);
|
||||
});
|
||||
} else if (newState === ProjectGrantState.PROJECTGRANTSTATE_INACTIVE) {
|
||||
this.projectService.DeactivateProjectGrant(this.grantid, this.projectid).then(() => {
|
||||
this.mgmtService.DeactivateProjectGrant(this.grantid, this.projectid).then(() => {
|
||||
this.toast.showInfo('PROJECT.TOAST.DEACTIVATED', true);
|
||||
this.grant.state = newState;
|
||||
}).catch(error => {
|
||||
@ -71,13 +69,13 @@ export class ProjectGrantDetailComponent {
|
||||
}
|
||||
|
||||
public getRoleOptions(projectId: string): void {
|
||||
this.projectService.SearchProjectRoles(projectId, 100, 0).then(resp => {
|
||||
this.mgmtService.SearchProjectRoles(projectId, 100, 0).then(resp => {
|
||||
this.memberRoleOptions = resp.toObject().resultList;
|
||||
});
|
||||
}
|
||||
|
||||
updateRoles(selectionChange: MatSelectChange): void {
|
||||
this.projectService.UpdateProjectGrant(this.grant.id, this.grant.projectId, selectionChange.value)
|
||||
this.mgmtService.UpdateProjectGrant(this.grant.id, this.grant.projectId, selectionChange.value)
|
||||
.then((newgrant: ProjectGrant) => {
|
||||
this.toast.showInfo('PROJECT.TOAST.GRANTUPDATED');
|
||||
}).catch(error => {
|
||||
|
@ -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 { ProjectMember } from 'src/app/proto/generated/management_pb';
|
||||
import { ProjectService } from 'src/app/services/project.service';
|
||||
import { ManagementService } from 'src/app/services/mgmt.service';
|
||||
|
||||
/**
|
||||
* Data source for the ProjectMembers view. This class should
|
||||
@ -18,7 +18,7 @@ export class ProjectGrantMembersDataSource extends DataSource<ProjectMember.AsOb
|
||||
private loadingSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
|
||||
public loading$: Observable<boolean> = this.loadingSubject.asObservable();
|
||||
|
||||
constructor(private projectService: ProjectService) {
|
||||
constructor(private mgmtService: ManagementService) {
|
||||
super();
|
||||
}
|
||||
|
||||
@ -28,7 +28,7 @@ export class ProjectGrantMembersDataSource extends DataSource<ProjectMember.AsOb
|
||||
|
||||
this.loadingSubject.next(true);
|
||||
|
||||
from(this.projectService.SearchProjectGrantMembers(projectId,
|
||||
from(this.mgmtService.SearchProjectGrantMembers(projectId,
|
||||
grantId, pageSize, offset)).pipe(
|
||||
map(resp => {
|
||||
const response = resp.toObject();
|
||||
|
@ -6,7 +6,7 @@ import { MatSelectChange } from '@angular/material/select';
|
||||
import { MatTable } from '@angular/material/table';
|
||||
import { tap } from 'rxjs/operators';
|
||||
import { ProjectMember, ProjectType } from 'src/app/proto/generated/management_pb';
|
||||
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 {
|
||||
@ -39,11 +39,11 @@ export class ProjectGrantMembersComponent implements AfterViewInit, OnInit {
|
||||
public memberRoleOptions: string[] = [];
|
||||
|
||||
constructor(
|
||||
private projectService: ProjectService,
|
||||
private mgmtService: ManagementService,
|
||||
private dialog: MatDialog,
|
||||
private toast: ToastService,
|
||||
) {
|
||||
this.dataSource = new ProjectGrantMembersDataSource(this.projectService);
|
||||
this.dataSource = new ProjectGrantMembersDataSource(this.mgmtService);
|
||||
this.getRoleOptions();
|
||||
}
|
||||
|
||||
@ -61,13 +61,13 @@ export class ProjectGrantMembersComponent implements AfterViewInit, OnInit {
|
||||
|
||||
public getRoleOptions(): void {
|
||||
if (this.type === ProjectType.PROJECTTYPE_GRANTED) {
|
||||
this.projectService.GetProjectGrantMemberRoles().then(resp => {
|
||||
this.mgmtService.GetProjectGrantMemberRoles().then(resp => {
|
||||
this.memberRoleOptions = resp.toObject().rolesList;
|
||||
}).catch(error => {
|
||||
this.toast.showError(error);
|
||||
});
|
||||
} else if (this.type === ProjectType.PROJECTTYPE_OWNED) {
|
||||
this.projectService.GetProjectMemberRoles().then(resp => {
|
||||
this.mgmtService.GetProjectMemberRoles().then(resp => {
|
||||
this.memberRoleOptions = resp.toObject().rolesList;
|
||||
}).catch(error => {
|
||||
this.toast.showError(error);
|
||||
@ -86,7 +86,7 @@ export class ProjectGrantMembersComponent implements AfterViewInit, OnInit {
|
||||
|
||||
public removeProjectMemberSelection(): void {
|
||||
Promise.all(this.selection.selected.map(member => {
|
||||
return this.projectService.RemoveProjectGrantMember(this.projectId, this.grantId, member.userId).then(() => {
|
||||
return this.mgmtService.RemoveProjectGrantMember(this.projectId, this.grantId, member.userId).then(() => {
|
||||
this.toast.showInfo('PROJECT.GRANT.TOAST.PROJECTGRANTMEMBERREMOVED', true);
|
||||
}).catch(error => {
|
||||
this.toast.showError(error);
|
||||
@ -107,7 +107,7 @@ export class ProjectGrantMembersComponent implements AfterViewInit, OnInit {
|
||||
}
|
||||
|
||||
public async openAddMember(): Promise<any> {
|
||||
const keysList = (await this.projectService.GetProjectGrantMemberRoles()).toObject();
|
||||
const keysList = (await this.mgmtService.GetProjectGrantMemberRoles()).toObject();
|
||||
|
||||
const dialogRef = this.dialog.open(ProjectGrantMembersCreateDialogComponent, {
|
||||
data: {
|
||||
@ -119,7 +119,7 @@ export class ProjectGrantMembersComponent implements AfterViewInit, OnInit {
|
||||
dialogRef.afterClosed().subscribe((dataToAdd: ProjectGrantMembersCreateDialogExportType) => {
|
||||
if (dataToAdd) {
|
||||
Promise.all(dataToAdd.userIds.map((userid: string) => {
|
||||
return this.projectService.AddProjectGrantMember(
|
||||
return this.mgmtService.AddProjectGrantMember(
|
||||
this.projectId,
|
||||
this.grantId,
|
||||
userid,
|
||||
@ -135,7 +135,7 @@ export class ProjectGrantMembersComponent implements AfterViewInit, OnInit {
|
||||
}
|
||||
|
||||
updateRoles(member: ProjectMember.AsObject, selectionChange: MatSelectChange): void {
|
||||
this.projectService.ChangeProjectGrantMember(this.projectId, this.grantId, member.userId, selectionChange.value)
|
||||
this.mgmtService.ChangeProjectGrantMember(this.projectId, this.grantId, member.userId, selectionChange.value)
|
||||
.then((newmember: ProjectMember) => {
|
||||
this.toast.showInfo('PROJECT.GRANT.TOAST.PROJECTGRANTMEMBERCHANGED', true);
|
||||
}).catch(error => {
|
||||
|
@ -2,7 +2,7 @@ import { Location } from '@angular/common';
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import { Project, ProjectCreateRequest } from 'src/app/proto/generated/management_pb';
|
||||
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({
|
||||
@ -16,7 +16,7 @@ export class ProjectCreateComponent implements OnInit {
|
||||
constructor(
|
||||
private router: Router,
|
||||
private toast: ToastService,
|
||||
private projectService: ProjectService,
|
||||
private mgmtService: ManagementService,
|
||||
private _location: Location,
|
||||
) { }
|
||||
|
||||
@ -25,7 +25,7 @@ export class ProjectCreateComponent implements OnInit {
|
||||
public ngOnInit(): void { }
|
||||
|
||||
public saveProject(): void {
|
||||
this.projectService
|
||||
this.mgmtService
|
||||
.CreateProject(this.project)
|
||||
.then((data: Project) => {
|
||||
this.router.navigate(['projects', data.getId()]);
|
||||
|
@ -3,9 +3,8 @@ import { Component, OnDestroy, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { Subscription } from 'rxjs';
|
||||
import { Org, ProjectRole } from 'src/app/proto/generated/management_pb';
|
||||
import { AuthService } from 'src/app/services/auth.service';
|
||||
import { OrgService } from 'src/app/services/org.service';
|
||||
import { ProjectService } from 'src/app/services/project.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';
|
||||
|
||||
@Component({
|
||||
@ -24,11 +23,10 @@ export class ProjectGrantCreateComponent implements OnInit, OnDestroy {
|
||||
|
||||
private routeSubscription: Subscription = new Subscription();
|
||||
constructor(
|
||||
private orgService: OrgService,
|
||||
private route: ActivatedRoute,
|
||||
private toast: ToastService,
|
||||
private projectService: ProjectService,
|
||||
private authService: AuthService,
|
||||
private mgmtService: ManagementService,
|
||||
private authService: GrpcAuthService,
|
||||
private _location: Location,
|
||||
) { }
|
||||
|
||||
@ -43,7 +41,7 @@ export class ProjectGrantCreateComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
public searchOrg(domain: string): void {
|
||||
this.orgService.getOrgByDomainGlobal(domain).then((ret) => {
|
||||
this.mgmtService.getOrgByDomainGlobal(domain).then((ret) => {
|
||||
const tmp = ret.toObject();
|
||||
this.authService.GetActiveOrg().then((org) => {
|
||||
if (tmp !== org) {
|
||||
@ -61,7 +59,7 @@ export class ProjectGrantCreateComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
public addGrant(): void {
|
||||
this.projectService
|
||||
this.mgmtService
|
||||
.CreateProjectGrant(this.org.id, this.projectId, this.rolesKeyList)
|
||||
.then((data) => {
|
||||
this.close();
|
||||
|
@ -5,7 +5,7 @@ import { FormArray, FormControl, FormGroup, Validators } from '@angular/forms';
|
||||
import { ActivatedRoute, Params, Router } from '@angular/router';
|
||||
import { Subscription } from 'rxjs';
|
||||
import { ProjectRoleAdd } from 'src/app/proto/generated/management_pb';
|
||||
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({
|
||||
@ -45,7 +45,7 @@ export class ProjectRoleCreateComponent implements OnInit, OnDestroy {
|
||||
private router: Router,
|
||||
private route: ActivatedRoute,
|
||||
private toast: ToastService,
|
||||
private projectService: ProjectService,
|
||||
private mgmtService: ManagementService,
|
||||
private _location: Location,
|
||||
) {
|
||||
this.formGroup = new FormGroup({
|
||||
@ -92,7 +92,7 @@ export class ProjectRoleCreateComponent implements OnInit, OnDestroy {
|
||||
return role;
|
||||
});
|
||||
|
||||
this.projectService.BulkAddProjectRole(this.projectId, rolesToAdd).then(() => {
|
||||
this.mgmtService.BulkAddProjectRole(this.projectId, rolesToAdd).then(() => {
|
||||
this.router.navigate(['projects', this.projectId]);
|
||||
}).catch(error => {
|
||||
this.toast.showError(error);
|
||||
|
@ -5,9 +5,8 @@ import { Subscription } from 'rxjs';
|
||||
import { UserGrantContext } from 'src/app/modules/user-grants/user-grants-datasource';
|
||||
import { Org } from 'src/app/proto/generated/auth_pb';
|
||||
import { ProjectGrantView, ProjectRole, ProjectView, User, UserGrant } from 'src/app/proto/generated/management_pb';
|
||||
import { AuthService } from 'src/app/services/auth.service';
|
||||
import { MgmtUserService } from 'src/app/services/mgmt-user.service';
|
||||
import { ProjectService } from 'src/app/services/project.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';
|
||||
|
||||
@Component({
|
||||
@ -35,12 +34,12 @@ export class UserGrantCreateComponent implements OnDestroy {
|
||||
|
||||
public grantRolesKeyList: string[] = [];
|
||||
constructor(
|
||||
private authService: AuthService,
|
||||
private userService: MgmtUserService,
|
||||
private userService: ManagementService,
|
||||
private toast: ToastService,
|
||||
private _location: Location,
|
||||
private route: ActivatedRoute,
|
||||
private projectService: ProjectService,
|
||||
private authService: GrpcAuthService,
|
||||
private mgmtService: ManagementService,
|
||||
) {
|
||||
this.subscription = this.route.params.subscribe((params: Params) => {
|
||||
const { context, projectid, grantid, userid } = params;
|
||||
@ -54,7 +53,7 @@ export class UserGrantCreateComponent implements OnDestroy {
|
||||
this.context = UserGrantContext.OWNED_PROJECT;
|
||||
} else if (this.projectId && this.grantId) {
|
||||
this.context = UserGrantContext.GRANTED_PROJECT;
|
||||
this.projectService.GetGrantedProjectByID(this.projectId, this.grantId).then(resp => {
|
||||
this.mgmtService.GetGrantedProjectByID(this.projectId, this.grantId).then(resp => {
|
||||
this.grantRolesKeyList = resp.toObject().roleKeysList;
|
||||
}).catch(error => {
|
||||
this.toast.showError(error);
|
||||
|
@ -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));
|
||||
|
||||
|
@ -1,13 +1,13 @@
|
||||
import { Pipe, PipeTransform } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
import { AuthService } from '../services/auth.service';
|
||||
import { GrpcAuthService } from '../services/grpc-auth.service';
|
||||
|
||||
@Pipe({
|
||||
name: 'hasRole',
|
||||
})
|
||||
export class HasRolePipe implements PipeTransform {
|
||||
constructor(private authService: AuthService) { }
|
||||
constructor(private authService: GrpcAuthService) { }
|
||||
|
||||
public transform(values: string[]): Observable<boolean> {
|
||||
return this.authService.isAllowed(values);
|
||||
|
@ -1,8 +1,6 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Empty } from 'google-protobuf/google/protobuf/empty_pb';
|
||||
import { Metadata } from 'grpc-web';
|
||||
|
||||
import { AdminServicePromiseClient } from '../proto/generated/admin_grpc_web_pb';
|
||||
import {
|
||||
AddIamMemberRequest,
|
||||
ChangeIamMemberRequest,
|
||||
@ -24,29 +22,13 @@ import {
|
||||
ViewID,
|
||||
Views,
|
||||
} from '../proto/generated/admin_pb';
|
||||
import { GrpcBackendService } from './grpc-backend.service';
|
||||
import { GrpcService, RequestFactory, ResponseMapper } from './grpc.service';
|
||||
import { GrpcService } from './grpc.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class AdminService {
|
||||
constructor(private readonly grpcService: GrpcService, private grpcBackendService: GrpcBackendService) { }
|
||||
|
||||
public async request<TReq, TResp, TMappedResp>(
|
||||
requestFn: RequestFactory<AdminServicePromiseClient, TReq, TResp>,
|
||||
request: TReq,
|
||||
responseMapper: ResponseMapper<TResp, TMappedResp>,
|
||||
metadata?: Metadata,
|
||||
): Promise<TMappedResp> {
|
||||
const mappedRequestFn = requestFn(this.grpcService.admin).bind(this.grpcService.mgmt);
|
||||
const response = await this.grpcBackendService.runRequest(
|
||||
mappedRequestFn,
|
||||
request,
|
||||
metadata,
|
||||
);
|
||||
return responseMapper(response);
|
||||
}
|
||||
constructor(private readonly grpcService: GrpcService) { }
|
||||
|
||||
public async SetUpOrg(
|
||||
createOrgRequest: CreateOrgRequest,
|
||||
@ -57,46 +39,29 @@ export class AdminService {
|
||||
req.setOrg(createOrgRequest);
|
||||
req.setUser(registerUserRequest);
|
||||
|
||||
return await this.request(
|
||||
c => c.setUpOrg,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
return this.grpcService.admin.setUpOrg(req);
|
||||
}
|
||||
|
||||
public async GetIamMemberRoles(): Promise<IamMemberRoles> {
|
||||
return await this.request(
|
||||
c => c.getIamMemberRoles,
|
||||
new Empty(),
|
||||
f => f,
|
||||
);
|
||||
const req = new Empty();
|
||||
return this.grpcService.admin.getIamMemberRoles(req);
|
||||
}
|
||||
|
||||
public async GetViews(): Promise<Views> {
|
||||
return await this.request(
|
||||
c => c.getViews,
|
||||
new Empty(),
|
||||
f => f,
|
||||
);
|
||||
const req = new Empty();
|
||||
return this.grpcService.admin.getViews(req);
|
||||
}
|
||||
|
||||
public async GetFailedEvents(): Promise<FailedEvents> {
|
||||
return await this.request(
|
||||
c => c.getFailedEvents,
|
||||
new Empty(),
|
||||
f => f,
|
||||
);
|
||||
const req = new Empty();
|
||||
return this.grpcService.admin.getFailedEvents(req);
|
||||
}
|
||||
|
||||
public async ClearView(viewname: string, db: string): Promise<Empty> {
|
||||
const req: ViewID = new ViewID();
|
||||
req.setDatabase(db);
|
||||
req.setViewName(viewname);
|
||||
return await this.request(
|
||||
c => c.clearView,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
return this.grpcService.admin.clearView(req);
|
||||
}
|
||||
|
||||
public async RemoveFailedEvent(viewname: string, db: string, sequence: number): Promise<Empty> {
|
||||
@ -104,11 +69,7 @@ export class AdminService {
|
||||
req.setDatabase(db);
|
||||
req.setViewName(viewname);
|
||||
req.setFailedSequence(sequence);
|
||||
return await this.request(
|
||||
c => c.removeFailedEvent,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
return this.grpcService.admin.removeFailedEvent(req);
|
||||
}
|
||||
|
||||
public async SearchIamMembers(
|
||||
@ -122,11 +83,7 @@ export class AdminService {
|
||||
if (queryList) {
|
||||
req.setQueriesList(queryList);
|
||||
}
|
||||
return await this.request(
|
||||
c => c.searchIamMembers,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
return this.grpcService.admin.searchIamMembers(req);
|
||||
}
|
||||
|
||||
public async RemoveIamMember(
|
||||
@ -135,11 +92,7 @@ export class AdminService {
|
||||
const req = new RemoveIamMemberRequest();
|
||||
req.setUserId(userId);
|
||||
|
||||
return await this.request(
|
||||
c => c.removeIamMember,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
return this.grpcService.admin.removeIamMember(req);
|
||||
}
|
||||
|
||||
public async AddIamMember(
|
||||
@ -150,11 +103,7 @@ export class AdminService {
|
||||
req.setUserId(userId);
|
||||
req.setRolesList(rolesList);
|
||||
|
||||
return await this.request(
|
||||
c => c.addIamMember,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
return this.grpcService.admin.addIamMember(req);
|
||||
}
|
||||
|
||||
public async ChangeIamMember(
|
||||
@ -165,22 +114,14 @@ export class AdminService {
|
||||
req.setUserId(userId);
|
||||
req.setRolesList(rolesList);
|
||||
|
||||
return await this.request(
|
||||
c => c.changeIamMember,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
return this.grpcService.admin.changeIamMember(req);
|
||||
}
|
||||
|
||||
public async GetOrgIamPolicy(orgId: string): Promise<OrgIamPolicy> {
|
||||
const req = new OrgIamPolicyID();
|
||||
req.setOrgId(orgId);
|
||||
|
||||
return await this.request(
|
||||
c => c.getOrgIamPolicy,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
return this.grpcService.admin.getOrgIamPolicy(req);
|
||||
}
|
||||
|
||||
public async CreateOrgIamPolicy(
|
||||
@ -192,11 +133,7 @@ export class AdminService {
|
||||
req.setDescription(description);
|
||||
req.setUserLoginMustBeDomain(userLoginMustBeDomain);
|
||||
|
||||
return await this.request(
|
||||
c => c.createOrgIamPolicy,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
return this.grpcService.admin.createOrgIamPolicy(req);
|
||||
}
|
||||
|
||||
public async UpdateOrgIamPolicy(
|
||||
@ -207,12 +144,7 @@ export class AdminService {
|
||||
req.setOrgId(orgId);
|
||||
req.setDescription(description);
|
||||
req.setUserLoginMustBeDomain(userLoginMustBeDomain);
|
||||
|
||||
return await this.request(
|
||||
c => c.updateOrgIamPolicy,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
return this.grpcService.admin.updateOrgIamPolicy(req);
|
||||
}
|
||||
|
||||
public async deleteOrgIamPolicy(
|
||||
@ -220,10 +152,6 @@ export class AdminService {
|
||||
): Promise<Empty> {
|
||||
const req = new OrgIamPolicyID();
|
||||
req.setOrgId(orgId);
|
||||
return await this.request(
|
||||
c => c.deleteOrgIamPolicy,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
return this.grpcService.admin.deleteOrgIamPolicy(req);
|
||||
}
|
||||
}
|
||||
|
@ -1,298 +0,0 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Empty } from 'google-protobuf/google/protobuf/empty_pb';
|
||||
import { Metadata } from 'grpc-web';
|
||||
|
||||
import { AuthServicePromiseClient } from '../proto/generated/auth_grpc_web_pb';
|
||||
import {
|
||||
Changes,
|
||||
ChangesRequest,
|
||||
Gender,
|
||||
MfaOtpResponse,
|
||||
MultiFactors,
|
||||
MyPermissions,
|
||||
MyProjectOrgSearchQuery,
|
||||
MyProjectOrgSearchRequest,
|
||||
MyProjectOrgSearchResponse,
|
||||
PasswordChange,
|
||||
PasswordComplexityPolicy,
|
||||
UpdateUserAddressRequest,
|
||||
UpdateUserEmailRequest,
|
||||
UpdateUserPhoneRequest,
|
||||
UpdateUserProfileRequest,
|
||||
UserAddress,
|
||||
UserEmail,
|
||||
UserPhone,
|
||||
UserProfile,
|
||||
UserProfileView,
|
||||
UserSessionViews,
|
||||
UserView,
|
||||
VerifyMfaOtp,
|
||||
VerifyUserPhoneRequest,
|
||||
} from '../proto/generated/auth_pb';
|
||||
import { GrpcBackendService } from './grpc-backend.service';
|
||||
import { GrpcService, RequestFactory, ResponseMapper } from './grpc.service';
|
||||
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class AuthUserService {
|
||||
constructor(private readonly grpcClient: GrpcService,
|
||||
private grpcBackendService: GrpcBackendService,
|
||||
) { }
|
||||
|
||||
public async request<TReq, TResp, TMappedResp>(
|
||||
requestFn: RequestFactory<AuthServicePromiseClient, TReq, TResp>,
|
||||
request: TReq,
|
||||
responseMapper: ResponseMapper<TResp, TMappedResp>,
|
||||
metadata?: Metadata,
|
||||
): Promise<TMappedResp> {
|
||||
const mappedRequestFn = requestFn(this.grpcClient.auth).bind(this.grpcClient.auth);
|
||||
const response = await this.grpcBackendService.runRequest(
|
||||
mappedRequestFn,
|
||||
request,
|
||||
metadata,
|
||||
);
|
||||
return responseMapper(response);
|
||||
}
|
||||
|
||||
public async GetMyUserProfile(): Promise<UserProfileView> {
|
||||
return await this.request(
|
||||
c => c.getMyUserProfile,
|
||||
new Empty(),
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async GetMyPasswordComplexityPolicy(): Promise<PasswordComplexityPolicy> {
|
||||
return await this.request(
|
||||
c => c.getMyPasswordComplexityPolicy,
|
||||
new Empty(),
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async GetMyUser(): Promise<UserView> {
|
||||
return await this.request(
|
||||
c => c.getMyUser,
|
||||
new Empty(),
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async GetMyMfas(): Promise<MultiFactors> {
|
||||
return await this.request(
|
||||
c => c.getMyMfas,
|
||||
new Empty(),
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async SearchMyProjectOrgs(
|
||||
limit: number,
|
||||
offset: number,
|
||||
queryList?: MyProjectOrgSearchQuery[],
|
||||
): Promise<MyProjectOrgSearchResponse> {
|
||||
const req: MyProjectOrgSearchRequest = new MyProjectOrgSearchRequest();
|
||||
req.setOffset(offset);
|
||||
req.setLimit(limit);
|
||||
if (queryList) {
|
||||
req.setQueriesList(queryList);
|
||||
}
|
||||
|
||||
return await this.request(
|
||||
c => c.searchMyProjectOrgs,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async SaveMyUserProfile(
|
||||
firstName?: string,
|
||||
lastName?: string,
|
||||
nickName?: string,
|
||||
preferredLanguage?: string,
|
||||
gender?: Gender,
|
||||
): Promise<UserProfile> {
|
||||
const req = new UpdateUserProfileRequest();
|
||||
if (firstName) {
|
||||
req.setFirstName(firstName);
|
||||
}
|
||||
if (lastName) {
|
||||
req.setLastName(lastName);
|
||||
}
|
||||
if (nickName) {
|
||||
req.setNickName(nickName);
|
||||
}
|
||||
if (gender) {
|
||||
req.setGender(gender);
|
||||
}
|
||||
if (preferredLanguage) {
|
||||
req.setPreferredLanguage(preferredLanguage);
|
||||
}
|
||||
return await this.request(
|
||||
c => c.updateMyUserProfile,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async getMyUserSessions(): Promise<UserSessionViews> {
|
||||
return await this.request(
|
||||
c => c.getMyUserSessions,
|
||||
new Empty(),
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async GetMyUserEmail(): Promise<UserEmail> {
|
||||
return await this.request(
|
||||
c => c.getMyUserEmail,
|
||||
new Empty(),
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async SaveMyUserEmail(email: string): Promise<UserEmail> {
|
||||
const req = new UpdateUserEmailRequest();
|
||||
req.setEmail(email);
|
||||
return await this.request(
|
||||
c => c.changeMyUserEmail,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async RemoveMyUserPhone(): Promise<Empty> {
|
||||
return await this.request(
|
||||
c => c.removeMyUserPhone,
|
||||
new Empty(),
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async GetMyzitadelPermissions(): Promise<MyPermissions> {
|
||||
return await this.request(
|
||||
c => c.getMyZitadelPermissions,
|
||||
new Empty(),
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async GetMyUserPhone(): Promise<UserPhone> {
|
||||
// return this.grpcClient.auth.getMyUserPhone(new Empty());
|
||||
return await this.request(
|
||||
c => c.getMyUserPhone,
|
||||
new Empty(),
|
||||
(f: UserPhone) => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async SaveMyUserPhone(phone: string): Promise<UserPhone> {
|
||||
const req = new UpdateUserPhoneRequest();
|
||||
req.setPhone(phone);
|
||||
return await this.request(
|
||||
c => c.changeMyUserPhone,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async GetMyUserAddress(): Promise<UserAddress> {
|
||||
return await this.request(
|
||||
c => c.getMyUserAddress,
|
||||
new Empty(),
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async ResendEmailVerification(): Promise<Empty> {
|
||||
const req = new Empty();
|
||||
return await this.request(
|
||||
c => c.resendMyEmailVerificationMail,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async ResendPhoneVerification(): Promise<Empty> {
|
||||
const req = new Empty();
|
||||
return await this.request(
|
||||
c => c.resendMyPhoneVerificationCode,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async ChangeMyPassword(oldPassword: string, newPassword: string): Promise<Empty> {
|
||||
const req = new PasswordChange();
|
||||
req.setOldPassword(oldPassword);
|
||||
req.setNewPassword(newPassword);
|
||||
return await this.request(
|
||||
c => c.changeMyPassword,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async AddMfaOTP(): Promise<MfaOtpResponse> {
|
||||
return await this.request(
|
||||
c => c.addMfaOTP,
|
||||
new Empty(),
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async RemoveMfaOTP(): Promise<Empty> {
|
||||
return await this.request(
|
||||
c => c.removeMfaOTP,
|
||||
new Empty(),
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async VerifyMfaOTP(code: string): Promise<Empty> {
|
||||
const req = new VerifyMfaOtp();
|
||||
req.setCode(code);
|
||||
return await this.request(
|
||||
c => c.verifyMfaOTP,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async VerifyMyUserPhone(code: string): Promise<Empty> {
|
||||
const req = new VerifyUserPhoneRequest();
|
||||
req.setCode(code);
|
||||
return await this.request(
|
||||
c => c.verifyMyUserPhone,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async SaveMyUserAddress(address: UserAddress.AsObject): Promise<UserAddress> {
|
||||
const req = new UpdateUserAddressRequest();
|
||||
req.setStreetAddress(address.streetAddress);
|
||||
req.setPostalCode(address.postalCode);
|
||||
req.setLocality(address.locality);
|
||||
req.setRegion(address.region);
|
||||
req.setCountry(address.country);
|
||||
return await this.request(
|
||||
c => c.updateMyUserAddress,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async GetMyUserChanges(limit: number, sequenceoffset: number): Promise<Changes> {
|
||||
const req = new ChangesRequest();
|
||||
req.setLimit(limit);
|
||||
req.setSequenceOffset(sequenceoffset);
|
||||
return await this.request(
|
||||
c => c.getMyUserChanges,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
}
|
@ -1,175 +0,0 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { AuthConfig, OAuthService } from 'angular-oauth2-oidc';
|
||||
import { BehaviorSubject, from, merge, Observable, of, Subject } from 'rxjs';
|
||||
import { catchError, filter, finalize, first, map, mergeMap, switchMap, take, timeout } from 'rxjs/operators';
|
||||
|
||||
import { Org, UserProfileView } from '../proto/generated/auth_pb';
|
||||
import { AuthUserService } from './auth-user.service';
|
||||
import { GrpcService } from './grpc.service';
|
||||
import { StatehandlerService } from './statehandler.service';
|
||||
import { StorageKey, StorageService } from './storage.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class AuthService {
|
||||
private cachedOrgs: Org.AsObject[] = [];
|
||||
private _activeOrgChanged: Subject<Org.AsObject> = new Subject();
|
||||
public user!: Observable<UserProfileView.AsObject>;
|
||||
private _authenticated: boolean = false;
|
||||
private readonly _authenticationChanged: BehaviorSubject<
|
||||
boolean
|
||||
> = new BehaviorSubject(this.authenticated);
|
||||
|
||||
private zitadelPermissions: BehaviorSubject<string[]> = new BehaviorSubject(['user.resourceowner']);
|
||||
|
||||
constructor(
|
||||
private grpcService: GrpcService,
|
||||
private config: AuthConfig,
|
||||
private oauthService: OAuthService,
|
||||
private userService: AuthUserService,
|
||||
private storage: StorageService,
|
||||
private statehandler: StatehandlerService,
|
||||
) {
|
||||
this.user = merge(
|
||||
of(this.oauthService.getAccessToken()).pipe(
|
||||
filter(token => token ? true : false),
|
||||
),
|
||||
this.oauthService.events.pipe(
|
||||
filter(e => e.type === 'token_received'),
|
||||
timeout(this.oauthService.waitForTokenInMsec || 0),
|
||||
catchError(_ => of(null)), // timeout is not an error
|
||||
map(_ => this.oauthService.getAccessToken()),
|
||||
),
|
||||
).pipe(
|
||||
take(1),
|
||||
mergeMap(() => {
|
||||
return from(this.userService.GetMyUserProfile().then(userprofile => userprofile.toObject()));
|
||||
}),
|
||||
finalize(() => {
|
||||
this.loadPermissions();
|
||||
}),
|
||||
);
|
||||
|
||||
this.activeOrgChanged.subscribe(() => {
|
||||
this.loadPermissions();
|
||||
});
|
||||
}
|
||||
|
||||
private loadPermissions(): void {
|
||||
merge([
|
||||
// this.authenticationChanged,
|
||||
this.activeOrgChanged.pipe(map(org => !!org)),
|
||||
]).pipe(
|
||||
first(),
|
||||
switchMap(() => from(this.userService.GetMyzitadelPermissions())),
|
||||
map(rolesResp => rolesResp.toObject().permissionsList),
|
||||
).subscribe(roles => {
|
||||
this.zitadelPermissions.next(roles);
|
||||
});
|
||||
}
|
||||
|
||||
public isAllowed(roles: string[] | RegExp[]): Observable<boolean> {
|
||||
if (roles && roles.length > 0) {
|
||||
return this.zitadelPermissions.pipe(switchMap(zroles => {
|
||||
return of(this.hasRoles(zroles, roles));
|
||||
}));
|
||||
} else {
|
||||
return of(false);
|
||||
}
|
||||
}
|
||||
|
||||
public hasRoles(userRoles: string[], requestedRoles: string[] | RegExp[]): boolean {
|
||||
return requestedRoles.findIndex((regexp: any) => {
|
||||
return userRoles.findIndex(role => {
|
||||
return (new RegExp(regexp)).test(role);
|
||||
}) > -1;
|
||||
}) > -1;
|
||||
}
|
||||
|
||||
public get authenticated(): boolean {
|
||||
return this._authenticated;
|
||||
}
|
||||
|
||||
public get authenticationChanged(): Observable<boolean> {
|
||||
return this._authenticationChanged;
|
||||
}
|
||||
|
||||
public getOIDCUser(): Observable<any> {
|
||||
return from(this.oauthService.loadUserProfile());
|
||||
}
|
||||
|
||||
public async authenticate(
|
||||
config?: Partial<AuthConfig>,
|
||||
setState: boolean = true,
|
||||
force: boolean = false,
|
||||
): Promise<boolean> {
|
||||
this.config.issuer = config?.issuer || this.grpcService.issuer;
|
||||
this.config.clientId = config?.clientId || this.grpcService.clientid;
|
||||
this.config.redirectUri = config?.redirectUri || this.grpcService.redirectUri;
|
||||
this.config.postLogoutRedirectUri = config?.postLogoutRedirectUri || this.grpcService.postLogoutRedirectUri;
|
||||
this.config.customQueryParams = config?.customQueryParams;
|
||||
this.oauthService.configure(this.config);
|
||||
// this.oauthService.setupAutomaticSilentRefresh();
|
||||
this.oauthService.strictDiscoveryDocumentValidation = false;
|
||||
await this.oauthService.loadDiscoveryDocumentAndTryLogin();
|
||||
|
||||
this._authenticated = this.oauthService.hasValidAccessToken();
|
||||
|
||||
if (!this.oauthService.hasValidIdToken() || !this.authenticated || config || force) {
|
||||
const newState = setState ? await this.statehandler.createState().toPromise() : undefined;
|
||||
this.oauthService.initCodeFlow(newState);
|
||||
}
|
||||
this._authenticationChanged.next(this.authenticated);
|
||||
|
||||
return this.authenticated;
|
||||
}
|
||||
|
||||
public signout(): void {
|
||||
this.oauthService.logOut();
|
||||
this._authenticated = false;
|
||||
this._authenticationChanged.next(false);
|
||||
}
|
||||
|
||||
public get activeOrgChanged(): Observable<Org.AsObject> {
|
||||
return this._activeOrgChanged;
|
||||
}
|
||||
|
||||
public async GetActiveOrg(id?: string): Promise<Org.AsObject> {
|
||||
if (id) {
|
||||
const org = this.storage.getItem<Org.AsObject>(StorageKey.organization);
|
||||
if (org && this.cachedOrgs.find(tmp => tmp.id === org.id)) {
|
||||
return org;
|
||||
}
|
||||
return Promise.reject(new Error('no cached org'));
|
||||
} else {
|
||||
let orgs = this.cachedOrgs;
|
||||
if (orgs.length === 0) {
|
||||
orgs = (await this.userService.SearchMyProjectOrgs(10, 0)).toObject().resultList;
|
||||
this.cachedOrgs = orgs;
|
||||
}
|
||||
|
||||
const org = this.storage.getItem<Org.AsObject>(StorageKey.organization);
|
||||
if (org && orgs.find(tmp => tmp.id === org.id)) {
|
||||
return org;
|
||||
}
|
||||
|
||||
if (orgs.length === 0) {
|
||||
return Promise.reject(new Error('No organizations found!'));
|
||||
}
|
||||
const orgToSet = orgs.find(element => element.id !== '0' && element.name !== '');
|
||||
|
||||
if (orgToSet) {
|
||||
this.setActiveOrg(orgToSet);
|
||||
return Promise.resolve(orgToSet);
|
||||
}
|
||||
return Promise.resolve(orgs[0]);
|
||||
}
|
||||
}
|
||||
|
||||
public setActiveOrg(org: Org.AsObject): void {
|
||||
this.storage.setItem(StorageKey.organization, org);
|
||||
this._activeOrgChanged.next(org);
|
||||
}
|
||||
}
|
||||
|
69
console/src/app/services/authentication.service.ts
Normal file
69
console/src/app/services/authentication.service.ts
Normal file
@ -0,0 +1,69 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { AuthConfig, OAuthService } from 'angular-oauth2-oidc';
|
||||
import { BehaviorSubject, from, Observable } from 'rxjs';
|
||||
|
||||
import { StatehandlerService } from './statehandler.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class AuthenticationService {
|
||||
private authConfig!: AuthConfig;
|
||||
private _authenticated: boolean = false;
|
||||
private readonly _authenticationChanged: BehaviorSubject<
|
||||
boolean
|
||||
> = new BehaviorSubject(this.authenticated);
|
||||
|
||||
constructor(
|
||||
private oauthService: OAuthService,
|
||||
private statehandler: StatehandlerService,
|
||||
) { }
|
||||
|
||||
public initConfig(data: AuthConfig): void {
|
||||
this.authConfig = data;
|
||||
}
|
||||
|
||||
public get authenticated(): boolean {
|
||||
return this._authenticated;
|
||||
}
|
||||
|
||||
public get authenticationChanged(): Observable<boolean> {
|
||||
return this._authenticationChanged;
|
||||
}
|
||||
|
||||
public getOIDCUser(): Observable<any> {
|
||||
return from(this.oauthService.loadUserProfile());
|
||||
}
|
||||
|
||||
public async authenticate(
|
||||
config?: Partial<AuthConfig>,
|
||||
setState: boolean = true,
|
||||
force: boolean = false,
|
||||
): Promise<boolean> {
|
||||
if (config) {
|
||||
this.authConfig = config;
|
||||
}
|
||||
console.log(this.authConfig);
|
||||
this.oauthService.configure(this.authConfig);
|
||||
|
||||
this.oauthService.strictDiscoveryDocumentValidation = false;
|
||||
await this.oauthService.loadDiscoveryDocumentAndTryLogin();
|
||||
|
||||
this._authenticated = this.oauthService.hasValidAccessToken();
|
||||
|
||||
if (!this.oauthService.hasValidIdToken() || !this.authenticated || config || force) {
|
||||
const newState = setState ? await this.statehandler.createState().toPromise() : undefined;
|
||||
this.oauthService.initCodeFlow(newState);
|
||||
}
|
||||
this._authenticationChanged.next(this.authenticated);
|
||||
|
||||
return this.authenticated;
|
||||
}
|
||||
|
||||
public signout(): void {
|
||||
this.oauthService.logOut();
|
||||
this._authenticated = false;
|
||||
this._authenticationChanged.next(false);
|
||||
}
|
||||
}
|
||||
|
317
console/src/app/services/grpc-auth.service.ts
Normal file
317
console/src/app/services/grpc-auth.service.ts
Normal file
@ -0,0 +1,317 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { OAuthService } from 'angular-oauth2-oidc';
|
||||
import { Empty } from 'google-protobuf/google/protobuf/empty_pb';
|
||||
import { BehaviorSubject, from, merge, Observable, of, Subject } from 'rxjs';
|
||||
import { catchError, filter, finalize, first, map, mergeMap, switchMap, take, timeout } from 'rxjs/operators';
|
||||
|
||||
import {
|
||||
Changes,
|
||||
ChangesRequest,
|
||||
Gender,
|
||||
MfaOtpResponse,
|
||||
MultiFactors,
|
||||
MyPermissions,
|
||||
MyProjectOrgSearchQuery,
|
||||
MyProjectOrgSearchRequest,
|
||||
MyProjectOrgSearchResponse,
|
||||
Org,
|
||||
PasswordChange,
|
||||
PasswordComplexityPolicy,
|
||||
UpdateUserAddressRequest,
|
||||
UpdateUserEmailRequest,
|
||||
UpdateUserPhoneRequest,
|
||||
UpdateUserProfileRequest,
|
||||
UserAddress,
|
||||
UserEmail,
|
||||
UserPhone,
|
||||
UserProfile,
|
||||
UserProfileView,
|
||||
UserSessionViews,
|
||||
UserView,
|
||||
VerifyMfaOtp,
|
||||
VerifyUserPhoneRequest,
|
||||
} from '../proto/generated/auth_pb';
|
||||
import { GrpcService } from './grpc.service';
|
||||
import { StorageKey, StorageService } from './storage.service';
|
||||
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class GrpcAuthService {
|
||||
private _activeOrgChanged: Subject<Org.AsObject> = new Subject();
|
||||
public user!: Observable<UserProfileView.AsObject>;
|
||||
private zitadelPermissions: BehaviorSubject<string[]> = new BehaviorSubject(['user.resourceowner']);
|
||||
private cachedOrgs: Org.AsObject[] = [];
|
||||
|
||||
constructor(
|
||||
private readonly grpcService: GrpcService,
|
||||
private oauthService: OAuthService,
|
||||
private storage: StorageService,
|
||||
) {
|
||||
this.user = merge(
|
||||
of(this.oauthService.getAccessToken()).pipe(
|
||||
filter(token => token ? true : false),
|
||||
),
|
||||
this.oauthService.events.pipe(
|
||||
filter(e => e.type === 'token_received'),
|
||||
timeout(this.oauthService.waitForTokenInMsec || 0),
|
||||
catchError(_ => of(null)), // timeout is not an error
|
||||
map(_ => this.oauthService.getAccessToken()),
|
||||
),
|
||||
).pipe(
|
||||
take(1),
|
||||
mergeMap(() => {
|
||||
return from(this.GetMyUserProfile().then(userprofile => userprofile.toObject()));
|
||||
}),
|
||||
finalize(() => {
|
||||
this.loadPermissions();
|
||||
}),
|
||||
);
|
||||
|
||||
this.activeOrgChanged.subscribe(() => {
|
||||
this.loadPermissions();
|
||||
});
|
||||
}
|
||||
|
||||
public async GetActiveOrg(id?: string): Promise<Org.AsObject> {
|
||||
if (id) {
|
||||
const org = this.storage.getItem<Org.AsObject>(StorageKey.organization);
|
||||
if (org && this.cachedOrgs.find(tmp => tmp.id === org.id)) {
|
||||
return org;
|
||||
}
|
||||
return Promise.reject(new Error('no cached org'));
|
||||
} else {
|
||||
let orgs = this.cachedOrgs;
|
||||
if (orgs.length === 0) {
|
||||
orgs = (await this.SearchMyProjectOrgs(10, 0)).toObject().resultList;
|
||||
this.cachedOrgs = orgs;
|
||||
}
|
||||
|
||||
const org = this.storage.getItem<Org.AsObject>(StorageKey.organization);
|
||||
if (org && orgs.find(tmp => tmp.id === org.id)) {
|
||||
return org;
|
||||
}
|
||||
|
||||
if (orgs.length === 0) {
|
||||
return Promise.reject(new Error('No organizations found!'));
|
||||
}
|
||||
const orgToSet = orgs.find(element => element.id !== '0' && element.name !== '');
|
||||
|
||||
if (orgToSet) {
|
||||
this.setActiveOrg(orgToSet);
|
||||
return Promise.resolve(orgToSet);
|
||||
}
|
||||
return Promise.resolve(orgs[0]);
|
||||
}
|
||||
}
|
||||
|
||||
public get activeOrgChanged(): Observable<Org.AsObject> {
|
||||
return this._activeOrgChanged;
|
||||
}
|
||||
|
||||
public setActiveOrg(org: Org.AsObject): void {
|
||||
this.storage.setItem(StorageKey.organization, org);
|
||||
this._activeOrgChanged.next(org);
|
||||
}
|
||||
|
||||
private loadPermissions(): void {
|
||||
merge([
|
||||
// this.authenticationChanged,
|
||||
this.activeOrgChanged.pipe(map(org => !!org)),
|
||||
]).pipe(
|
||||
first(),
|
||||
switchMap(() => from(this.GetMyzitadelPermissions())),
|
||||
map(rolesResp => rolesResp.toObject().permissionsList),
|
||||
).subscribe(roles => {
|
||||
this.zitadelPermissions.next(roles);
|
||||
});
|
||||
}
|
||||
|
||||
public isAllowed(roles: string[] | RegExp[]): Observable<boolean> {
|
||||
if (roles && roles.length > 0) {
|
||||
return this.zitadelPermissions.pipe(switchMap(zroles => {
|
||||
return of(this.hasRoles(zroles, roles));
|
||||
}));
|
||||
} else {
|
||||
return of(false);
|
||||
}
|
||||
}
|
||||
|
||||
public hasRoles(userRoles: string[], requestedRoles: string[] | RegExp[]): boolean {
|
||||
return requestedRoles.findIndex((regexp: any) => {
|
||||
return userRoles.findIndex(role => {
|
||||
return (new RegExp(regexp)).test(role);
|
||||
}) > -1;
|
||||
}) > -1;
|
||||
}
|
||||
|
||||
public async GetMyUserProfile(): Promise<UserProfileView> {
|
||||
return this.grpcService.auth.getMyUserProfile(new Empty());
|
||||
}
|
||||
|
||||
public async GetMyPasswordComplexityPolicy(): Promise<PasswordComplexityPolicy> {
|
||||
return this.grpcService.auth.getMyPasswordComplexityPolicy(
|
||||
new Empty(),
|
||||
);
|
||||
}
|
||||
|
||||
public async GetMyUser(): Promise<UserView> {
|
||||
return this.grpcService.auth.getMyUser(
|
||||
new Empty(),
|
||||
);
|
||||
}
|
||||
|
||||
public async GetMyMfas(): Promise<MultiFactors> {
|
||||
return this.grpcService.auth.getMyMfas(
|
||||
new Empty(),
|
||||
);
|
||||
}
|
||||
|
||||
public async SearchMyProjectOrgs(
|
||||
limit: number,
|
||||
offset: number,
|
||||
queryList?: MyProjectOrgSearchQuery[],
|
||||
): Promise<MyProjectOrgSearchResponse> {
|
||||
const req: MyProjectOrgSearchRequest = new MyProjectOrgSearchRequest();
|
||||
req.setOffset(offset);
|
||||
req.setLimit(limit);
|
||||
if (queryList) {
|
||||
req.setQueriesList(queryList);
|
||||
}
|
||||
|
||||
return this.grpcService.auth.searchMyProjectOrgs(req);
|
||||
}
|
||||
|
||||
public async SaveMyUserProfile(
|
||||
firstName?: string,
|
||||
lastName?: string,
|
||||
nickName?: string,
|
||||
preferredLanguage?: string,
|
||||
gender?: Gender,
|
||||
): Promise<UserProfile> {
|
||||
const req = new UpdateUserProfileRequest();
|
||||
if (firstName) {
|
||||
req.setFirstName(firstName);
|
||||
}
|
||||
if (lastName) {
|
||||
req.setLastName(lastName);
|
||||
}
|
||||
if (nickName) {
|
||||
req.setNickName(nickName);
|
||||
}
|
||||
if (gender) {
|
||||
req.setGender(gender);
|
||||
}
|
||||
if (preferredLanguage) {
|
||||
req.setPreferredLanguage(preferredLanguage);
|
||||
}
|
||||
return this.grpcService.auth.updateMyUserProfile(req);
|
||||
}
|
||||
|
||||
public async getMyUserSessions(): Promise<UserSessionViews> {
|
||||
return this.grpcService.auth.getMyUserSessions(
|
||||
new Empty(),
|
||||
);
|
||||
}
|
||||
|
||||
public async GetMyUserEmail(): Promise<UserEmail> {
|
||||
return this.grpcService.auth.getMyUserEmail(
|
||||
new Empty(),
|
||||
);
|
||||
}
|
||||
|
||||
public async SaveMyUserEmail(email: string): Promise<UserEmail> {
|
||||
const req = new UpdateUserEmailRequest();
|
||||
req.setEmail(email);
|
||||
return this.grpcService.auth.changeMyUserEmail(req);
|
||||
}
|
||||
|
||||
public async RemoveMyUserPhone(): Promise<Empty> {
|
||||
return this.grpcService.auth.removeMyUserPhone(
|
||||
new Empty(),
|
||||
);
|
||||
}
|
||||
|
||||
public async GetMyzitadelPermissions(): Promise<MyPermissions> {
|
||||
return this.grpcService.auth.getMyZitadelPermissions(
|
||||
new Empty(),
|
||||
);
|
||||
}
|
||||
|
||||
public async GetMyUserPhone(): Promise<UserPhone> {
|
||||
return this.grpcService.auth.getMyUserPhone(
|
||||
new Empty(),
|
||||
);
|
||||
}
|
||||
|
||||
public async SaveMyUserPhone(phone: string): Promise<UserPhone> {
|
||||
const req = new UpdateUserPhoneRequest();
|
||||
req.setPhone(phone);
|
||||
return this.grpcService.auth.changeMyUserPhone(req);
|
||||
}
|
||||
|
||||
public async GetMyUserAddress(): Promise<UserAddress> {
|
||||
return this.grpcService.auth.getMyUserAddress(
|
||||
new Empty(),
|
||||
);
|
||||
}
|
||||
|
||||
public async ResendEmailVerification(): Promise<Empty> {
|
||||
const req = new Empty();
|
||||
return this.grpcService.auth.resendMyEmailVerificationMail(req);
|
||||
}
|
||||
|
||||
public async ResendPhoneVerification(): Promise<Empty> {
|
||||
const req = new Empty();
|
||||
return this.grpcService.auth.resendMyPhoneVerificationCode(req);
|
||||
}
|
||||
|
||||
public async ChangeMyPassword(oldPassword: string, newPassword: string): Promise<Empty> {
|
||||
const req = new PasswordChange();
|
||||
req.setOldPassword(oldPassword);
|
||||
req.setNewPassword(newPassword);
|
||||
return this.grpcService.auth.changeMyPassword(req);
|
||||
}
|
||||
|
||||
public async AddMfaOTP(): Promise<MfaOtpResponse> {
|
||||
return this.grpcService.auth.addMfaOTP(
|
||||
new Empty(),
|
||||
);
|
||||
}
|
||||
|
||||
public async RemoveMfaOTP(): Promise<Empty> {
|
||||
return this.grpcService.auth.removeMfaOTP(
|
||||
new Empty(),
|
||||
);
|
||||
}
|
||||
|
||||
public async VerifyMfaOTP(code: string): Promise<Empty> {
|
||||
const req = new VerifyMfaOtp();
|
||||
req.setCode(code);
|
||||
return this.grpcService.auth.verifyMfaOTP(req);
|
||||
}
|
||||
|
||||
public async VerifyMyUserPhone(code: string): Promise<Empty> {
|
||||
const req = new VerifyUserPhoneRequest();
|
||||
req.setCode(code);
|
||||
return this.grpcService.auth.verifyMyUserPhone(req);
|
||||
}
|
||||
|
||||
public async SaveMyUserAddress(address: UserAddress.AsObject): Promise<UserAddress> {
|
||||
const req = new UpdateUserAddressRequest();
|
||||
req.setStreetAddress(address.streetAddress);
|
||||
req.setPostalCode(address.postalCode);
|
||||
req.setLocality(address.locality);
|
||||
req.setRegion(address.region);
|
||||
req.setCountry(address.country);
|
||||
return this.grpcService.auth.updateMyUserAddress(req);
|
||||
}
|
||||
|
||||
public async GetMyUserChanges(limit: number, sequenceoffset: number): Promise<Changes> {
|
||||
const req = new ChangesRequest();
|
||||
req.setLimit(limit);
|
||||
req.setSequenceOffset(sequenceoffset);
|
||||
return this.grpcService.auth.getMyUserChanges(req);
|
||||
}
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
import { Inject, Injectable } from '@angular/core';
|
||||
import { Metadata } from 'grpc-web';
|
||||
|
||||
import { GrpcDefaultHandler, GrpcHandler, GrpcInterceptorHandler, GrpcRequestFn } from './grpc-handler';
|
||||
import { GRPC_INTERCEPTORS, GrpcInterceptor } from './interceptors/grpc-interceptor';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class GrpcBackendService {
|
||||
constructor(
|
||||
@Inject(GRPC_INTERCEPTORS) private readonly interceptors: GrpcInterceptor[],
|
||||
) { }
|
||||
|
||||
public async runRequest<TReq, TResp>(
|
||||
requestFn: GrpcRequestFn<TReq, TResp>,
|
||||
request: TReq,
|
||||
metadata: Metadata = {},
|
||||
): Promise<TResp> {
|
||||
const defaultHandler: GrpcHandler = new GrpcDefaultHandler(requestFn);
|
||||
const chain = this.interceptors.reduceRight(
|
||||
(next, interceptor) => new GrpcInterceptorHandler(next, interceptor),
|
||||
defaultHandler,
|
||||
);
|
||||
return chain.handle(request, metadata);
|
||||
}
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
import { Metadata } from 'grpc-web';
|
||||
|
||||
import { GrpcInterceptor } from './interceptors/grpc-interceptor';
|
||||
|
||||
export type GrpcRequestFn<TReq, TResp> = (
|
||||
request: TReq,
|
||||
metadata?: Metadata,
|
||||
) => Promise<TResp>;
|
||||
|
||||
export interface GrpcHandler {
|
||||
handle(req: unknown, metadata: Metadata): Promise<any>;
|
||||
}
|
||||
|
||||
export class GrpcInterceptorHandler implements GrpcHandler {
|
||||
constructor(
|
||||
private readonly next: GrpcHandler,
|
||||
private interceptor: GrpcInterceptor,
|
||||
) { }
|
||||
|
||||
public handle(req: unknown, metadata: Metadata): Promise<unknown> {
|
||||
return this.interceptor.intercept(req, metadata, this.next);
|
||||
}
|
||||
}
|
||||
|
||||
export class GrpcDefaultHandler<TReq, TResp> implements GrpcHandler {
|
||||
constructor(private readonly requestFn: GrpcRequestFn<TReq, TResp>) { }
|
||||
|
||||
public handle(req: TReq, metadata: Metadata): Promise<TResp> {
|
||||
return this.requestFn(req, metadata);
|
||||
}
|
||||
}
|
@ -1,21 +1,20 @@
|
||||
import { PlatformLocation } from '@angular/common';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { AuthConfig } from 'angular-oauth2-oidc';
|
||||
|
||||
import { AdminServicePromiseClient } from '../proto/generated/admin_grpc_web_pb';
|
||||
import { AuthServicePromiseClient } from '../proto/generated/auth_grpc_web_pb';
|
||||
import { ManagementServicePromiseClient } from '../proto/generated/management_grpc_web_pb';
|
||||
import { GrpcRequestFn } from './grpc-handler';
|
||||
import { AuthenticationService } from './authentication.service';
|
||||
import { AuthInterceptor } from './interceptors/auth.interceptor';
|
||||
import { OrgInterceptor } from './interceptors/org.interceptor';
|
||||
import { StorageService } from './storage.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class GrpcService {
|
||||
public issuer: string = '';
|
||||
public clientid: string = '';
|
||||
public redirectUri: string = '';
|
||||
public postLogoutRedirectUri: string = '';
|
||||
|
||||
public auth!: AuthServicePromiseClient;
|
||||
public mgmt!: ManagementServicePromiseClient;
|
||||
public admin!: AdminServicePromiseClient;
|
||||
@ -23,22 +22,51 @@ export class GrpcService {
|
||||
constructor(
|
||||
private http: HttpClient,
|
||||
private platformLocation: PlatformLocation,
|
||||
private authenticationService: AuthenticationService,
|
||||
private storageService: StorageService,
|
||||
) { }
|
||||
|
||||
public async loadAppEnvironment(): Promise<any> {
|
||||
return this.http.get('./assets/environment.json')
|
||||
.toPromise().then((data: any) => {
|
||||
if (data && data.authServiceUrl && data.mgmtServiceUrl && data.issuer) {
|
||||
this.auth = new AuthServicePromiseClient(data.authServiceUrl);
|
||||
this.mgmt = new ManagementServicePromiseClient(data.mgmtServiceUrl);
|
||||
this.admin = new AdminServicePromiseClient(data.adminServiceUrl);
|
||||
const interceptors = {
|
||||
'unaryInterceptors': [
|
||||
new AuthInterceptor(this.authenticationService, this.storageService),
|
||||
new OrgInterceptor(this.storageService),
|
||||
],
|
||||
};
|
||||
|
||||
this.issuer = data.issuer;
|
||||
if (data.clientid) {
|
||||
this.clientid = data.clientid;
|
||||
this.redirectUri = window.location.origin + this.platformLocation.getBaseHrefFromDOM() + 'auth/callback';
|
||||
this.postLogoutRedirectUri = window.location.origin + this.platformLocation.getBaseHrefFromDOM() + 'signedout';
|
||||
}
|
||||
this.auth = new AuthServicePromiseClient(
|
||||
data.authServiceUrl,
|
||||
null,
|
||||
// @ts-ignore
|
||||
interceptors,
|
||||
);
|
||||
this.mgmt = new ManagementServicePromiseClient(
|
||||
data.mgmtServiceUrl,
|
||||
null,
|
||||
// @ts-ignore
|
||||
interceptors,
|
||||
);
|
||||
this.admin = new AdminServicePromiseClient(
|
||||
data.adminServiceUrl,
|
||||
null,
|
||||
// @ts-ignore
|
||||
interceptors,
|
||||
);
|
||||
|
||||
const authConfig: AuthConfig = {
|
||||
scope: 'openid profile email',
|
||||
responseType: 'code',
|
||||
oidc: true,
|
||||
clientId: data.clientid,
|
||||
issuer: data.issuer,
|
||||
redirectUri: window.location.origin + this.platformLocation.getBaseHrefFromDOM() + 'auth/callback',
|
||||
postLogoutRedirectUri: window.location.origin + this.platformLocation.getBaseHrefFromDOM() + 'signedout',
|
||||
};
|
||||
|
||||
this.authenticationService.initConfig(authConfig);
|
||||
}
|
||||
return Promise.resolve(data);
|
||||
}).catch(() => {
|
||||
@ -46,9 +74,3 @@ export class GrpcService {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export type RequestFactory<TClient, TReq, TResp> = (
|
||||
client: TClient,
|
||||
) => GrpcRequestFn<TReq, TResp>;
|
||||
|
||||
export type ResponseMapper<TResp, TMappedResp> = (resp: TResp) => TMappedResp;
|
||||
|
40
console/src/app/services/interceptors/auth.interceptor.ts
Normal file
40
console/src/app/services/interceptors/auth.interceptor.ts
Normal file
@ -0,0 +1,40 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Request, UnaryInterceptor, UnaryResponse } from 'grpc-web';
|
||||
import { filter, first } from 'rxjs/operators';
|
||||
|
||||
import { AuthenticationService } from '../authentication.service';
|
||||
import { StorageService } from '../storage.service';
|
||||
|
||||
|
||||
const authorizationKey = 'Authorization';
|
||||
const bearerPrefix = 'Bearer';
|
||||
const accessTokenStorageKey = 'access_token';
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class AuthInterceptor<TReq = unknown, TResp = unknown> implements UnaryInterceptor<TReq, TResp> {
|
||||
constructor(private authenticationService: AuthenticationService, private storageService: StorageService) { }
|
||||
|
||||
public async intercept(request: Request<TReq, TResp>, invoker: any): Promise<UnaryResponse<TReq, TResp>> {
|
||||
await this.authenticationService.authenticationChanged.pipe(
|
||||
filter((authed) => !!authed),
|
||||
first(),
|
||||
).toPromise();
|
||||
|
||||
const metadata = request.getMetadata();
|
||||
const accessToken = this.storageService.getItem(accessTokenStorageKey);
|
||||
metadata[authorizationKey] = `${bearerPrefix} ${accessToken}`;
|
||||
|
||||
return invoker(request).then((response: any) => {
|
||||
// const message = response.getResponseMessage();
|
||||
const respMetadata = response.getMetadata();
|
||||
|
||||
// TODO: intercept unauthenticated an authenticate
|
||||
|
||||
// const status = respMetadata['grpc-status'];
|
||||
// console.log(respMetadata, status);
|
||||
// if (status?.code === 16) {
|
||||
// this.authenticationService.authenticate();
|
||||
// }
|
||||
return response;
|
||||
});
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Metadata } from 'grpc-web';
|
||||
|
||||
import { GrpcHandler } from '../grpc-handler';
|
||||
import { StorageService } from '../storage.service';
|
||||
import { GrpcInterceptor } from './grpc-interceptor';
|
||||
|
||||
const authorizationKey = 'Authorization';
|
||||
const bearerPrefix = 'Bearer ';
|
||||
const accessTokenStorageField = 'access_token';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class GrpcAuthInterceptor implements GrpcInterceptor {
|
||||
constructor(private readonly authStorage: StorageService) { }
|
||||
|
||||
public async intercept(
|
||||
req: unknown,
|
||||
metadata: Metadata,
|
||||
next: GrpcHandler,
|
||||
): Promise<any> {
|
||||
if (!metadata[authorizationKey]) {
|
||||
const accessToken = this.authStorage.getItem(accessTokenStorageField);
|
||||
if (accessToken) {
|
||||
metadata[authorizationKey] = bearerPrefix + accessToken;
|
||||
}
|
||||
}
|
||||
|
||||
return await next.handle(req, metadata);
|
||||
}
|
||||
}
|
@ -1,12 +1,6 @@
|
||||
import { InjectionToken } from '@angular/core';
|
||||
import { Metadata } from 'grpc-web';
|
||||
import { UnaryInterceptor } from 'grpc-web';
|
||||
|
||||
import { GrpcHandler } from '../grpc-handler';
|
||||
|
||||
export const GRPC_INTERCEPTORS = new InjectionToken<GrpcInterceptor[]>(
|
||||
export const GRPC_INTERCEPTORS = new InjectionToken<Array<UnaryInterceptor<any, any>>>(
|
||||
'GRPC_INTERCEPTORS',
|
||||
);
|
||||
|
||||
export interface GrpcInterceptor {
|
||||
intercept(req: unknown, metadata: Metadata, next: GrpcHandler): Promise<any>;
|
||||
}
|
||||
|
@ -1,26 +0,0 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Metadata } from 'grpc-web';
|
||||
|
||||
import { Org } from '../../proto/generated/auth_pb';
|
||||
import { GrpcHandler } from '../grpc-handler';
|
||||
import { StorageService } from '../storage.service';
|
||||
import { GrpcInterceptor } from './grpc-interceptor';
|
||||
|
||||
const orgKey = 'x-zitadel-orgid';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class GrpcOrgInterceptor implements GrpcInterceptor {
|
||||
constructor(private readonly storageService: StorageService) { }
|
||||
|
||||
public async intercept(
|
||||
req: unknown,
|
||||
metadata: Metadata,
|
||||
next: GrpcHandler,
|
||||
): Promise<any> {
|
||||
const org: Org.AsObject | null = (this.storageService.getItem('organization'));
|
||||
if (!metadata[orgKey] && org) {
|
||||
metadata[orgKey] = org.id ?? '';
|
||||
}
|
||||
return await next.handle(req, metadata);
|
||||
}
|
||||
}
|
26
console/src/app/services/interceptors/org.interceptor.ts
Normal file
26
console/src/app/services/interceptors/org.interceptor.ts
Normal file
@ -0,0 +1,26 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Request, UnaryInterceptor, UnaryResponse } from 'grpc-web';
|
||||
import { Org } from 'src/app/proto/generated/auth_pb';
|
||||
|
||||
import { StorageService } from '../storage.service';
|
||||
|
||||
|
||||
const orgKey = 'x-zitadel-orgid';
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class OrgInterceptor<TReq = unknown, TResp = unknown> implements UnaryInterceptor<TReq, TResp> {
|
||||
constructor(private readonly storageService: StorageService) { }
|
||||
|
||||
public intercept(request: Request<TReq, TResp>, invoker: any): Promise<UnaryResponse<TReq, TResp>> {
|
||||
const metadata = request.getMetadata();
|
||||
|
||||
const org: Org.AsObject | null = (this.storageService.getItem('organization'));
|
||||
|
||||
if (org) {
|
||||
metadata[orgKey] = `${org.id}`;
|
||||
}
|
||||
|
||||
return invoker(request).then((response: any) => {
|
||||
return response;
|
||||
});
|
||||
}
|
||||
}
|
@ -1,534 +0,0 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Empty } from 'google-protobuf/google/protobuf/empty_pb';
|
||||
import { Metadata } from 'grpc-web';
|
||||
|
||||
import { ManagementServicePromiseClient } from '../proto/generated/management_grpc_web_pb';
|
||||
import {
|
||||
ChangeRequest,
|
||||
Changes,
|
||||
CreateUserRequest,
|
||||
LoginName,
|
||||
Gender,
|
||||
MultiFactors,
|
||||
NotificationType,
|
||||
PasswordRequest,
|
||||
ProjectGrantMemberSearchQuery,
|
||||
ProjectGrantMemberSearchRequest,
|
||||
ProjectGrantMemberSearchResponse,
|
||||
ProjectMemberSearchQuery,
|
||||
ProjectMemberSearchRequest,
|
||||
ProjectMemberSearchResponse,
|
||||
ProjectRoleAdd,
|
||||
SetPasswordNotificationRequest,
|
||||
UpdateUserAddressRequest,
|
||||
UpdateUserEmailRequest,
|
||||
UpdateUserPhoneRequest,
|
||||
UpdateUserProfileRequest,
|
||||
User,
|
||||
UserAddress,
|
||||
UserEmail,
|
||||
UserGrant,
|
||||
UserGrantCreate,
|
||||
UserGrantID,
|
||||
UserGrantRemoveBulk,
|
||||
UserGrantSearchQuery,
|
||||
UserGrantSearchRequest,
|
||||
UserGrantSearchResponse,
|
||||
UserGrantUpdate,
|
||||
UserGrantView,
|
||||
UserID,
|
||||
UserMembershipSearchQuery,
|
||||
UserMembershipSearchRequest,
|
||||
UserMembershipSearchResponse,
|
||||
UserPhone,
|
||||
UserProfile,
|
||||
UserSearchQuery,
|
||||
UserSearchRequest,
|
||||
UserSearchResponse,
|
||||
UserView,
|
||||
} from '../proto/generated/management_pb';
|
||||
import { GrpcBackendService } from './grpc-backend.service';
|
||||
import { GrpcService, RequestFactory, ResponseMapper } from './grpc.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class MgmtUserService {
|
||||
constructor(private grpcService: GrpcService, private grpcBackendService: GrpcBackendService) { }
|
||||
|
||||
public async request<TReq, TResp, TMappedResp>(
|
||||
requestFn: RequestFactory<ManagementServicePromiseClient, TReq, TResp>,
|
||||
request: TReq,
|
||||
responseMapper: ResponseMapper<TResp, TMappedResp>,
|
||||
metadata?: Metadata,
|
||||
): Promise<TMappedResp> {
|
||||
const mappedRequestFn = requestFn(this.grpcService.mgmt).bind(this.grpcService.mgmt);
|
||||
const response = await this.grpcBackendService.runRequest(
|
||||
mappedRequestFn,
|
||||
request,
|
||||
metadata,
|
||||
);
|
||||
return responseMapper(response);
|
||||
}
|
||||
|
||||
public async CreateUser(user: CreateUserRequest.AsObject): Promise<User> {
|
||||
const req = new CreateUserRequest();
|
||||
req.setEmail(user.email);
|
||||
req.setUserName(user.userName);
|
||||
req.setFirstName(user.firstName);
|
||||
req.setLastName(user.lastName);
|
||||
req.setNickName(user.nickName);
|
||||
req.setPassword(user.password);
|
||||
req.setPreferredLanguage(user.preferredLanguage);
|
||||
req.setGender(user.gender);
|
||||
req.setPhone(user.phone);
|
||||
req.setStreetAddress(user.streetAddress);
|
||||
req.setPostalCode(user.postalCode);
|
||||
req.setLocality(user.locality);
|
||||
req.setRegion(user.region);
|
||||
req.setCountry(user.country);
|
||||
return await this.request(
|
||||
c => c.createUser,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async GetUserByID(id: string): Promise<UserView> {
|
||||
const req = new UserID();
|
||||
req.setId(id);
|
||||
return await this.request(
|
||||
c => c.getUserByID,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async SearchProjectMembers(
|
||||
limit: number, offset: number, queryList?: ProjectMemberSearchQuery[]): Promise<ProjectMemberSearchResponse> {
|
||||
const req = new ProjectMemberSearchRequest();
|
||||
req.setLimit(limit);
|
||||
req.setOffset(offset);
|
||||
if (queryList) {
|
||||
req.setQueriesList(queryList);
|
||||
}
|
||||
return await this.request(
|
||||
c => c.searchProjectMembers,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async SearchUserMemberships(userId: string,
|
||||
limit: number, offset: number, queryList?: UserMembershipSearchQuery[]): Promise<UserMembershipSearchResponse> {
|
||||
const req = new UserMembershipSearchRequest();
|
||||
req.setLimit(limit);
|
||||
req.setOffset(offset);
|
||||
req.setUserId(userId);
|
||||
if (queryList) {
|
||||
req.setQueriesList(queryList);
|
||||
}
|
||||
return await this.request(
|
||||
c => c.searchUserMemberships,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async GetUserProfile(id: string): Promise<UserProfile> {
|
||||
const req = new UserID();
|
||||
req.setId(id);
|
||||
return await this.request(
|
||||
c => c.getUserProfile,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async getUserMfas(id: string): Promise<MultiFactors> {
|
||||
const req = new UserID();
|
||||
req.setId(id);
|
||||
return await this.request(
|
||||
c => c.getUserMfas,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async SaveUserProfile(
|
||||
id: string,
|
||||
firstName?: string,
|
||||
lastName?: string,
|
||||
nickName?: string,
|
||||
preferredLanguage?: string,
|
||||
gender?: Gender,
|
||||
): Promise<UserProfile> {
|
||||
const req = new UpdateUserProfileRequest();
|
||||
req.setId(id);
|
||||
if (firstName) {
|
||||
req.setFirstName(firstName);
|
||||
}
|
||||
if (lastName) {
|
||||
req.setLastName(lastName);
|
||||
}
|
||||
if (nickName) {
|
||||
req.setNickName(nickName);
|
||||
}
|
||||
if (gender) {
|
||||
req.setGender(gender);
|
||||
}
|
||||
if (preferredLanguage) {
|
||||
req.setPreferredLanguage(preferredLanguage);
|
||||
}
|
||||
return await this.request(
|
||||
c => c.updateUserProfile,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async GetUserEmail(id: string): Promise<UserEmail> {
|
||||
const req = new UserID();
|
||||
req.setId(id);
|
||||
return await this.request(
|
||||
c => c.getUserEmail,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async SaveUserEmail(id: string, email: string): Promise<UserEmail> {
|
||||
const req = new UpdateUserEmailRequest();
|
||||
req.setId(id);
|
||||
req.setEmail(email);
|
||||
return await this.request(
|
||||
c => c.changeUserEmail,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async GetUserPhone(id: string): Promise<UserPhone> {
|
||||
const req = new UserID();
|
||||
req.setId(id);
|
||||
return await this.request(
|
||||
c => c.getUserPhone,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async SaveUserPhone(id: string, phone: string): Promise<UserPhone> {
|
||||
const req = new UpdateUserPhoneRequest();
|
||||
req.setId(id);
|
||||
req.setPhone(phone);
|
||||
return await this.request(
|
||||
c => c.changeUserPhone,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async RemoveUserPhone(id: string): Promise<Empty> {
|
||||
const req = new UserID();
|
||||
req.setId(id);
|
||||
return await this.request(
|
||||
c => c.removeUserPhone,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async DeactivateUser(id: string): Promise<UserPhone> {
|
||||
const req = new UserID();
|
||||
req.setId(id);
|
||||
return await this.request(
|
||||
c => c.deactivateUser,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async CreateUserGrant(
|
||||
userId: string,
|
||||
roleNamesList: string[],
|
||||
projectId?: string,
|
||||
grantId?: string,
|
||||
): Promise<UserGrant> {
|
||||
const req = new UserGrantCreate();
|
||||
if (projectId) { req.setProjectId(projectId); }
|
||||
if (grantId) { req.setGrantId(grantId); }
|
||||
req.setUserId(userId);
|
||||
req.setRoleKeysList(roleNamesList);
|
||||
|
||||
return await this.request(
|
||||
c => c.createUserGrant,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
public async ReactivateUser(id: string): Promise<UserPhone> {
|
||||
const req = new UserID();
|
||||
req.setId(id);
|
||||
return await this.request(
|
||||
c => c.reactivateUser,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async AddRole(id: string, key: string, displayName: string, group: string): Promise<Empty> {
|
||||
const req = new ProjectRoleAdd();
|
||||
req.setId(id);
|
||||
req.setKey(key);
|
||||
if (displayName) {
|
||||
req.setDisplayName(displayName);
|
||||
}
|
||||
req.setGroup(group);
|
||||
return await this.request(
|
||||
c => c.addProjectRole,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async GetUserAddress(id: string): Promise<UserAddress> {
|
||||
const req = new UserID();
|
||||
req.setId(id);
|
||||
return await this.request(
|
||||
c => c.getUserAddress,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async ResendEmailVerification(id: string): Promise<any> {
|
||||
const req = new UserID();
|
||||
req.setId(id);
|
||||
return await this.request(
|
||||
c => c.resendEmailVerificationMail,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async ResendPhoneVerification(id: string): Promise<any> {
|
||||
const req = new UserID();
|
||||
req.setId(id);
|
||||
return await this.request(
|
||||
c => c.resendPhoneVerificationCode,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async SetInitialPassword(id: string, password: string): Promise<any> {
|
||||
const req = new PasswordRequest();
|
||||
req.setId(id);
|
||||
req.setPassword(password);
|
||||
return await this.request(
|
||||
c => c.setInitialPassword,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async SendSetPasswordNotification(id: string, type: NotificationType): Promise<any> {
|
||||
const req = new SetPasswordNotificationRequest();
|
||||
req.setId(id);
|
||||
req.setType(type);
|
||||
return await this.request(
|
||||
c => c.sendSetPasswordNotification,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async SaveUserAddress(address: UserAddress.AsObject): Promise<UserAddress> {
|
||||
const req = new UpdateUserAddressRequest();
|
||||
req.setId(address.id);
|
||||
req.setStreetAddress(address.streetAddress);
|
||||
req.setPostalCode(address.postalCode);
|
||||
req.setLocality(address.locality);
|
||||
req.setRegion(address.region);
|
||||
req.setCountry(address.country);
|
||||
return await this.request(
|
||||
c => c.updateUserAddress,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async SearchProjectGrantMembers(
|
||||
limit: number,
|
||||
offset: number,
|
||||
query?: ProjectGrantMemberSearchQuery[],
|
||||
): Promise<ProjectGrantMemberSearchResponse> {
|
||||
const req = new ProjectGrantMemberSearchRequest();
|
||||
req.setLimit(limit);
|
||||
req.setOffset(offset);
|
||||
if (query) {
|
||||
req.setQueriesList(query);
|
||||
}
|
||||
return await this.request(
|
||||
c => c.searchProjectGrantMembers,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async SearchUsers(limit: number, offset: number, queryList?: UserSearchQuery[]): Promise<UserSearchResponse> {
|
||||
const req = new UserSearchRequest();
|
||||
req.setLimit(limit);
|
||||
req.setOffset(offset);
|
||||
if (queryList) {
|
||||
req.setQueriesList(queryList);
|
||||
}
|
||||
return await this.request(
|
||||
c => c.searchUsers,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async GetUserByLoginNameGlobal(loginName: string): Promise<UserView> {
|
||||
const req = new LoginName();
|
||||
req.setLoginName(loginName);
|
||||
return await this.request(
|
||||
c => c.getUserByLoginNameGlobal,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
// USER GRANTS
|
||||
|
||||
public async SearchUserGrants(
|
||||
limit: number,
|
||||
offset: number,
|
||||
queryList?: UserGrantSearchQuery[],
|
||||
): Promise<UserGrantSearchResponse> {
|
||||
const req = new UserGrantSearchRequest();
|
||||
req.setLimit(limit);
|
||||
req.setOffset(offset);
|
||||
if (queryList) {
|
||||
req.setQueriesList(queryList);
|
||||
}
|
||||
return await this.request(
|
||||
c => c.searchUserGrants,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public async UserGrantByID(
|
||||
id: string,
|
||||
userId: string,
|
||||
): Promise<UserGrantView> {
|
||||
const req = new UserGrantID();
|
||||
req.setId(id);
|
||||
req.setUserId(userId);
|
||||
|
||||
return await this.request(
|
||||
c => c.userGrantByID,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async UpdateUserGrant(
|
||||
id: string,
|
||||
userId: string,
|
||||
roleKeysList: string[],
|
||||
): Promise<UserGrant> {
|
||||
const req = new UserGrantUpdate();
|
||||
req.setId(id);
|
||||
req.setRoleKeysList(roleKeysList);
|
||||
req.setUserId(userId);
|
||||
|
||||
return await this.request(
|
||||
c => c.updateUserGrant,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async RemoveUserGrant(
|
||||
id: string,
|
||||
userId: string,
|
||||
): Promise<Empty> {
|
||||
const req = new UserGrantID();
|
||||
req.setId(id);
|
||||
req.setUserId(userId);
|
||||
|
||||
return await this.request(
|
||||
c => c.removeUserGrant,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async BulkRemoveUserGrant(
|
||||
idsList: string[],
|
||||
): Promise<Empty> {
|
||||
const req = new UserGrantRemoveBulk();
|
||||
req.setIdsList(idsList);
|
||||
|
||||
return await this.request(
|
||||
c => c.bulkRemoveUserGrant,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
public async ApplicationChanges(id: string, limit: number, offset: number): Promise<Changes> {
|
||||
const req = new ChangeRequest();
|
||||
req.setId(id);
|
||||
req.setLimit(limit);
|
||||
req.setSequenceOffset(offset);
|
||||
return await this.request(
|
||||
c => c.applicationChanges,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async OrgChanges(id: string, limit: number, offset: number): Promise<Changes> {
|
||||
const req = new ChangeRequest();
|
||||
req.setId(id);
|
||||
req.setLimit(limit);
|
||||
req.setSequenceOffset(offset);
|
||||
return await this.request(
|
||||
c => c.orgChanges,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async ProjectChanges(id: string, limit: number, offset: number): Promise<Changes> {
|
||||
const req = new ChangeRequest();
|
||||
req.setId(id);
|
||||
req.setLimit(limit);
|
||||
req.setSequenceOffset(offset);
|
||||
return await this.request(
|
||||
c => c.projectChanges,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async UserChanges(id: string, limit: number, sequenceoffset: number): Promise<Changes> {
|
||||
const req = new ChangeRequest();
|
||||
req.setId(id);
|
||||
req.setLimit(limit);
|
||||
req.setSequenceOffset(sequenceoffset);
|
||||
return await this.request(
|
||||
c => c.userChanges,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
}
|
1066
console/src/app/services/mgmt.service.ts
Normal file
1066
console/src/app/services/mgmt.service.ts
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,454 +0,0 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Empty } from 'google-protobuf/google/protobuf/empty_pb';
|
||||
import { Metadata } from 'grpc-web';
|
||||
|
||||
import { ManagementServicePromiseClient } from '../proto/generated/management_grpc_web_pb';
|
||||
import {
|
||||
AddOrgDomainRequest,
|
||||
AddOrgMemberRequest,
|
||||
ChangeOrgMemberRequest,
|
||||
Domain,
|
||||
Iam,
|
||||
Org,
|
||||
OrgCreateRequest,
|
||||
OrgDomain,
|
||||
OrgDomainSearchQuery,
|
||||
OrgDomainSearchRequest,
|
||||
OrgDomainSearchResponse,
|
||||
OrgDomainValidationRequest,
|
||||
OrgDomainValidationResponse,
|
||||
OrgDomainValidationType,
|
||||
OrgIamPolicy,
|
||||
OrgID,
|
||||
OrgMember,
|
||||
OrgMemberRoles,
|
||||
OrgMemberSearchRequest,
|
||||
OrgMemberSearchResponse,
|
||||
PasswordAgePolicy,
|
||||
PasswordAgePolicyCreate,
|
||||
PasswordAgePolicyID,
|
||||
PasswordAgePolicyUpdate,
|
||||
PasswordComplexityPolicy,
|
||||
PasswordComplexityPolicyCreate,
|
||||
PasswordComplexityPolicyID,
|
||||
PasswordComplexityPolicyUpdate,
|
||||
PasswordLockoutPolicy,
|
||||
PasswordLockoutPolicyCreate,
|
||||
PasswordLockoutPolicyID,
|
||||
PasswordLockoutPolicyUpdate,
|
||||
ProjectGrant,
|
||||
ProjectGrantCreate,
|
||||
RemoveOrgDomainRequest,
|
||||
RemoveOrgMemberRequest,
|
||||
ValidateOrgDomainRequest,
|
||||
} from '../proto/generated/management_pb';
|
||||
import { GrpcBackendService } from './grpc-backend.service';
|
||||
import { GrpcService, RequestFactory, ResponseMapper } from './grpc.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class OrgService {
|
||||
constructor(private readonly grpcService: GrpcService, private grpcBackendService: GrpcBackendService) { }
|
||||
|
||||
public async request<TReq, TResp, TMappedResp>(
|
||||
requestFn: RequestFactory<ManagementServicePromiseClient, TReq, TResp>,
|
||||
request: TReq,
|
||||
responseMapper: ResponseMapper<TResp, TMappedResp>,
|
||||
metadata?: Metadata,
|
||||
): Promise<TMappedResp> {
|
||||
const mappedRequestFn = requestFn(this.grpcService.mgmt).bind(this.grpcService.mgmt);
|
||||
const response = await this.grpcBackendService.runRequest(
|
||||
mappedRequestFn,
|
||||
request,
|
||||
metadata,
|
||||
);
|
||||
return responseMapper(response);
|
||||
}
|
||||
|
||||
public async GetIam(): Promise<Iam> {
|
||||
const req: Empty = new Empty();
|
||||
return await this.request(
|
||||
c => c.getIam,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async GetDefaultPasswordComplexityPolicy(): Promise<PasswordComplexityPolicy> {
|
||||
const req: Empty = new Empty();
|
||||
return await this.request(
|
||||
c => c.getDefaultPasswordComplexityPolicy,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async GetMyOrg(): Promise<Org> {
|
||||
return await this.request(
|
||||
c => c.getMyOrg,
|
||||
new Empty(),
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async AddMyOrgDomain(domain: string): Promise<OrgDomain> {
|
||||
const req: AddOrgDomainRequest = new AddOrgDomainRequest();
|
||||
req.setDomain(domain);
|
||||
return await this.request(
|
||||
c => c.addMyOrgDomain,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async RemoveMyOrgDomain(domain: string): Promise<Empty> {
|
||||
const req: RemoveOrgDomainRequest = new RemoveOrgDomainRequest();
|
||||
req.setDomain(domain);
|
||||
return await this.request(
|
||||
c => c.removeMyOrgDomain,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async SearchMyOrgDomains(offset: number, limit: number, queryList?: OrgDomainSearchQuery[]):
|
||||
Promise<OrgDomainSearchResponse> {
|
||||
const req: OrgDomainSearchRequest = new OrgDomainSearchRequest();
|
||||
req.setLimit(limit);
|
||||
req.setOffset(offset);
|
||||
if (queryList) {
|
||||
req.setQueriesList(queryList);
|
||||
}
|
||||
|
||||
return await this.request(
|
||||
c => c.searchMyOrgDomains,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async GenerateMyOrgDomainValidation(domain: string, type: OrgDomainValidationType):
|
||||
Promise<OrgDomainValidationResponse> {
|
||||
const req: OrgDomainValidationRequest = new OrgDomainValidationRequest();
|
||||
req.setDomain(domain);
|
||||
req.setType(type);
|
||||
|
||||
return await this.request(
|
||||
c => c.generateMyOrgDomainValidation,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async ValidateMyOrgDomain(domain: string):
|
||||
Promise<Empty> {
|
||||
const req: ValidateOrgDomainRequest = new ValidateOrgDomainRequest();
|
||||
req.setDomain(domain);
|
||||
|
||||
return await this.request(
|
||||
c => c.validateMyOrgDomain,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async SearchMyOrgMembers(limit: number, offset: number): Promise<OrgMemberSearchResponse> {
|
||||
const req = new OrgMemberSearchRequest();
|
||||
req.setLimit(limit);
|
||||
req.setOffset(offset);
|
||||
return await this.request(
|
||||
c => c.searchMyOrgMembers,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async getOrgByDomainGlobal(domain: string): Promise<Org> {
|
||||
const req = new Domain();
|
||||
req.setDomain(domain);
|
||||
return await this.request(
|
||||
c => c.getOrgByDomainGlobal,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async CreateOrg(name: string): Promise<Org> {
|
||||
const req = new OrgCreateRequest();
|
||||
req.setName(name);
|
||||
return await this.request(
|
||||
c => c.createOrg,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async AddMyOrgMember(userId: string, rolesList: string[]): Promise<Empty> {
|
||||
const req = new AddOrgMemberRequest();
|
||||
req.setUserId(userId);
|
||||
if (rolesList) {
|
||||
req.setRolesList(rolesList);
|
||||
}
|
||||
return await this.request(
|
||||
c => c.addMyOrgMember,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async ChangeMyOrgMember(userId: string, rolesList: string[]): Promise<OrgMember> {
|
||||
const req = new ChangeOrgMemberRequest();
|
||||
req.setUserId(userId);
|
||||
req.setRolesList(rolesList);
|
||||
return await this.request(
|
||||
c => c.changeMyOrgMember,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public async RemoveMyOrgMember(userId: string): Promise<Empty> {
|
||||
const req = new RemoveOrgMemberRequest();
|
||||
req.setUserId(userId);
|
||||
return await this.request(
|
||||
c => c.removeMyOrgMember,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async DeactivateMyOrg(): Promise<Org> {
|
||||
return await this.request(
|
||||
c => c.deactivateMyOrg,
|
||||
new Empty(),
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async ReactivateMyOrg(): Promise<Org> {
|
||||
const req = new OrgID();
|
||||
return await this.request(
|
||||
c => c.reactivateMyOrg,
|
||||
new Empty(),
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async CreateProjectGrant(
|
||||
projectId: string,
|
||||
orgId: string,
|
||||
roleKeysList: string[],
|
||||
): Promise<ProjectGrant> {
|
||||
const req = new ProjectGrantCreate();
|
||||
req.setProjectId(projectId);
|
||||
req.setGrantedOrgId(orgId);
|
||||
req.setRoleKeysList(roleKeysList);
|
||||
return await this.request(
|
||||
c => c.createProjectGrant,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async GetOrgMemberRoles(): Promise<OrgMemberRoles> {
|
||||
const req = new Empty();
|
||||
return await this.request(
|
||||
c => c.getOrgMemberRoles,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
// Policy
|
||||
|
||||
public async GetMyOrgIamPolicy(): Promise<OrgIamPolicy> {
|
||||
return await this.request(
|
||||
c => c.getMyOrgIamPolicy,
|
||||
new Empty(),
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async GetPasswordAgePolicy(): Promise<PasswordAgePolicy> {
|
||||
const req = new Empty();
|
||||
|
||||
return await this.request(
|
||||
c => c.getPasswordAgePolicy,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async CreatePasswordAgePolicy(
|
||||
description: string,
|
||||
maxAgeDays: number,
|
||||
expireWarnDays: number,
|
||||
): Promise<PasswordAgePolicy> {
|
||||
const req = new PasswordAgePolicyCreate();
|
||||
req.setDescription(description);
|
||||
req.setMaxAgeDays(maxAgeDays);
|
||||
req.setExpireWarnDays(expireWarnDays);
|
||||
|
||||
return await this.request(
|
||||
c => c.createPasswordAgePolicy,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async DeletePasswordAgePolicy(id: string): Promise<Empty> {
|
||||
const req = new PasswordAgePolicyID();
|
||||
req.setId(id);
|
||||
return await this.request(
|
||||
c => c.deletePasswordAgePolicy,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async UpdatePasswordAgePolicy(
|
||||
description: string,
|
||||
maxAgeDays: number,
|
||||
expireWarnDays: number,
|
||||
): Promise<PasswordAgePolicy> {
|
||||
const req = new PasswordAgePolicyUpdate();
|
||||
req.setDescription(description);
|
||||
req.setMaxAgeDays(maxAgeDays);
|
||||
req.setExpireWarnDays(expireWarnDays);
|
||||
return await this.request(
|
||||
c => c.updatePasswordAgePolicy,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async GetPasswordComplexityPolicy(): Promise<PasswordComplexityPolicy> {
|
||||
return await this.request(
|
||||
c => c.getPasswordComplexityPolicy,
|
||||
new Empty(),
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async CreatePasswordComplexityPolicy(
|
||||
description: string,
|
||||
hasLowerCase: boolean,
|
||||
hasUpperCase: boolean,
|
||||
hasNumber: boolean,
|
||||
hasSymbol: boolean,
|
||||
minLength: number,
|
||||
): Promise<PasswordComplexityPolicy> {
|
||||
const req = new PasswordComplexityPolicyCreate();
|
||||
req.setDescription(description);
|
||||
req.setHasLowercase(hasLowerCase);
|
||||
req.setHasUppercase(hasUpperCase);
|
||||
req.setHasNumber(hasNumber);
|
||||
req.setHasSymbol(hasSymbol);
|
||||
req.setMinLength(minLength);
|
||||
return await this.request(
|
||||
c => c.createPasswordComplexityPolicy,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async DeletePasswordComplexityPolicy(id: string): Promise<Empty> {
|
||||
const req = new PasswordComplexityPolicyID();
|
||||
req.setId(id);
|
||||
return await this.request(
|
||||
c => c.deletePasswordComplexityPolicy,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async UpdatePasswordComplexityPolicy(
|
||||
description: string,
|
||||
hasLowerCase: boolean,
|
||||
hasUpperCase: boolean,
|
||||
hasNumber: boolean,
|
||||
hasSymbol: boolean,
|
||||
minLength: number,
|
||||
): Promise<PasswordComplexityPolicy> {
|
||||
const req = new PasswordComplexityPolicyUpdate();
|
||||
req.setDescription(description);
|
||||
req.setHasLowercase(hasLowerCase);
|
||||
req.setHasUppercase(hasUpperCase);
|
||||
req.setHasNumber(hasNumber);
|
||||
req.setHasSymbol(hasSymbol);
|
||||
req.setMinLength(minLength);
|
||||
return await this.request(
|
||||
c => c.updatePasswordComplexityPolicy,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async GetPasswordLockoutPolicy(): Promise<PasswordLockoutPolicy> {
|
||||
const req = new Empty();
|
||||
|
||||
return await this.request(
|
||||
c => c.getPasswordLockoutPolicy,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async CreatePasswordLockoutPolicy(
|
||||
description: string,
|
||||
maxAttempts: number,
|
||||
showLockoutFailures: boolean,
|
||||
): Promise<PasswordLockoutPolicy> {
|
||||
const req = new PasswordLockoutPolicyCreate();
|
||||
req.setDescription(description);
|
||||
req.setMaxAttempts(maxAttempts);
|
||||
req.setShowLockOutFailures(showLockoutFailures);
|
||||
|
||||
return await this.request(
|
||||
c => c.createPasswordLockoutPolicy,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async DeletePasswordLockoutPolicy(id: string): Promise<Empty> {
|
||||
const req = new PasswordLockoutPolicyID();
|
||||
req.setId(id);
|
||||
|
||||
return await this.request(
|
||||
c => c.deletePasswordLockoutPolicy,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async UpdatePasswordLockoutPolicy(
|
||||
description: string,
|
||||
maxAttempts: number,
|
||||
showLockoutFailures: boolean,
|
||||
): Promise<PasswordLockoutPolicy> {
|
||||
const req = new PasswordLockoutPolicyUpdate();
|
||||
req.setDescription(description);
|
||||
req.setMaxAttempts(maxAttempts);
|
||||
req.setShowLockOutFailures(showLockoutFailures);
|
||||
return await this.request(
|
||||
c => c.updatePasswordLockoutPolicy,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public getLocalizedComplexityPolicyPatternErrorString(policy: PasswordComplexityPolicy.AsObject): string {
|
||||
if (policy.hasNumber && policy.hasSymbol) {
|
||||
return 'ORG.POLICY.PWD_COMPLEXITY.SYMBOLANDNUMBERERROR';
|
||||
} else if (policy.hasNumber) {
|
||||
return 'ORG.POLICY.PWD_COMPLEXITY.NUMBERERROR';
|
||||
} else if (policy.hasSymbol) {
|
||||
return 'ORG.POLICY.PWD_COMPLEXITY.SYMBOLERROR';
|
||||
} else {
|
||||
return 'ORG.POLICY.PWD_COMPLEXITY.PATTERNERROR';
|
||||
}
|
||||
}
|
||||
}
|
@ -1,604 +0,0 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Empty } from 'google-protobuf/google/protobuf/empty_pb';
|
||||
import { Metadata } from 'grpc-web';
|
||||
|
||||
import { ManagementServicePromiseClient } from '../proto/generated/management_grpc_web_pb';
|
||||
import {
|
||||
Application,
|
||||
ApplicationID,
|
||||
ApplicationSearchQuery,
|
||||
ApplicationSearchRequest,
|
||||
ApplicationSearchResponse,
|
||||
ApplicationUpdate,
|
||||
ApplicationView,
|
||||
GrantedProjectSearchRequest,
|
||||
OIDCApplicationCreate,
|
||||
OIDCConfig,
|
||||
OIDCConfigUpdate,
|
||||
Project,
|
||||
ProjectCreateRequest,
|
||||
ProjectGrant,
|
||||
ProjectGrantCreate,
|
||||
ProjectGrantID,
|
||||
ProjectGrantMember,
|
||||
ProjectGrantMemberAdd,
|
||||
ProjectGrantMemberChange,
|
||||
ProjectGrantMemberRemove,
|
||||
ProjectGrantMemberRoles,
|
||||
ProjectGrantMemberSearchQuery,
|
||||
ProjectGrantMemberSearchRequest,
|
||||
ProjectGrantSearchRequest,
|
||||
ProjectGrantSearchResponse,
|
||||
ProjectGrantUpdate,
|
||||
ProjectGrantView,
|
||||
ProjectID,
|
||||
ProjectMember,
|
||||
ProjectMemberAdd,
|
||||
ProjectMemberChange,
|
||||
ProjectMemberRemove,
|
||||
ProjectMemberRoles,
|
||||
ProjectMemberSearchRequest,
|
||||
ProjectMemberSearchResponse,
|
||||
ProjectRole,
|
||||
ProjectRoleAdd,
|
||||
ProjectRoleAddBulk,
|
||||
ProjectRoleChange,
|
||||
ProjectRoleRemove,
|
||||
ProjectRoleSearchQuery,
|
||||
ProjectRoleSearchRequest,
|
||||
ProjectRoleSearchResponse,
|
||||
ProjectSearchQuery,
|
||||
ProjectSearchRequest,
|
||||
ProjectSearchResponse,
|
||||
ProjectUpdateRequest,
|
||||
ProjectView,
|
||||
ZitadelDocs,
|
||||
} from '../proto/generated/management_pb';
|
||||
import { GrpcBackendService } from './grpc-backend.service';
|
||||
import { GrpcService, RequestFactory, ResponseMapper } from './grpc.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class ProjectService {
|
||||
constructor(private readonly grpcService: GrpcService, private grpcBackendService: GrpcBackendService) { }
|
||||
|
||||
public async request<TReq, TResp, TMappedResp>(
|
||||
requestFn: RequestFactory<ManagementServicePromiseClient, TReq, TResp>,
|
||||
request: TReq,
|
||||
responseMapper: ResponseMapper<TResp, TMappedResp>,
|
||||
metadata?: Metadata,
|
||||
): Promise<TMappedResp> {
|
||||
const mappedRequestFn = requestFn(this.grpcService.mgmt).bind(this.grpcService.mgmt);
|
||||
const response = await this.grpcBackendService.runRequest(
|
||||
mappedRequestFn,
|
||||
request,
|
||||
metadata,
|
||||
);
|
||||
return responseMapper(response);
|
||||
}
|
||||
|
||||
public async SearchProjects(
|
||||
limit: number, offset: number, queryList?: ProjectSearchQuery[]): Promise<ProjectSearchResponse> {
|
||||
const req = new ProjectSearchRequest();
|
||||
req.setLimit(limit);
|
||||
req.setOffset(offset);
|
||||
if (queryList) {
|
||||
req.setQueriesList(queryList);
|
||||
}
|
||||
return await this.request(
|
||||
c => c.searchProjects,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async SearchGrantedProjects(
|
||||
limit: number, offset: number, queryList?: ProjectSearchQuery[]): Promise<ProjectGrantSearchResponse> {
|
||||
const req = new GrantedProjectSearchRequest();
|
||||
req.setLimit(limit);
|
||||
req.setOffset(offset);
|
||||
if (queryList) {
|
||||
req.setQueriesList(queryList);
|
||||
}
|
||||
return await this.request(
|
||||
c => c.searchGrantedProjects,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public async GetZitadelDocs(): Promise<ZitadelDocs> {
|
||||
const req = new Empty();
|
||||
return await this.request(
|
||||
c => c.getZitadelDocs,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async GetProjectById(projectId: string): Promise<ProjectView> {
|
||||
const req = new ProjectID();
|
||||
req.setId(projectId);
|
||||
return await this.request(
|
||||
c => c.projectByID,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async GetGrantedProjectByID(projectId: string, id: string): Promise<ProjectGrantView> {
|
||||
const req = new ProjectGrantID();
|
||||
req.setId(id);
|
||||
req.setProjectId(projectId);
|
||||
return await this.request(
|
||||
c => c.getGrantedProjectByID,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async CreateProject(project: ProjectCreateRequest.AsObject): Promise<Project> {
|
||||
const req = new ProjectCreateRequest();
|
||||
req.setName(project.name);
|
||||
return await this.request(
|
||||
c => c.createProject,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async UpdateProject(id: string, name: string): Promise<Project> {
|
||||
const req = new ProjectUpdateRequest();
|
||||
req.setName(name);
|
||||
req.setId(id);
|
||||
return await this.request(
|
||||
c => c.updateProject,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async UpdateProjectGrant(id: string, projectId: string, rolesList: string[]): Promise<ProjectGrant> {
|
||||
const req = new ProjectGrantUpdate();
|
||||
req.setRoleKeysList(rolesList);
|
||||
req.setId(id);
|
||||
req.setProjectId(projectId);
|
||||
return await this.request(
|
||||
c => c.updateProjectGrant,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async RemoveProjectGrant(id: string, projectId: string): Promise<Empty> {
|
||||
const req = new ProjectGrantID();
|
||||
req.setId(id);
|
||||
req.setProjectId(projectId);
|
||||
return await this.request(
|
||||
c => c.removeProjectGrant,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async DeactivateProject(projectId: string): Promise<Project> {
|
||||
const req = new ProjectID();
|
||||
req.setId(projectId);
|
||||
return await this.request(
|
||||
c => c.deactivateProject,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async ReactivateProject(projectId: string): Promise<Project> {
|
||||
const req = new ProjectID();
|
||||
req.setId(projectId);
|
||||
return await this.request(
|
||||
c => c.reactivateProject,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async SearchProjectGrants(projectId: string, limit: number, offset: number): Promise<ProjectGrantSearchResponse> {
|
||||
const req = new ProjectGrantSearchRequest();
|
||||
req.setProjectId(projectId);
|
||||
req.setLimit(limit);
|
||||
req.setOffset(offset);
|
||||
return await this.request(
|
||||
c => c.searchProjectGrants,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async GetProjectGrantMemberRoles(): Promise<ProjectGrantMemberRoles> {
|
||||
const req = new Empty();
|
||||
return await this.request(
|
||||
c => c.getProjectGrantMemberRoles,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async AddProjectMember(id: string, userId: string, rolesList: string[]): Promise<Empty> {
|
||||
const req = new ProjectMemberAdd();
|
||||
req.setId(id);
|
||||
req.setUserId(userId);
|
||||
req.setRolesList(rolesList);
|
||||
return await this.request(
|
||||
c => c.addProjectMember,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async ChangeProjectMember(id: string, userId: string, rolesList: string[]): Promise<ProjectMember> {
|
||||
const req = new ProjectMemberChange();
|
||||
req.setId(id);
|
||||
req.setUserId(userId);
|
||||
req.setRolesList(rolesList);
|
||||
return await this.request(
|
||||
c => c.changeProjectMember,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async AddProjectGrantMember(
|
||||
projectId: string,
|
||||
grantId: string,
|
||||
userId: string,
|
||||
rolesList: string[],
|
||||
): Promise<Empty> {
|
||||
const req = new ProjectGrantMemberAdd();
|
||||
req.setProjectId(projectId);
|
||||
req.setGrantId(grantId);
|
||||
req.setUserId(userId);
|
||||
req.setRolesList(rolesList);
|
||||
return await this.request(
|
||||
c => c.addProjectGrantMember,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async ChangeProjectGrantMember(
|
||||
projectId: string,
|
||||
grantId: string,
|
||||
userId: string,
|
||||
rolesList: string[],
|
||||
): Promise<ProjectGrantMember> {
|
||||
const req = new ProjectGrantMemberChange();
|
||||
req.setProjectId(projectId);
|
||||
req.setGrantId(grantId);
|
||||
req.setUserId(userId);
|
||||
req.setRolesList(rolesList);
|
||||
return await this.request(
|
||||
c => c.changeProjectGrantMember,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async SearchProjectGrantMembers(
|
||||
projectId: string,
|
||||
grantId: string,
|
||||
limit: number,
|
||||
offset: number,
|
||||
queryList?: ProjectGrantMemberSearchQuery[],
|
||||
): Promise<ProjectMemberSearchResponse> {
|
||||
const req = new ProjectGrantMemberSearchRequest();
|
||||
req.setLimit(limit);
|
||||
req.setOffset(offset);
|
||||
if (queryList) {
|
||||
req.setQueriesList(queryList);
|
||||
}
|
||||
req.setProjectId(projectId);
|
||||
req.setGrantId(grantId);
|
||||
return await this.request(
|
||||
c => c.searchProjectGrantMembers,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async RemoveProjectGrantMember(
|
||||
projectId: string,
|
||||
grantId: string,
|
||||
userId: string,
|
||||
): Promise<Empty> {
|
||||
const req = new ProjectGrantMemberRemove();
|
||||
req.setGrantId(grantId);
|
||||
req.setUserId(userId);
|
||||
req.setProjectId(projectId);
|
||||
return await this.request(
|
||||
c => c.removeProjectGrantMember,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public async CreateProjectGrant(orgId: string, projectId: string, roleKeys: string[]): Promise<ProjectGrant> {
|
||||
const req = new ProjectGrantCreate();
|
||||
req.setGrantedOrgId(orgId);
|
||||
req.setProjectId(projectId);
|
||||
req.setRoleKeysList(roleKeys);
|
||||
return await this.request(
|
||||
c => c.createProjectGrant,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async ReactivateApplication(projectId: string, appId: string): Promise<Application> {
|
||||
const req = new ApplicationID();
|
||||
req.setId(appId);
|
||||
req.setProjectId(projectId);
|
||||
|
||||
return await this.request(
|
||||
c => c.reactivateApplication,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async DeactivateApplication(projectId: string, appId: string): Promise<Application> {
|
||||
const req = new ApplicationID();
|
||||
req.setId(appId);
|
||||
req.setProjectId(projectId);
|
||||
|
||||
return await this.request(
|
||||
c => c.deactivateApplication,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async RegenerateOIDCClientSecret(id: string, projectId: string): Promise<any> {
|
||||
const req = new ApplicationID();
|
||||
req.setId(id);
|
||||
req.setProjectId(projectId);
|
||||
return await this.request(
|
||||
c => c.regenerateOIDCClientSecret,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async SearchProjectRoles(
|
||||
projectId: string,
|
||||
limit: number,
|
||||
offset: number,
|
||||
queryList?: ProjectRoleSearchQuery[],
|
||||
): Promise<ProjectRoleSearchResponse> {
|
||||
const req = new ProjectRoleSearchRequest();
|
||||
req.setProjectId(projectId);
|
||||
req.setLimit(limit);
|
||||
req.setOffset(offset);
|
||||
if (queryList) {
|
||||
req.setQueriesList(queryList);
|
||||
}
|
||||
return await this.request(
|
||||
c => c.searchProjectRoles,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async AddProjectRole(role: ProjectRoleAdd.AsObject): Promise<Empty> {
|
||||
const req = new ProjectRoleAdd();
|
||||
req.setId(role.id);
|
||||
if (role.displayName) {
|
||||
req.setDisplayName(role.displayName);
|
||||
}
|
||||
req.setKey(role.key);
|
||||
req.setGroup(role.group);
|
||||
return await this.request(
|
||||
c => c.addProjectRole,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async BulkAddProjectRole(
|
||||
id: string,
|
||||
rolesList: ProjectRoleAdd[],
|
||||
): Promise<Empty> {
|
||||
const req = new ProjectRoleAddBulk();
|
||||
req.setId(id);
|
||||
req.setProjectRolesList(rolesList);
|
||||
return await this.request(
|
||||
c => c.bulkAddProjectRole,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async RemoveProjectRole(projectId: string, key: string): Promise<Empty> {
|
||||
const req = new ProjectRoleRemove();
|
||||
req.setId(projectId);
|
||||
req.setKey(key);
|
||||
return await this.request(
|
||||
c => c.removeProjectRole,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public async ChangeProjectRole(projectId: string, key: string, displayName: string, group: string):
|
||||
Promise<ProjectRole> {
|
||||
const req = new ProjectRoleChange();
|
||||
req.setId(projectId);
|
||||
req.setKey(key);
|
||||
req.setGroup(group);
|
||||
req.setDisplayName(displayName);
|
||||
return await this.request(
|
||||
c => c.changeProjectRole,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public async RemoveProjectMember(id: string, userId: string): Promise<Empty> {
|
||||
const req = new ProjectMemberRemove();
|
||||
req.setId(id);
|
||||
req.setUserId(userId);
|
||||
return await this.request(
|
||||
c => c.removeProjectMember,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async SearchProjectMembers(projectId: string,
|
||||
limit: number, offset: number): Promise<ProjectMemberSearchResponse> {
|
||||
const req = new ProjectMemberSearchRequest();
|
||||
req.setProjectId(projectId);
|
||||
req.setLimit(limit);
|
||||
req.setOffset(offset);
|
||||
return await this.request(
|
||||
c => c.searchProjectMembers,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async SearchApplications(
|
||||
projectId: string,
|
||||
limit: number,
|
||||
offset: number,
|
||||
queryList?: ApplicationSearchQuery[]): Promise<ApplicationSearchResponse> {
|
||||
const req = new ApplicationSearchRequest();
|
||||
req.setProjectId(projectId);
|
||||
req.setLimit(limit);
|
||||
req.setOffset(offset);
|
||||
if (queryList) {
|
||||
req.setQueriesList(queryList);
|
||||
}
|
||||
return await this.request(
|
||||
c => c.searchApplications,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async GetApplicationById(projectId: string, applicationId: string): Promise<ApplicationView> {
|
||||
const req = new ApplicationID();
|
||||
req.setProjectId(projectId);
|
||||
req.setId(applicationId);
|
||||
return await this.request(
|
||||
c => c.applicationByID,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async GetProjectMemberRoles(): Promise<ProjectMemberRoles> {
|
||||
const req = new Empty();
|
||||
return await this.request(
|
||||
c => c.getProjectMemberRoles,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async ProjectGrantByID(id: string, projectId: string): Promise<ProjectGrantView> {
|
||||
const req = new ProjectGrantID();
|
||||
req.setId(id);
|
||||
req.setProjectId(projectId);
|
||||
return await this.request(
|
||||
c => c.projectGrantByID,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async RemoveProject(id: string): Promise<Empty> {
|
||||
const req = new ProjectID();
|
||||
req.setId(id);
|
||||
return await this.request(
|
||||
c => c.removeProject,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public async DeactivateProjectGrant(id: string, projectId: string): Promise<ProjectGrant> {
|
||||
const req = new ProjectGrantID();
|
||||
req.setId(id);
|
||||
req.setProjectId(projectId);
|
||||
return await this.request(
|
||||
c => c.deactivateProjectGrant,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async ReactivateProjectGrant(id: string, projectId: string): Promise<ProjectGrant> {
|
||||
const req = new ProjectGrantID();
|
||||
req.setId(id);
|
||||
req.setProjectId(projectId);
|
||||
return await this.request(
|
||||
c => c.reactivateProjectGrant,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async CreateOIDCApp(app: OIDCApplicationCreate.AsObject): Promise<Application> {
|
||||
const req = new OIDCApplicationCreate();
|
||||
req.setProjectId(app.projectId);
|
||||
req.setName(app.name);
|
||||
req.setRedirectUrisList(app.redirectUrisList);
|
||||
req.setResponseTypesList(app.responseTypesList);
|
||||
req.setGrantTypesList(app.grantTypesList);
|
||||
req.setApplicationType(app.applicationType);
|
||||
req.setAuthMethodType(app.authMethodType);
|
||||
req.setPostLogoutRedirectUrisList(app.postLogoutRedirectUrisList);
|
||||
|
||||
return await this.request(
|
||||
c => c.createOIDCApplication,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async UpdateApplication(projectId: string, appId: string, name: string): Promise<Application> {
|
||||
const req = new ApplicationUpdate();
|
||||
req.setId(appId);
|
||||
req.setName(name);
|
||||
req.setProjectId(projectId);
|
||||
return await this.request(
|
||||
c => c.updateApplication,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async UpdateOIDCAppConfig(projectId: string,
|
||||
appId: string, oidcConfig: OIDCConfig.AsObject): Promise<OIDCConfig> {
|
||||
const req = new OIDCConfigUpdate();
|
||||
req.setProjectId(projectId);
|
||||
req.setApplicationId(appId);
|
||||
req.setRedirectUrisList(oidcConfig.redirectUrisList);
|
||||
req.setResponseTypesList(oidcConfig.responseTypesList);
|
||||
req.setAuthMethodType(oidcConfig.authMethodType);
|
||||
req.setPostLogoutRedirectUrisList(oidcConfig.postLogoutRedirectUrisList);
|
||||
req.setGrantTypesList(oidcConfig.grantTypesList);
|
||||
req.setApplicationType(oidcConfig.applicationType);
|
||||
req.setDevMode(oidcConfig.devMode);
|
||||
return await this.request(
|
||||
c => c.updateApplicationOIDCConfig,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
}
|
@ -6,7 +6,7 @@ import { Observable } from 'rxjs';
|
||||
import { take } from 'rxjs/operators';
|
||||
|
||||
import { WarnDialogComponent } from '../modules/warn-dialog/warn-dialog.component';
|
||||
import { AuthService } from './auth.service';
|
||||
import { AuthenticationService } from './authentication.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
@ -15,7 +15,7 @@ export class ToastService {
|
||||
constructor(private dialog: MatDialog,
|
||||
private snackBar: MatSnackBar,
|
||||
private translate: TranslateService,
|
||||
private authService: AuthService,
|
||||
private authService: AuthenticationService,
|
||||
) { }
|
||||
|
||||
public showInfo(message: string, i18nkey: boolean = false): void {
|
||||
|
@ -3,5 +3,5 @@
|
||||
"mgmtServiceUrl": "https://api.zitadel.dev",
|
||||
"adminServiceUrl":"https://api.zitadel.dev",
|
||||
"issuer": "https://issuer.zitadel.dev",
|
||||
"clientid": "63426288794266821@zitadel"
|
||||
"clientid": "70669160379706195@zitadel"
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user