Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

acl: do not check EACL for system role #3015

Merged
merged 1 commit into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,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 @@
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

Check warning on line 141 in pkg/services/object/acl/acl.go

View check run for this annotation

Codecov / codecov/patch

pkg/services/object/acl/acl.go#L132-L141

Added lines #L132 - L141 were not covered by tests
}

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to make a separate condition for this, we already have the case

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also did not get it but maybe @roman-khimov has some thoughts on it

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That switch is so nice in its request role->acl role mapping that I didn't wont to interrupt the flow there. Can be changed at any time.

}

Check warning on line 146 in pkg/services/object/acl/acl.go

View check run for this annotation

Codecov / codecov/patch

pkg/services/object/acl/acl.go#L144-L146

Added lines #L144 - L146 were not covered by tests

// if bearer token is not allowed, then ignore it
if !basicACL.AllowedBearerRules(reqInfo.Operation()) {
reqInfo.CleanBearer()
Expand Down Expand Up @@ -182,18 +198,6 @@
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
Loading