Add ability to skip role creation on scope create (#308)
* Initial work on scope creation skipping * Fix things
This commit is contained in:
1 parent
e4da5e9ab5
commit
490be8a7e4
27 files changed
+962
-304
No files matched your search
@@ -106,7 +106,8 @@ func (s Service) CreateScope(ctx context.Context, req *pbs.CreateScopeRequest) (
|
||||
if err := validateCreateRequest(req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
p, err := s.createInRepo(ctx, authResults, req.GetItem())
|
||||
|
||||
p, err := s.createInRepo(ctx, authResults, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -162,7 +163,8 @@ func (s Service) getFromRepo(ctx context.Context, id string) (*pb.Scope, error)
|
||||
return ToProto(p), nil
|
||||
}
|
||||
|
||||
func (s Service) createInRepo(ctx context.Context, authResults auth.VerifyResults, item *pb.Scope) (*pb.Scope, error) {
|
||||
func (s Service) createInRepo(ctx context.Context, authResults auth.VerifyResults, req *pbs.CreateScopeRequest) (*pb.Scope, error) {
|
||||
item := req.GetItem()
|
||||
var opts []iam.Option
|
||||
if item.GetName() != nil {
|
||||
opts = append(opts, iam.WithName(item.GetName().GetValue()))
|
||||
@@ -170,6 +172,7 @@ func (s Service) createInRepo(ctx context.Context, authResults auth.VerifyResult
|
||||
if item.GetDescription() != nil {
|
||||
opts = append(opts, iam.WithDescription(item.GetDescription().GetValue()))
|
||||
}
|
||||
opts = append(opts, iam.WithSkipRoleCreation(req.GetSkipRoleCreation()))
|
||||
|
||||
parentScope := authResults.Scope
|
||||
var iamScope *iam.Scope
|
||||
@@ -187,7 +190,7 @@ func (s Service) createInRepo(ctx context.Context, authResults auth.VerifyResult
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out, err := repo.CreateScope(ctx, iamScope, authResults.UserId)
|
||||
out, err := repo.CreateScope(ctx, iamScope, authResults.UserId, opts...)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Unable to create scope: %v.", err)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user