mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-12 00:55:12 +00:00
feat(console): integrate frontend (#95)
* feat: console frontend * chore(dependabot): cycle and npm * chore: rename citadel to zitadel, remove generated files * chore: delete go files * chore(frontend): ci steps * chore: remove docker and envoy files * chore: remove docker file * chore: working dir * chore: run proto build * add console start * chore: restructure folders * chore: remove gui build * statikFs * generate proto for console * add statik import * import * chore: try statik * chore: path * chore: path * chore: script in root * chore: order build steps * chore: go get * chore: folder traversal * chore: non empty test file * chore: gitignore * chore: gitignore * chore: statik path * chore: switch to failing FE build * fix: build * fix: project-grant-test * fix: rm test * add statik.go * go mod tidy * chore: place test, seperate test from build * chore: lint all the world * chore: ci the world instead * chore: tune docker * chore: undo container test * chore: fix run * chore: docker build * chore: test docker build * chore: go build flags * finaly * fix caos_local * go mod Co-authored-by: Livio Amstutz <[email protected]> Co-authored-by: Max Peintner <[email protected]>
This commit is contained in:
co-authored by
Livio Amstutz
Max Peintner
parent
9e32740eb8
commit
92a294f5c8
@@ -0,0 +1,500 @@
|
||||
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,
|
||||
GrantedGrantID,
|
||||
OIDCApplicationCreate,
|
||||
OIDCConfig,
|
||||
OIDCConfigUpdate,
|
||||
Project,
|
||||
ProjectCreateRequest,
|
||||
ProjectGrant,
|
||||
ProjectGrantCreate,
|
||||
ProjectGrantID,
|
||||
ProjectGrantMemberAdd,
|
||||
ProjectGrantMemberRemove,
|
||||
ProjectGrantMemberRoles,
|
||||
ProjectGrantMemberSearchQuery,
|
||||
ProjectGrantMemberSearchRequest,
|
||||
ProjectGrantSearchRequest,
|
||||
ProjectGrantSearchResponse,
|
||||
ProjectID,
|
||||
ProjectMemberAdd,
|
||||
ProjectMemberChange,
|
||||
ProjectMemberRemove,
|
||||
ProjectMemberRoles,
|
||||
ProjectMemberSearchRequest,
|
||||
ProjectMemberSearchResponse,
|
||||
ProjectRoleAdd,
|
||||
ProjectRoleRemove,
|
||||
ProjectRoleSearchQuery,
|
||||
ProjectRoleSearchRequest,
|
||||
ProjectRoleSearchResponse,
|
||||
ProjectSearchQuery,
|
||||
ProjectSearchRequest,
|
||||
ProjectSearchResponse,
|
||||
ProjectUpdateRequest,
|
||||
ProjectUserGrantSearchRequest,
|
||||
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 GetProjectById(projectId: string): Promise<Project> {
|
||||
const req = new ProjectID();
|
||||
req.setId(projectId);
|
||||
return await this.request(
|
||||
c => c.projectByID,
|
||||
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(project: Project.AsObject): Promise<Project> {
|
||||
const req = new ProjectUpdateRequest();
|
||||
req.setName(project.name);
|
||||
req.setId(project.id);
|
||||
return await this.request(
|
||||
c => c.updateProject,
|
||||
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 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): Promise<any> {
|
||||
const req = new ApplicationID();
|
||||
req.setId(id);
|
||||
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);
|
||||
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,
|
||||
);
|
||||
}
|
||||
|
||||
// NEW
|
||||
public async GetGrantedProjectGrantByID(id: string): Promise<ProjectGrant> {
|
||||
const req = new GrantedGrantID();
|
||||
req.setId(id);
|
||||
return await this.request(
|
||||
c => c.getGrantedProjectGrantByID,
|
||||
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,
|
||||
);
|
||||
}
|
||||
|
||||
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,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user