Skip to content

Commit

Permalink
acl: do not check EACL for system role (#3015)
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-khimov authored Nov 14, 2024
2 parents ba1d639 + 08aefce commit 45802c6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ attribute, which is used for container domain name in NNS contracts (#2954)
- Pprof and metrics services stop at the end of SN's application lifecycle (#2976)
- Reject configuration with unknown fields (#2981)
- Log sampling is disabled by default now (#3011)
- EACL is no longer considered for system role (#2972)

### Removed
- Support for node.key configuration (#2959)
Expand Down
28 changes: 16 additions & 12 deletions pkg/services/object/acl/acl.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,22 @@ func (c *Checker) CheckEACL(msg any, reqInfo v2.RequestInfo) error {
return nil
}

var eaclRole eaclSDK.Role
switch op := reqInfo.RequestRole(); op {
default:
eaclRole = eaclSDK.Role(op)
case acl.RoleOwner:
eaclRole = eaclSDK.RoleUser
case acl.RoleInnerRing, acl.RoleContainer:
eaclRole = eaclSDK.RoleSystem
case acl.RoleOthers:
eaclRole = eaclSDK.RoleOthers
}

if eaclRole == eaclSDK.RoleSystem {
return nil // Controlled by BasicACL, EACL can not contain any rules for system role since 0.38.0.
}

// if bearer token is not allowed, then ignore it
if !basicACL.AllowedBearerRules(reqInfo.Operation()) {
reqInfo.CleanBearer()
Expand Down Expand Up @@ -182,18 +198,6 @@ func (c *Checker) CheckEACL(msg any, reqInfo v2.RequestInfo) error {
return fmt.Errorf("can't parse headers: %w", err)
}

var eaclRole eaclSDK.Role
switch op := reqInfo.RequestRole(); op {
default:
eaclRole = eaclSDK.Role(op)
case acl.RoleOwner:
eaclRole = eaclSDK.RoleUser
case acl.RoleInnerRing, acl.RoleContainer:
eaclRole = eaclSDK.RoleSystem
case acl.RoleOthers:
eaclRole = eaclSDK.RoleOthers
}

vu := new(eaclSDK.ValidationUnit).
WithRole(eaclRole).
WithOperation(eaclSDK.Operation(reqInfo.Operation())).
Expand Down

0 comments on commit 45802c6

Please sign in to comment.