Skip to content

Commit

Permalink
fix: sysadmin can override policy violation check
Browse files Browse the repository at this point in the history
  • Loading branch information
Qiu Jian committed Apr 29, 2020
1 parent 4d1b93e commit b1647e7
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/keystone/models/policies.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ func (manager *SPolicyManager) FetchEnabledPolicies() ([]SPolicy, error) {
}

func validatePolicyVioldatePrivilege(userCred mcclient.TokenCredential, policy *rbacutils.SRbacPolicy) error {
if userCred.GetUserName() == api.SystemAdminUser && userCred.GetDomainId() == api.DEFAULT_DOMAIN_ID {
return nil
}
opsScope, opsPolicySet := policyman.PolicyManager.GetMatchedPolicySet(userCred)
if opsScope != rbacutils.ScopeSystem && policy.Scope.HigherThan(opsScope) {
return errors.Wrapf(httperrors.ErrNotSufficientPrivilege, "cannot create policy scope higher than %s", opsScope)
Expand Down

0 comments on commit b1647e7

Please sign in to comment.