mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-05 22:02:15 +00:00
feat(console): domain verification, create org, regexp route guards, change org, iam member (#573)
* verification dialog, service * i18n, verification dialog * file saver * savefile * verify trigger * delete project, i18n * org create dialog * org-create-self * stylelint * fix signout redirect * rm unused dialog component, import * project i18n de * regexp roles * use regex to check permissions * border radius * change validation flow * update org member * iam member change * lint * rm unused css * Update console/src/assets/i18n/de.json Co-authored-by: Fabi <[email protected]> * Update console/src/assets/i18n/de.json Co-authored-by: Fabi <[email protected]> * change guard Co-authored-by: Fabi <[email protected]>
This commit is contained in:
@@ -5,6 +5,7 @@ import { Metadata } from 'grpc-web';
|
||||
import { AdminServicePromiseClient } from '../proto/generated/admin_grpc_web_pb';
|
||||
import {
|
||||
AddIamMemberRequest,
|
||||
ChangeIamMemberRequest,
|
||||
CreateOrgRequest,
|
||||
CreateUserRequest,
|
||||
IamMember,
|
||||
@@ -134,6 +135,20 @@ export class AdminService {
|
||||
);
|
||||
}
|
||||
|
||||
public async ChangeIamMember(
|
||||
userId: string,
|
||||
rolesList: string[],
|
||||
): Promise<IamMember> {
|
||||
const req = new ChangeIamMemberRequest();
|
||||
req.setUserId(userId);
|
||||
req.setRolesList(rolesList);
|
||||
|
||||
return await this.request(
|
||||
c => c.changeIamMember,
|
||||
req,
|
||||
f => f,
|
||||
);
|
||||
}
|
||||
|
||||
public async GetOrgIamPolicy(orgId: string): Promise<OrgIamPolicy> {
|
||||
const req = new OrgIamPolicyID();
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
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';
|
||||
@@ -31,7 +30,6 @@ export class AuthService {
|
||||
private userService: AuthUserService,
|
||||
private storage: StorageService,
|
||||
private statehandler: StatehandlerService,
|
||||
private router: Router,
|
||||
) {
|
||||
this.user = merge(
|
||||
of(this.oauthService.getAccessToken()).pipe(
|
||||
@@ -66,25 +64,28 @@ export class AuthService {
|
||||
first(),
|
||||
switchMap(() => from(this.userService.GetMyzitadelPermissions())),
|
||||
map(rolesResp => rolesResp.toObject().permissionsList),
|
||||
).subscribe(roles => this.zitadelPermissions.next(roles));
|
||||
).subscribe(roles => {
|
||||
console.log(roles);
|
||||
this.zitadelPermissions.next(roles);
|
||||
});
|
||||
}
|
||||
|
||||
public isAllowed(roles: string[], each: boolean = false): Observable<boolean> {
|
||||
public isAllowed(roles: string[] | RegExp[]): Observable<boolean> {
|
||||
if (roles && roles.length > 0) {
|
||||
return this.zitadelPermissions.pipe(switchMap(zroles => {
|
||||
return of(this.hasRoles(zroles, roles, each));
|
||||
return of(this.hasRoles(zroles, roles));
|
||||
}));
|
||||
} else {
|
||||
return of(false);
|
||||
}
|
||||
}
|
||||
|
||||
public hasRoles(userRoles: string[], requestedRoles: string[], each: boolean = false): boolean {
|
||||
return each ?
|
||||
requestedRoles.every(role => userRoles.includes(role)) :
|
||||
requestedRoles.findIndex(role => {
|
||||
return userRoles.findIndex(i => i.includes(role)) > -1;
|
||||
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 {
|
||||
@@ -129,7 +130,6 @@ export class AuthService {
|
||||
this.oauthService.logOut();
|
||||
this._authenticated = false;
|
||||
this._authenticationChanged.next(false);
|
||||
this.router.navigate(['/']);
|
||||
}
|
||||
|
||||
public get activeOrgChanged(): Observable<Org.AsObject> {
|
||||
|
||||
@@ -6,15 +6,21 @@ import { ManagementServicePromiseClient } from '../proto/generated/management_gr
|
||||
import {
|
||||
AddOrgDomainRequest,
|
||||
AddOrgMemberRequest,
|
||||
ChangeOrgMemberRequest,
|
||||
Domain,
|
||||
Iam,
|
||||
Org,
|
||||
OrgCreateRequest,
|
||||
OrgDomain,
|
||||
OrgDomainSearchQuery,
|
||||
OrgDomainSearchRequest,
|
||||
OrgDomainSearchResponse,
|
||||
OrgDomainValidationRequest,
|
||||
OrgDomainValidationResponse,
|
||||
OrgDomainValidationType,
|
||||
OrgIamPolicy,
|
||||
OrgID,
|
||||
OrgMember,
|
||||
OrgMemberRoles,
|
||||
OrgMemberSearchRequest,
|
||||
OrgMemberSearchResponse,
|
||||
@@ -34,6 +40,7 @@ import {
|
||||
ProjectGrantCreate,
|
||||
RemoveOrgDomainRequest,
|
||||
RemoveOrgMemberRequest,
|
||||
ValidateOrgDomainRequest,
|
||||
} from '../proto/generated/management_pb';
|
||||
import { GrpcBackendService } from './grpc-backend.service';
|
||||
import { GrpcService, RequestFactory, ResponseMapper } from './grpc.service';
|
||||
@@ -121,6 +128,31 @@ export class OrgService {
|
||||
);
|
||||
}
|
||||
|
||||
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);
|
||||
@@ -142,6 +174,16 @@ export class OrgService {
|
||||
);
|
||||
}
|
||||
|
||||
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);
|
||||
@@ -155,6 +197,18 @@ export class OrgService {
|
||||
);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
ApplicationSearchRequest,
|
||||
ApplicationSearchResponse,
|
||||
ApplicationUpdate,
|
||||
ApplicationView,
|
||||
GrantedProjectSearchRequest,
|
||||
OIDCApplicationCreate,
|
||||
OIDCConfig,
|
||||
@@ -488,7 +489,7 @@ export class ProjectService {
|
||||
);
|
||||
}
|
||||
|
||||
public async GetApplicationById(projectId: string, applicationId: string): Promise<Application> {
|
||||
public async GetApplicationById(projectId: string, applicationId: string): Promise<ApplicationView> {
|
||||
const req = new ApplicationID();
|
||||
req.setProjectId(projectId);
|
||||
req.setId(applicationId);
|
||||
@@ -519,6 +520,16 @@ export class ProjectService {
|
||||
);
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
Reference in New Issue
Block a user