mirror of
https://github.com/zitadel/zitadel.git
synced 2025-02-25 18:55:27 -06:00
* proto gen * fix: remove type from project lists (#256) * fix: remove type from project lists * Update user-detail.component.ts * fix: remove add project Co-authored-by: Livio Amstutz <livio.a@gmail.com> * fix project view model * regen mgmt proto * rm orgid from route, switch to project view * chore(deps-dev): bump @types/jasmine from 3.5.10 to 3.5.11 in /console (#252) Bumps [@types/jasmine](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/jasmine) from 3.5.10 to 3.5.11. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/jasmine) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps-dev): bump @angular-devkit/build-angular in /console (#251) Bumps [@angular-devkit/build-angular](https://github.com/angular/angular-cli) from 0.901.7 to 0.901.9. - [Release notes](https://github.com/angular/angular-cli/releases) - [Commits](https://github.com/angular/angular-cli/commits) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps): bump moment from 2.26.0 to 2.27.0 in /console (#250) Bumps [moment](https://github.com/moment/moment) from 2.26.0 to 2.27.0. - [Release notes](https://github.com/moment/moment/releases) - [Changelog](https://github.com/moment/moment/blob/develop/CHANGELOG.md) - [Commits](https://github.com/moment/moment/compare/2.26.0...2.27.0) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps-dev): bump karma from 5.0.9 to 5.1.0 in /console (#218) Bumps [karma](https://github.com/karma-runner/karma) from 5.0.9 to 5.1.0. - [Release notes](https://github.com/karma-runner/karma/releases) - [Changelog](https://github.com/karma-runner/karma/blob/master/CHANGELOG.md) - [Commits](https://github.com/karma-runner/karma/compare/v5.0.9...v5.1.0) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps): bump ngx-moment from 3.5.0 to 4.0.1 in /console (#219) Bumps [ngx-moment](https://github.com/urish/ngx-moment) from 3.5.0 to 4.0.1. - [Release notes](https://github.com/urish/ngx-moment/releases) - [Changelog](https://github.com/urish/ngx-moment/blob/master/CHANGELOG.md) - [Commits](https://github.com/urish/ngx-moment/compare/3.5.0...4.0.1) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Max Peintner <max@caos.ch> * chore(deps-dev): bump @angular/language-service in /console (#217) Bumps [@angular/language-service](https://github.com/angular/angular/tree/HEAD/packages/language-service) from 9.1.10 to 9.1.11. - [Release notes](https://github.com/angular/angular/releases) - [Changelog](https://github.com/angular/angular/blob/master/CHANGELOG.md) - [Commits](https://github.com/angular/angular/commits/9.1.11/packages/language-service) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Max Peintner <max@caos.ch> * chore(deps-dev): bump @angular/cli from 9.1.7 to 9.1.9 in /console (#249) Bumps [@angular/cli](https://github.com/angular/angular-cli) from 9.1.7 to 9.1.9. - [Release notes](https://github.com/angular/angular-cli/releases) - [Commits](https://github.com/angular/angular-cli/compare/v9.1.7...v9.1.9) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Max Peintner <max@caos.ch> * set partial user profile * fix org routing * auth user loginnames, i18n * fix clipboard, secret regeneration * project role required field * show change editor * show granted project grid, remove add button * hide meta overflow Co-authored-by: Fabi <38692350+fgerschwiler@users.noreply.github.com> Co-authored-by: Livio Amstutz <livio.a@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
382 lines
11 KiB
TypeScript
382 lines
11 KiB
TypeScript
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,
|
|
Iam,
|
|
Org,
|
|
OrgDomain,
|
|
OrgDomainSearchQuery,
|
|
OrgDomainSearchRequest,
|
|
OrgDomainSearchResponse,
|
|
OrgID,
|
|
OrgMemberRoles,
|
|
OrgMemberSearchRequest,
|
|
OrgMemberSearchResponse,
|
|
PasswordAgePolicy,
|
|
PasswordAgePolicyCreate,
|
|
PasswordAgePolicyID,
|
|
PasswordAgePolicyUpdate,
|
|
PasswordComplexityPolicy,
|
|
PasswordComplexityPolicyCreate,
|
|
PasswordComplexityPolicyID,
|
|
PasswordComplexityPolicyUpdate,
|
|
PasswordLockoutPolicy,
|
|
PasswordLockoutPolicyCreate,
|
|
PasswordLockoutPolicyID,
|
|
PasswordLockoutPolicyUpdate,
|
|
ProjectGrant,
|
|
ProjectGrantCreate,
|
|
RemoveOrgDomainRequest,
|
|
RemoveOrgMemberRequest,
|
|
} 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 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 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 OrgDomain();
|
|
req.setDomain(domain);
|
|
return await this.request(
|
|
c => c.getOrgByDomainGlobal,
|
|
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 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 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';
|
|
}
|
|
}
|
|
}
|