Skip to content

Commit af7b706

Browse files
author
OpenShift Bot
committed
Merge pull request #3658 from deads2k/return-api-error
Merged by openshift-bot
2 parents 89e9f72 + bbc6b45 commit af7b706

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

pkg/authorization/registry/rolebinding/policybased/virtual_storage.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -257,12 +257,12 @@ func (m *VirtualStorage) confirmNoEscalation(ctx kapi.Context, roleBinding *auth
257257
)
258258
ownerLocalRules, err := ruleResolver.GetEffectivePolicyRules(ctx)
259259
if err != nil {
260-
return err
260+
return kapierrors.NewInternalError(err)
261261
}
262262
masterContext := kapi.WithNamespace(ctx, "")
263263
ownerGlobalRules, err := ruleResolver.GetEffectivePolicyRules(masterContext)
264264
if err != nil {
265-
return err
265+
return kapierrors.NewInternalError(err)
266266
}
267267

268268
ownerRules := make([]authorizationapi.PolicyRule, 0, len(ownerGlobalRules)+len(ownerLocalRules))
@@ -272,7 +272,7 @@ func (m *VirtualStorage) confirmNoEscalation(ctx kapi.Context, roleBinding *auth
272272
ownerRightsCover, missingRights := rulevalidation.Covers(ownerRules, modifyingRole.Rules)
273273
if !ownerRightsCover {
274274
user, _ := kapi.UserFrom(ctx)
275-
return fmt.Errorf("attempt to grant extra privileges: %v\nuser=%v\nownerrules%v\n", missingRights, user, ownerRules)
275+
return kapierrors.NewUnauthorized(fmt.Sprintf("attempt to grant extra privileges: %v user=%v ownerrules=%v", missingRights, user, ownerRules))
276276
}
277277

278278
return nil

0 commit comments

Comments
 (0)