mirror of
https://github.com/andwati/zitadel.git
synced 2026-12-03 17:38:51 +00:00
Merge commit from fork
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
|||||||
"github.com/zitadel/zitadel/internal/eventstore"
|
"github.com/zitadel/zitadel/internal/eventstore"
|
||||||
"github.com/zitadel/zitadel/internal/query"
|
"github.com/zitadel/zitadel/internal/query"
|
||||||
"github.com/zitadel/zitadel/internal/repository/project"
|
"github.com/zitadel/zitadel/internal/repository/project"
|
||||||
|
"github.com/zitadel/zitadel/internal/zerrors"
|
||||||
mgmt_pb "github.com/zitadel/zitadel/pkg/grpc/management"
|
mgmt_pb "github.com/zitadel/zitadel/pkg/grpc/management"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -19,6 +20,9 @@ func (s *Server) GetProjectByID(ctx context.Context, req *mgmt_pb.GetProjectByID
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if project.ResourceOwner != authz.GetCtxData(ctx).OrgID {
|
||||||
|
return nil, zerrors.ThrowNotFound(nil, "MANAG-SFf2a", "Errors.Project.NotFound")
|
||||||
|
}
|
||||||
return &mgmt_pb.GetProjectByIDResponse{
|
return &mgmt_pb.GetProjectByIDResponse{
|
||||||
Project: project_grpc.ProjectViewToPb(project),
|
Project: project_grpc.ProjectViewToPb(project),
|
||||||
}, nil
|
}, nil
|
||||||
@@ -29,6 +33,9 @@ func (s *Server) GetGrantedProjectByID(ctx context.Context, req *mgmt_pb.GetGran
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if !(grant.ResourceOwner == authz.GetCtxData(ctx).OrgID || grant.GrantedOrgID == authz.GetCtxData(ctx).OrgID) {
|
||||||
|
return nil, zerrors.ThrowNotFound(nil, "MANAG-drt2a", "Errors.ProjectGrant.NotFound")
|
||||||
|
}
|
||||||
return &mgmt_pb.GetGrantedProjectByIDResponse{
|
return &mgmt_pb.GetGrantedProjectByIDResponse{
|
||||||
GrantedProject: project_grpc.GrantedProjectViewToPb(grant),
|
GrantedProject: project_grpc.GrantedProjectViewToPb(grant),
|
||||||
}, nil
|
}, nil
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import (
|
|||||||
"github.com/zitadel/zitadel/internal/eventstore"
|
"github.com/zitadel/zitadel/internal/eventstore"
|
||||||
"github.com/zitadel/zitadel/internal/query"
|
"github.com/zitadel/zitadel/internal/query"
|
||||||
"github.com/zitadel/zitadel/internal/repository/project"
|
"github.com/zitadel/zitadel/internal/repository/project"
|
||||||
|
"github.com/zitadel/zitadel/internal/zerrors"
|
||||||
mgmt_pb "github.com/zitadel/zitadel/pkg/grpc/management"
|
mgmt_pb "github.com/zitadel/zitadel/pkg/grpc/management"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -19,13 +20,16 @@ func (s *Server) GetAppByID(ctx context.Context, req *mgmt_pb.GetAppByIDRequest)
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if app.ResourceOwner != authz.GetCtxData(ctx).OrgID {
|
||||||
|
return nil, zerrors.ThrowNotFound(nil, "MANAG-SFf2a", "Errors.Project.App.NotFound")
|
||||||
|
}
|
||||||
return &mgmt_pb.GetAppByIDResponse{
|
return &mgmt_pb.GetAppByIDResponse{
|
||||||
App: project_grpc.AppToPb(app),
|
App: project_grpc.AppToPb(app),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) ListApps(ctx context.Context, req *mgmt_pb.ListAppsRequest) (*mgmt_pb.ListAppsResponse, error) {
|
func (s *Server) ListApps(ctx context.Context, req *mgmt_pb.ListAppsRequest) (*mgmt_pb.ListAppsResponse, error) {
|
||||||
queries, err := ListAppsRequestToModel(req)
|
queries, err := ListAppsRequestToModel(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import (
|
|||||||
mgmt_pb "github.com/zitadel/zitadel/pkg/grpc/management"
|
mgmt_pb "github.com/zitadel/zitadel/pkg/grpc/management"
|
||||||
)
|
)
|
||||||
|
|
||||||
func ListAppsRequestToModel(req *mgmt_pb.ListAppsRequest) (*query.AppSearchQueries, error) {
|
func ListAppsRequestToModel(ctx context.Context, req *mgmt_pb.ListAppsRequest) (*query.AppSearchQueries, error) {
|
||||||
offset, limit, asc := object.ListQueryToModel(req.Query)
|
offset, limit, asc := object.ListQueryToModel(req.Query)
|
||||||
queries, err := app_grpc.AppQueriesToModel(req.Queries)
|
queries, err := app_grpc.AppQueriesToModel(req.Queries)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -26,7 +26,11 @@ func ListAppsRequestToModel(req *mgmt_pb.ListAppsRequest) (*query.AppSearchQueri
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
queries = append(queries, projectQuery)
|
resourceOwner, err := query.NewAppResourceOwnerSearchQuery(authz.GetCtxData(ctx).OrgID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
queries = append(queries, projectQuery, resourceOwner)
|
||||||
return &query.AppSearchQueries{
|
return &query.AppSearchQueries{
|
||||||
SearchRequest: query.SearchRequest{
|
SearchRequest: query.SearchRequest{
|
||||||
Offset: offset,
|
Offset: offset,
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import (
|
|||||||
object_grpc "github.com/zitadel/zitadel/internal/api/grpc/object"
|
object_grpc "github.com/zitadel/zitadel/internal/api/grpc/object"
|
||||||
proj_grpc "github.com/zitadel/zitadel/internal/api/grpc/project"
|
proj_grpc "github.com/zitadel/zitadel/internal/api/grpc/project"
|
||||||
"github.com/zitadel/zitadel/internal/query"
|
"github.com/zitadel/zitadel/internal/query"
|
||||||
|
"github.com/zitadel/zitadel/internal/zerrors"
|
||||||
mgmt_pb "github.com/zitadel/zitadel/pkg/grpc/management"
|
mgmt_pb "github.com/zitadel/zitadel/pkg/grpc/management"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -17,6 +18,9 @@ func (s *Server) GetProjectGrantByID(ctx context.Context, req *mgmt_pb.GetProjec
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if !(grant.ResourceOwner == authz.GetCtxData(ctx).OrgID || grant.GrantedOrgID == authz.GetCtxData(ctx).OrgID) {
|
||||||
|
return nil, zerrors.ThrowNotFound(nil, "MANAG-d3g31", "Errors.ProjectGrant.NotFound")
|
||||||
|
}
|
||||||
return &mgmt_pb.GetProjectGrantByIDResponse{
|
return &mgmt_pb.GetProjectGrantByIDResponse{
|
||||||
ProjectGrant: proj_grpc.GrantedProjectViewToPb(grant),
|
ProjectGrant: proj_grpc.GrantedProjectViewToPb(grant),
|
||||||
}, nil
|
}, nil
|
||||||
|
|||||||
@@ -613,6 +613,10 @@ func (s *Server) ListHumanAuthFactors(ctx context.Context, req *mgmt_pb.ListHuma
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
err = query.AppendResourceOwnerQuery(authz.GetCtxData(ctx).OrgID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
authMethods, err := s.query.SearchUserAuthMethods(ctx, query, nil)
|
authMethods, err := s.query.SearchUserAuthMethods(ctx, query, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -676,6 +680,10 @@ func (s *Server) ListHumanPasswordless(ctx context.Context, req *mgmt_pb.ListHum
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
err = query.AppendResourceOwnerQuery(authz.GetCtxData(ctx).OrgID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
authMethods, err := s.query.SearchUserAuthMethods(ctx, query, nil)
|
authMethods, err := s.query.SearchUserAuthMethods(ctx, query, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@@ -682,6 +682,10 @@ func NewAppClientIDSearchQuery(clientID string) (SearchQuery, error) {
|
|||||||
return NewOrQuery(oidcClientIDQuery, apiClientIDQuery)
|
return NewOrQuery(oidcClientIDQuery, apiClientIDQuery)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewAppResourceOwnerSearchQuery(resourceOwner string) (SearchQuery, error) {
|
||||||
|
return NewTextQuery(AppColumnResourceOwner, resourceOwner, TextEquals)
|
||||||
|
}
|
||||||
|
|
||||||
func NewAppSAMLEntityIDSearchQuery(entityID string) (SearchQuery, error) {
|
func NewAppSAMLEntityIDSearchQuery(entityID string) (SearchQuery, error) {
|
||||||
return NewTextQuery(AppSAMLConfigColumnEntityID, entityID, TextEquals)
|
return NewTextQuery(AppSAMLConfigColumnEntityID, entityID, TextEquals)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user