mirror of
https://github.com/andwati/zitadel.git
synced 2026-10-31 03:22:15 +00:00
fix: query side (#257)
* fix: project by id return projectview * fix: return always view model on query side * fix: return always view model on query side
This commit is contained in:
@@ -14,12 +14,12 @@ func (s *Server) SearchApplications(ctx context.Context, in *ApplicationSearchRe
|
||||
return applicationSearchResponseFromModel(response), nil
|
||||
}
|
||||
|
||||
func (s *Server) ApplicationByID(ctx context.Context, in *ApplicationID) (*Application, error) {
|
||||
app, err := s.project.ApplicationByID(ctx, in.ProjectId, in.Id)
|
||||
func (s *Server) ApplicationByID(ctx context.Context, in *ApplicationID) (*ApplicationView, error) {
|
||||
app, err := s.project.ApplicationByID(ctx, in.Id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return appFromModel(app), nil
|
||||
return applicationViewFromModel(app), nil
|
||||
}
|
||||
|
||||
func (s *Server) CreateOIDCApplication(ctx context.Context, in *OIDCApplicationCreate) (*Application, error) {
|
||||
|
||||
+3493
-3372
File diff suppressed because it is too large
Load Diff
@@ -53,7 +53,7 @@
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/v1Org"
|
||||
"$ref": "#/definitions/v1OrgView"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -450,7 +450,7 @@
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/v1Org"
|
||||
"$ref": "#/definitions/v1OrgView"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -914,7 +914,7 @@
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/v1UserGrant"
|
||||
"$ref": "#/definitions/v1UserGrantView"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -1167,7 +1167,7 @@
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/v1Project"
|
||||
"$ref": "#/definitions/v1ProjectView"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -1673,7 +1673,7 @@
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/v1Application"
|
||||
"$ref": "#/definitions/v1ApplicationView"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -2100,7 +2100,7 @@
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/v1ProjectGrant"
|
||||
"$ref": "#/definitions/v1ProjectGrantView"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -2438,7 +2438,7 @@
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/v1UserGrant"
|
||||
"$ref": "#/definitions/v1UserGrantView"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -3405,7 +3405,7 @@
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/v1UserGrant"
|
||||
"$ref": "#/definitions/v1UserGrantView"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -4656,6 +4656,32 @@
|
||||
],
|
||||
"default": "ORGSTATE_UNSPECIFIED"
|
||||
},
|
||||
"v1OrgView": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"state": {
|
||||
"$ref": "#/definitions/v1OrgState"
|
||||
},
|
||||
"creation_date": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"change_date": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"sequence": {
|
||||
"type": "string",
|
||||
"format": "uint64"
|
||||
}
|
||||
}
|
||||
},
|
||||
"v1PasswordAgePolicy": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
||||
@@ -5,20 +5,20 @@ import (
|
||||
"github.com/golang/protobuf/ptypes/empty"
|
||||
)
|
||||
|
||||
func (s *Server) GetOrgByID(ctx context.Context, orgID *OrgID) (*Org, error) {
|
||||
func (s *Server) GetOrgByID(ctx context.Context, orgID *OrgID) (*OrgView, error) {
|
||||
org, err := s.org.OrgByID(ctx, orgID.Id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return orgFromModel(org), nil
|
||||
return orgViewFromModel(org), nil
|
||||
}
|
||||
|
||||
func (s *Server) GetOrgByDomainGlobal(ctx context.Context, in *OrgDomain) (*Org, error) {
|
||||
func (s *Server) GetOrgByDomainGlobal(ctx context.Context, in *OrgDomain) (*OrgView, error) {
|
||||
org, err := s.org.OrgByDomainGlobal(ctx, in.Domain)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return orgFromModel(org), nil
|
||||
return orgViewFromModel(org), nil
|
||||
}
|
||||
|
||||
func (s *Server) DeactivateOrg(ctx context.Context, in *OrgID) (*Org, error) {
|
||||
|
||||
@@ -34,14 +34,14 @@ func orgFromModel(org *org_model.Org) *Org {
|
||||
}
|
||||
}
|
||||
|
||||
func orgFromView(org *org_model.OrgView) *Org {
|
||||
func orgViewFromModel(org *org_model.OrgView) *OrgView {
|
||||
creationDate, err := ptypes.TimestampProto(org.CreationDate)
|
||||
logging.Log("GRPC-GTHsZ").OnError(err).Debug("unable to get timestamp from time")
|
||||
|
||||
changeDate, err := ptypes.TimestampProto(org.ChangeDate)
|
||||
logging.Log("GRPC-dVnoj").OnError(err).Debug("unable to get timestamp from time")
|
||||
|
||||
return &Org{
|
||||
return &OrgView{
|
||||
ChangeDate: changeDate,
|
||||
CreationDate: creationDate,
|
||||
Id: org.ID,
|
||||
|
||||
@@ -48,12 +48,12 @@ func (s *Server) SearchProjects(ctx context.Context, in *ProjectSearchRequest) (
|
||||
return projectSearchResponseFromModel(response), nil
|
||||
}
|
||||
|
||||
func (s *Server) ProjectByID(ctx context.Context, id *ProjectID) (*Project, error) {
|
||||
func (s *Server) ProjectByID(ctx context.Context, id *ProjectID) (*ProjectView, error) {
|
||||
project, err := s.project.ProjectByID(ctx, id.Id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return projectFromModel(project), nil
|
||||
return projectViewFromModel(project), nil
|
||||
}
|
||||
|
||||
func (s *Server) SearchGrantedProjects(ctx context.Context, in *GrantedProjectSearchRequest) (*ProjectGrantSearchResponse, error) {
|
||||
|
||||
@@ -20,12 +20,12 @@ func (s *Server) SearchProjectGrants(ctx context.Context, in *ProjectGrantSearch
|
||||
return projectGrantSearchResponseFromModel(response), nil
|
||||
}
|
||||
|
||||
func (s *Server) ProjectGrantByID(ctx context.Context, in *ProjectGrantID) (*ProjectGrant, error) {
|
||||
grant, err := s.project.ProjectGrantByID(ctx, in.ProjectId, in.Id)
|
||||
func (s *Server) ProjectGrantByID(ctx context.Context, in *ProjectGrantID) (*ProjectGrantView, error) {
|
||||
grant, err := s.project.ProjectGrantByID(ctx, in.Id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return projectGrantFromModel(grant), nil
|
||||
return projectGrantFromGrantedProjectModel(grant), nil
|
||||
}
|
||||
|
||||
func (s *Server) CreateProjectGrant(ctx context.Context, in *ProjectGrantCreate) (*ProjectGrant, error) {
|
||||
|
||||
@@ -17,12 +17,12 @@ func (s *Server) SearchUserGrants(ctx context.Context, in *UserGrantSearchReques
|
||||
return userGrantSearchResponseFromModel(response), nil
|
||||
}
|
||||
|
||||
func (s *Server) UserGrantByID(ctx context.Context, request *UserGrantID) (*UserGrant, error) {
|
||||
func (s *Server) UserGrantByID(ctx context.Context, request *UserGrantID) (*UserGrantView, error) {
|
||||
user, err := s.usergrant.UserGrantByID(ctx, request.Id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return usergrantFromModel(user), nil
|
||||
return userGrantViewFromModel(user), nil
|
||||
}
|
||||
|
||||
func (s *Server) CreateUserGrant(ctx context.Context, in *UserGrantCreate) (*UserGrant, error) {
|
||||
@@ -79,12 +79,12 @@ func (s *Server) SearchProjectUserGrants(ctx context.Context, request *ProjectUs
|
||||
return nil, errors.ThrowUnimplemented(nil, "GRPC-8jdSw", "Not implemented")
|
||||
}
|
||||
|
||||
func (s *Server) ProjectUserGrantByID(ctx context.Context, request *ProjectUserGrantID) (*UserGrant, error) {
|
||||
func (s *Server) ProjectUserGrantByID(ctx context.Context, request *ProjectUserGrantID) (*UserGrantView, error) {
|
||||
user, err := s.usergrant.UserGrantByID(ctx, request.Id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return usergrantFromModel(user), nil
|
||||
return userGrantViewFromModel(user), nil
|
||||
}
|
||||
|
||||
func (s *Server) CreateProjectUserGrant(ctx context.Context, in *UserGrantCreate) (*UserGrant, error) {
|
||||
@@ -122,12 +122,12 @@ func (s *Server) SearchProjectGrantUserGrants(ctx context.Context, request *Proj
|
||||
return nil, errors.ThrowUnimplemented(nil, "GRPC-32sFs", "Not implemented")
|
||||
}
|
||||
|
||||
func (s *Server) ProjectGrantUserGrantByID(ctx context.Context, request *ProjectGrantUserGrantID) (*UserGrant, error) {
|
||||
func (s *Server) ProjectGrantUserGrantByID(ctx context.Context, request *ProjectGrantUserGrantID) (*UserGrantView, error) {
|
||||
user, err := s.usergrant.UserGrantByID(ctx, request.Id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return usergrantFromModel(user), nil
|
||||
return userGrantViewFromModel(user), nil
|
||||
}
|
||||
|
||||
func (s *Server) CreateProjectGrantUserGrant(ctx context.Context, in *ProjectGrantUserGrantCreate) (*UserGrant, error) {
|
||||
|
||||
@@ -485,7 +485,7 @@ service ManagementService {
|
||||
}
|
||||
|
||||
//ORG
|
||||
rpc GetOrgByID(OrgID) returns (Org) {
|
||||
rpc GetOrgByID(OrgID) returns (OrgView) {
|
||||
option (google.api.http) = {
|
||||
get: "/orgs/{id}"
|
||||
};
|
||||
@@ -495,7 +495,7 @@ service ManagementService {
|
||||
};
|
||||
}
|
||||
|
||||
rpc GetOrgByDomainGlobal(OrgDomain) returns (Org) {
|
||||
rpc GetOrgByDomainGlobal(OrgDomain) returns (OrgView) {
|
||||
option (google.api.http) = {
|
||||
get: "/global/orgs/domain/{domain}"
|
||||
};
|
||||
@@ -527,7 +527,6 @@ service ManagementService {
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
rpc SearchMyOrgDomains(OrgDomainSearchRequest) returns (OrgDomainSearchResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/orgs/me/domains/_search"
|
||||
@@ -637,7 +636,7 @@ service ManagementService {
|
||||
};
|
||||
}
|
||||
|
||||
rpc ProjectByID(ProjectID) returns (Project) {
|
||||
rpc ProjectByID(ProjectID) returns (ProjectView) {
|
||||
option (google.api.http) = {
|
||||
get: "/projects/{id}"
|
||||
};
|
||||
@@ -850,7 +849,7 @@ service ManagementService {
|
||||
};
|
||||
}
|
||||
|
||||
rpc ApplicationByID(ApplicationID) returns (Application) {
|
||||
rpc ApplicationByID(ApplicationID) returns (ApplicationView) {
|
||||
option (google.api.http) = {
|
||||
get: "/projects/{project_id}/applications/{id}"
|
||||
};
|
||||
@@ -957,7 +956,7 @@ service ManagementService {
|
||||
};
|
||||
}
|
||||
|
||||
rpc ProjectGrantByID(ProjectGrantID) returns (ProjectGrant) {
|
||||
rpc ProjectGrantByID(ProjectGrantID) returns (ProjectGrantView) {
|
||||
option (google.api.http) = {
|
||||
get: "/projects/{project_id}/grants/{id}"
|
||||
};
|
||||
@@ -1086,7 +1085,7 @@ service ManagementService {
|
||||
};
|
||||
}
|
||||
|
||||
rpc UserGrantByID(UserGrantID) returns (UserGrant) {
|
||||
rpc UserGrantByID(UserGrantID) returns (UserGrantView) {
|
||||
option (google.api.http) = {
|
||||
get: "/users/{user_id}/grants/{id}"
|
||||
};
|
||||
@@ -1196,7 +1195,7 @@ service ManagementService {
|
||||
};
|
||||
}
|
||||
|
||||
rpc ProjectUserGrantByID(ProjectUserGrantID) returns (UserGrant) {
|
||||
rpc ProjectUserGrantByID(ProjectUserGrantID) returns (UserGrantView) {
|
||||
option (google.api.http) = {
|
||||
get: "/projects/{project_id}/users/{user_id}/grants/{id}"
|
||||
};
|
||||
@@ -1267,7 +1266,7 @@ service ManagementService {
|
||||
};
|
||||
}
|
||||
|
||||
rpc ProjectGrantUserGrantByID(ProjectGrantUserGrantID) returns (UserGrant) {
|
||||
rpc ProjectGrantUserGrantByID(ProjectGrantUserGrantID) returns (UserGrantView) {
|
||||
option (google.api.http) = {
|
||||
get: "/projectgrants/{project_grant_id}/users/{user_id}/grants/{id}"
|
||||
};
|
||||
@@ -1812,6 +1811,15 @@ message Org {
|
||||
uint64 sequence = 6;
|
||||
}
|
||||
|
||||
message OrgView {
|
||||
string id = 1;
|
||||
OrgState state = 2;
|
||||
google.protobuf.Timestamp creation_date = 3;
|
||||
google.protobuf.Timestamp change_date = 4;
|
||||
string name = 5;
|
||||
uint64 sequence = 6;
|
||||
}
|
||||
|
||||
enum OrgState {
|
||||
ORGSTATE_UNSPECIFIED = 0;
|
||||
ORGSTATE_ACTIVE = 1;
|
||||
|
||||
Reference in New Issue
Block a user