mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-19 10:46:58 +08:00
fix: sysadmin can override policy violation check
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user