mirror of
https://github.com/zitadel/zitadel.git
synced 2025-02-25 18:55:27 -06:00
* fix 2fa,mfa config, self management * u2f enable when otp * passwordless grpc auth * clockskew, passwordless container, util class * passwordless, i18n * passwordless auth and mgmt * lint ts * chore(deps-dev): bump ts-node from 9.1.0 to 9.1.1 in /console (#1089) Bumps [ts-node](https://github.com/TypeStrong/ts-node) from 9.1.0 to 9.1.1. - [Release notes](https://github.com/TypeStrong/ts-node/releases) - [Commits](https://github.com/TypeStrong/ts-node/compare/v9.1.0...v9.1.1) 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/cli from 11.0.3 to 11.0.4 in /console (#1094) Bumps [@angular/cli](https://github.com/angular/angular-cli) from 11.0.3 to 11.0.4. - [Release notes](https://github.com/angular/angular-cli/releases) - [Commits](https://github.com/angular/angular-cli/compare/v11.0.3...v11.0.4) 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): bump uuid from 8.3.1 to 8.3.2 in /console (#1098) Bumps [uuid](https://github.com/uuidjs/uuid) from 8.3.1 to 8.3.2. - [Release notes](https://github.com/uuidjs/uuid/releases) - [Changelog](https://github.com/uuidjs/uuid/blob/master/CHANGELOG.md) - [Commits](https://github.com/uuidjs/uuid/compare/v8.3.1...v8.3.2) 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 (#1099) Bumps [@angular/language-service](https://github.com/angular/angular/tree/HEAD/packages/language-service) from 11.0.3 to 11.0.4. - [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/11.0.4/packages/language-service) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps-dev): bump @types/node from 14.14.10 to 14.14.13 in /console (#1100) Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 14.14.10 to 14.14.13. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node) 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 (#1088) Bumps [@angular-devkit/build-angular](https://github.com/angular/angular-cli) from 0.1100.3 to 0.1100.4. - [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> Co-authored-by: Max Peintner <max@caos.ch> * fix: replace regex check for projectid (#1064) * update lock * fix app detail * logs * fix login policy update * fix error message * decode excluded cred id Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Livio Amstutz <livio.a@gmail.com>
402 lines
12 KiB
TypeScript
402 lines
12 KiB
TypeScript
import { Injectable } from '@angular/core';
|
|
import { Empty } from 'google-protobuf/google/protobuf/empty_pb';
|
|
|
|
import {
|
|
AddIamMemberRequest,
|
|
ChangeIamMemberRequest,
|
|
CreateHumanRequest,
|
|
CreateOrgRequest,
|
|
CreateUserRequest,
|
|
DefaultLabelPolicy,
|
|
DefaultLabelPolicyUpdate,
|
|
DefaultLabelPolicyView,
|
|
DefaultLoginPolicy,
|
|
DefaultLoginPolicyRequest,
|
|
DefaultLoginPolicyView,
|
|
DefaultPasswordAgePolicyRequest,
|
|
DefaultPasswordAgePolicyView,
|
|
DefaultPasswordComplexityPolicy,
|
|
DefaultPasswordComplexityPolicyRequest,
|
|
DefaultPasswordComplexityPolicyView,
|
|
DefaultPasswordLockoutPolicy,
|
|
DefaultPasswordLockoutPolicyRequest,
|
|
DefaultPasswordLockoutPolicyView,
|
|
FailedEventID,
|
|
FailedEvents,
|
|
IamMember,
|
|
IamMemberRoles,
|
|
IamMemberSearchQuery,
|
|
IamMemberSearchRequest,
|
|
IamMemberSearchResponse,
|
|
Idp,
|
|
IdpID,
|
|
IdpProviderID,
|
|
IdpProviderSearchRequest,
|
|
IdpProviderSearchResponse,
|
|
IdpSearchQuery,
|
|
IdpSearchRequest,
|
|
IdpSearchResponse,
|
|
IdpView,
|
|
MultiFactor,
|
|
MultiFactorsResult,
|
|
OidcIdpConfig,
|
|
OidcIdpConfigCreate,
|
|
OidcIdpConfigUpdate,
|
|
OrgIamPolicy,
|
|
OrgIamPolicyID,
|
|
OrgIamPolicyRequest,
|
|
OrgIamPolicyView,
|
|
OrgSetUpRequest,
|
|
OrgSetUpResponse,
|
|
RemoveIamMemberRequest,
|
|
SecondFactor,
|
|
SecondFactorsResult,
|
|
ViewID,
|
|
Views,
|
|
} from '../proto/generated/admin_pb';
|
|
import { IdpUpdate } from '../proto/generated/management_pb';
|
|
import { GrpcService } from './grpc.service';
|
|
|
|
@Injectable({
|
|
providedIn: 'root',
|
|
})
|
|
export class AdminService {
|
|
constructor(private readonly grpcService: GrpcService) { }
|
|
|
|
public SetUpOrg(
|
|
createOrgRequest: CreateOrgRequest,
|
|
humanRequest: CreateHumanRequest,
|
|
): Promise<OrgSetUpResponse> {
|
|
const req: OrgSetUpRequest = new OrgSetUpRequest();
|
|
const userReq: CreateUserRequest = new CreateUserRequest();
|
|
|
|
userReq.setHuman(humanRequest);
|
|
|
|
req.setOrg(createOrgRequest);
|
|
req.setUser(userReq);
|
|
|
|
return this.grpcService.admin.setUpOrg(req);
|
|
}
|
|
|
|
public getDefaultLoginPolicyMultiFactors(): Promise<MultiFactorsResult> {
|
|
const req = new Empty();
|
|
return this.grpcService.admin.getDefaultLoginPolicyMultiFactors(req);
|
|
}
|
|
|
|
public addMultiFactorToDefaultLoginPolicy(req: MultiFactor): Promise<MultiFactor> {
|
|
return this.grpcService.admin.addMultiFactorToDefaultLoginPolicy(req);
|
|
}
|
|
|
|
public RemoveMultiFactorFromDefaultLoginPolicy(req: MultiFactor): Promise<Empty> {
|
|
return this.grpcService.admin.removeMultiFactorFromDefaultLoginPolicy(req);
|
|
}
|
|
|
|
public GetDefaultLoginPolicySecondFactors(): Promise<SecondFactorsResult> {
|
|
const req = new Empty();
|
|
return this.grpcService.admin.getDefaultLoginPolicySecondFactors(req);
|
|
}
|
|
|
|
public AddSecondFactorToDefaultLoginPolicy(req: SecondFactor): Promise<SecondFactor> {
|
|
return this.grpcService.admin.addSecondFactorToDefaultLoginPolicy(req);
|
|
}
|
|
|
|
public RemoveSecondFactorFromDefaultLoginPolicy(req: SecondFactor): Promise<Empty> {
|
|
return this.grpcService.admin.removeSecondFactorFromDefaultLoginPolicy(req);
|
|
}
|
|
|
|
public GetIamMemberRoles(): Promise<IamMemberRoles> {
|
|
const req = new Empty();
|
|
return this.grpcService.admin.getIamMemberRoles(req);
|
|
}
|
|
|
|
public GetViews(): Promise<Views> {
|
|
const req = new Empty();
|
|
return this.grpcService.admin.getViews(req);
|
|
}
|
|
|
|
public GetFailedEvents(): Promise<FailedEvents> {
|
|
const req = new Empty();
|
|
return this.grpcService.admin.getFailedEvents(req);
|
|
}
|
|
|
|
public ClearView(viewname: string, db: string): Promise<Empty> {
|
|
const req: ViewID = new ViewID();
|
|
req.setDatabase(db);
|
|
req.setViewName(viewname);
|
|
return this.grpcService.admin.clearView(req);
|
|
}
|
|
|
|
public RemoveFailedEvent(viewname: string, db: string, sequence: number): Promise<Empty> {
|
|
const req: FailedEventID = new FailedEventID();
|
|
req.setDatabase(db);
|
|
req.setViewName(viewname);
|
|
req.setFailedSequence(sequence);
|
|
return this.grpcService.admin.removeFailedEvent(req);
|
|
}
|
|
|
|
/* Policies */
|
|
|
|
/* complexity */
|
|
|
|
public GetDefaultPasswordComplexityPolicy(): Promise<DefaultPasswordComplexityPolicyView> {
|
|
const req = new Empty();
|
|
return this.grpcService.admin.getDefaultPasswordComplexityPolicy(req);
|
|
}
|
|
|
|
public UpdateDefaultPasswordComplexityPolicy(
|
|
hasLowerCase: boolean,
|
|
hasUpperCase: boolean,
|
|
hasNumber: boolean,
|
|
hasSymbol: boolean,
|
|
minLength: number,
|
|
): Promise<DefaultPasswordComplexityPolicy> {
|
|
const req = new DefaultPasswordComplexityPolicyRequest();
|
|
req.setHasLowercase(hasLowerCase);
|
|
req.setHasUppercase(hasUpperCase);
|
|
req.setHasNumber(hasNumber);
|
|
req.setHasSymbol(hasSymbol);
|
|
req.setMinLength(minLength);
|
|
return this.grpcService.admin.updateDefaultPasswordComplexityPolicy(req);
|
|
}
|
|
|
|
/* age */
|
|
|
|
public GetDefaultPasswordAgePolicy(): Promise<DefaultPasswordAgePolicyView> {
|
|
const req = new Empty();
|
|
|
|
return this.grpcService.admin.getDefaultPasswordAgePolicy(req);
|
|
}
|
|
|
|
public UpdateDefaultPasswordAgePolicy(
|
|
maxAgeDays: number,
|
|
expireWarnDays: number,
|
|
): Promise<DefaultPasswordAgePolicyView> {
|
|
const req = new DefaultPasswordAgePolicyRequest();
|
|
req.setMaxAgeDays(maxAgeDays);
|
|
req.setExpireWarnDays(expireWarnDays);
|
|
|
|
return this.grpcService.admin.updateDefaultPasswordAgePolicy(req);
|
|
}
|
|
|
|
/* lockout */
|
|
|
|
public GetDefaultPasswordLockoutPolicy(): Promise<DefaultPasswordLockoutPolicyView> {
|
|
const req = new Empty();
|
|
return this.grpcService.admin.getDefaultPasswordLockoutPolicy(req);
|
|
}
|
|
|
|
public UpdateDefaultPasswordLockoutPolicy(
|
|
maxAttempts: number,
|
|
showLockoutFailures: boolean,
|
|
): Promise<DefaultPasswordLockoutPolicy> {
|
|
const req = new DefaultPasswordLockoutPolicyRequest();
|
|
req.setMaxAttempts(maxAttempts);
|
|
req.setShowLockoutFailure(showLockoutFailures);
|
|
|
|
return this.grpcService.admin.updateDefaultPasswordLockoutPolicy(req);
|
|
}
|
|
|
|
/* label */
|
|
|
|
public GetDefaultLabelPolicy(): Promise<DefaultLabelPolicyView> {
|
|
const req = new Empty();
|
|
return this.grpcService.admin.getDefaultLabelPolicy(req);
|
|
}
|
|
|
|
public UpdateDefaultLabelPolicy(req: DefaultLabelPolicyUpdate): Promise<DefaultLabelPolicy> {
|
|
return this.grpcService.admin.updateDefaultLabelPolicy(req);
|
|
}
|
|
|
|
/* login */
|
|
|
|
public GetDefaultLoginPolicy(
|
|
): Promise<DefaultLoginPolicyView> {
|
|
const req = new Empty();
|
|
return this.grpcService.admin.getDefaultLoginPolicy(req);
|
|
}
|
|
|
|
public UpdateDefaultLoginPolicy(req: DefaultLoginPolicyRequest): Promise<DefaultLoginPolicy> {
|
|
return this.grpcService.admin.updateDefaultLoginPolicy(req);
|
|
}
|
|
|
|
/* org iam */
|
|
|
|
public GetOrgIamPolicy(orgId: string): Promise<OrgIamPolicyView> {
|
|
const req = new OrgIamPolicyID();
|
|
req.setOrgId(orgId);
|
|
return this.grpcService.admin.getOrgIamPolicy(req);
|
|
}
|
|
|
|
public CreateOrgIamPolicy(
|
|
orgId: string,
|
|
userLoginMustBeDomain: boolean): Promise<OrgIamPolicy> {
|
|
const req = new OrgIamPolicyRequest();
|
|
req.setOrgId(orgId);
|
|
req.setUserLoginMustBeDomain(userLoginMustBeDomain);
|
|
|
|
return this.grpcService.admin.createOrgIamPolicy(req);
|
|
}
|
|
|
|
public UpdateOrgIamPolicy(
|
|
orgId: string,
|
|
userLoginMustBeDomain: boolean): Promise<OrgIamPolicy> {
|
|
const req = new OrgIamPolicyRequest();
|
|
req.setOrgId(orgId);
|
|
req.setUserLoginMustBeDomain(userLoginMustBeDomain);
|
|
return this.grpcService.admin.updateOrgIamPolicy(req);
|
|
}
|
|
|
|
public RemoveOrgIamPolicy(
|
|
orgId: string,
|
|
): Promise<Empty> {
|
|
const req = new OrgIamPolicyID();
|
|
req.setOrgId(orgId);
|
|
return this.grpcService.admin.removeOrgIamPolicy(req);
|
|
}
|
|
|
|
/* admin iam */
|
|
|
|
public GetDefaultOrgIamPolicy(): Promise<OrgIamPolicyView> {
|
|
const req = new Empty();
|
|
return this.grpcService.admin.getDefaultOrgIamPolicy(req);
|
|
}
|
|
|
|
/* policies end */
|
|
|
|
public AddIdpProviderToDefaultLoginPolicy(configId: string): Promise<IdpProviderID> {
|
|
const req = new IdpProviderID();
|
|
req.setIdpConfigId(configId);
|
|
return this.grpcService.admin.addIdpProviderToDefaultLoginPolicy(req);
|
|
}
|
|
|
|
public RemoveIdpProviderFromDefaultLoginPolicy(configId: string): Promise<Empty> {
|
|
const req = new IdpProviderID();
|
|
req.setIdpConfigId(configId);
|
|
return this.grpcService.admin.removeIdpProviderFromDefaultLoginPolicy(req);
|
|
}
|
|
|
|
public GetDefaultLoginPolicyIdpProviders(limit?: number, offset?: number): Promise<IdpProviderSearchResponse> {
|
|
const req = new IdpProviderSearchRequest();
|
|
if (limit) {
|
|
req.setLimit(limit);
|
|
}
|
|
if (offset) {
|
|
req.setOffset(offset);
|
|
}
|
|
return this.grpcService.admin.getDefaultLoginPolicyIdpProviders(req);
|
|
}
|
|
|
|
public SearchIdps(
|
|
limit?: number,
|
|
offset?: number,
|
|
queryList?: IdpSearchQuery[],
|
|
): Promise<IdpSearchResponse> {
|
|
const req = new IdpSearchRequest();
|
|
if (limit) {
|
|
req.setLimit(limit);
|
|
}
|
|
if (offset) {
|
|
req.setOffset(offset);
|
|
}
|
|
if (queryList) {
|
|
req.setQueriesList(queryList);
|
|
}
|
|
return this.grpcService.admin.searchIdps(req);
|
|
}
|
|
|
|
public IdpByID(
|
|
id: string,
|
|
): Promise<IdpView> {
|
|
const req = new IdpID();
|
|
req.setId(id);
|
|
return this.grpcService.admin.idpByID(req);
|
|
}
|
|
|
|
public UpdateIdp(
|
|
req: IdpUpdate,
|
|
): Promise<Idp> {
|
|
return this.grpcService.admin.updateIdpConfig(req);
|
|
}
|
|
|
|
public CreateOidcIdp(
|
|
req: OidcIdpConfigCreate,
|
|
): Promise<Idp> {
|
|
return this.grpcService.admin.createOidcIdp(req);
|
|
}
|
|
|
|
public UpdateOidcIdpConfig(
|
|
req: OidcIdpConfigUpdate,
|
|
): Promise<OidcIdpConfig> {
|
|
return this.grpcService.admin.updateOidcIdpConfig(req);
|
|
}
|
|
|
|
public RemoveIdpConfig(
|
|
id: string,
|
|
): Promise<Empty> {
|
|
const req = new IdpID;
|
|
req.setId(id);
|
|
return this.grpcService.admin.removeIdpConfig(req);
|
|
}
|
|
|
|
public DeactivateIdpConfig(
|
|
id: string,
|
|
): Promise<Empty> {
|
|
const req = new IdpID;
|
|
req.setId(id);
|
|
return this.grpcService.admin.deactivateIdpConfig(req);
|
|
}
|
|
|
|
public ReactivateIdpConfig(
|
|
id: string,
|
|
): Promise<Empty> {
|
|
const req = new IdpID;
|
|
req.setId(id);
|
|
return this.grpcService.admin.reactivateIdpConfig(req);
|
|
}
|
|
|
|
public SearchIamMembers(
|
|
limit: number,
|
|
offset: number,
|
|
queryList?: IamMemberSearchQuery[],
|
|
): Promise<IamMemberSearchResponse> {
|
|
const req = new IamMemberSearchRequest();
|
|
req.setLimit(limit);
|
|
req.setOffset(offset);
|
|
if (queryList) {
|
|
req.setQueriesList(queryList);
|
|
}
|
|
return this.grpcService.admin.searchIamMembers(req);
|
|
}
|
|
|
|
public RemoveIamMember(
|
|
userId: string,
|
|
): Promise<Empty> {
|
|
const req = new RemoveIamMemberRequest();
|
|
req.setUserId(userId);
|
|
|
|
return this.grpcService.admin.removeIamMember(req);
|
|
}
|
|
|
|
public AddIamMember(
|
|
userId: string,
|
|
rolesList: string[],
|
|
): Promise<IamMember> {
|
|
const req = new AddIamMemberRequest();
|
|
req.setUserId(userId);
|
|
req.setRolesList(rolesList);
|
|
|
|
return this.grpcService.admin.addIamMember(req);
|
|
}
|
|
|
|
public ChangeIamMember(
|
|
userId: string,
|
|
rolesList: string[],
|
|
): Promise<IamMember> {
|
|
const req = new ChangeIamMemberRequest();
|
|
req.setUserId(userId);
|
|
req.setRolesList(rolesList);
|
|
|
|
return this.grpcService.admin.changeIamMember(req);
|
|
}
|
|
}
|