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>
534 lines
16 KiB
TypeScript
534 lines
16 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 {
|
|
Application,
|
|
ApplicationID,
|
|
ApplicationSearchQuery,
|
|
ApplicationSearchRequest,
|
|
ApplicationSearchResponse,
|
|
ApplicationUpdate,
|
|
GrantedProjectSearchRequest,
|
|
OIDCApplicationCreate,
|
|
OIDCConfig,
|
|
OIDCConfigUpdate,
|
|
Project,
|
|
ProjectCreateRequest,
|
|
ProjectGrant,
|
|
ProjectGrantCreate,
|
|
ProjectGrantID,
|
|
ProjectGrantMemberAdd,
|
|
ProjectGrantMemberRemove,
|
|
ProjectGrantMemberRoles,
|
|
ProjectGrantMemberSearchQuery,
|
|
ProjectGrantMemberSearchRequest,
|
|
ProjectGrantSearchRequest,
|
|
ProjectGrantSearchResponse,
|
|
ProjectGrantUpdate,
|
|
ProjectGrantView,
|
|
ProjectID,
|
|
ProjectMemberAdd,
|
|
ProjectMemberChange,
|
|
ProjectMemberRemove,
|
|
ProjectMemberRoles,
|
|
ProjectMemberSearchRequest,
|
|
ProjectMemberSearchResponse,
|
|
ProjectRoleAdd,
|
|
ProjectRoleRemove,
|
|
ProjectRoleSearchQuery,
|
|
ProjectRoleSearchRequest,
|
|
ProjectRoleSearchResponse,
|
|
ProjectSearchQuery,
|
|
ProjectSearchRequest,
|
|
ProjectSearchResponse,
|
|
ProjectUpdateRequest,
|
|
ProjectUserGrantSearchRequest,
|
|
ProjectView,
|
|
UserGrant,
|
|
UserGrantCreate,
|
|
UserGrantSearchQuery,
|
|
UserGrantSearchResponse,
|
|
} 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 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 ChangeProjectMember(id: string, userId: string, rolesList: string[]): Promise<Empty> {
|
|
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 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(projectId: string, userId: string, rolesList: string[]): Promise<Empty> {
|
|
const req = new ProjectMemberAdd();
|
|
req.setId(projectId);
|
|
req.setUserId(userId);
|
|
req.setRolesList(rolesList);
|
|
return await this.request(
|
|
c => c.addProjectMember,
|
|
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 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.setProjectId(projectId);
|
|
req.setGrantId(grantId);
|
|
req.setUserId(userId);
|
|
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(appId: string): Promise<Application> {
|
|
const req = new ApplicationID();
|
|
req.setId(appId);
|
|
return await this.request(
|
|
c => c.reactivateApplication,
|
|
req,
|
|
f => f,
|
|
);
|
|
}
|
|
|
|
public async DectivateApplication(projectId: string): Promise<Application> {
|
|
const req = new ApplicationID();
|
|
req.setId(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 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 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<Application> {
|
|
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): Promise<ProjectGrant> {
|
|
const req = new ProjectGrantID();
|
|
return await this.request(
|
|
c => c.projectGrantByID,
|
|
req,
|
|
f => f,
|
|
);
|
|
}
|
|
|
|
// ********* */
|
|
|
|
public async SearchProjectUserGrants(
|
|
projectId: string,
|
|
offset: number,
|
|
limit: number,
|
|
queryList?: UserGrantSearchQuery[],
|
|
): Promise<UserGrantSearchResponse> {
|
|
const req = new ProjectUserGrantSearchRequest();
|
|
req.setLimit(limit);
|
|
req.setOffset(offset);
|
|
req.setProjectId(projectId);
|
|
if (queryList) {
|
|
req.setQueriesList(queryList);
|
|
}
|
|
return await this.request(
|
|
c => c.searchProjectUserGrants,
|
|
req,
|
|
f => f,
|
|
);
|
|
}
|
|
|
|
public async CreateProjectUserGrant(
|
|
projectId: string,
|
|
userId: string,
|
|
roleKeysList: string[],
|
|
): Promise<UserGrant> {
|
|
const req = new UserGrantCreate();
|
|
req.setProjectId(projectId);
|
|
req.setRoleKeysList(roleKeysList);
|
|
req.setUserId(userId);
|
|
|
|
return await this.request(
|
|
c => c.createProjectUserGrant,
|
|
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);
|
|
return await this.request(
|
|
c => c.updateApplicationOIDCConfig,
|
|
req,
|
|
f => f,
|
|
);
|
|
}
|
|
}
|