mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
auth: add client-only ACL (#18730)
The RPC handlers expect to see `nil` ACL objects whenever ACLs are disabled. By using `nil` as a sentinel value, we have the risk of nil pointer exceptions and improper handling of `nil` when returned from our various auth methods that can lead to privilege escalation bugs. This is the third in a series to eliminate the use of `nil` ACLs as a sentinel value for when ACLs are disabled. This patch involves creating a new "virtual" ACL object for checking permissions on client operations and a matching `AuthenticateClientOnly` method for client-only RPCs that can produce that ACL. Unlike the server ACLs PR, this also includes a special case for "legacy" client RPCs where the client was not previously sending the secret as it should (leaning on mTLS only). Those client RPCs were fixed in Nomad 1.6.0, but it'll take a while before we can guarantee they'll be present during upgrades. Ref: https://github.com/hashicorp/nomad-enterprise/pull/1218 Ref: https://github.com/hashicorp/nomad/pull/18703 Ref: https://github.com/hashicorp/nomad/pull/18715 Ref: https://github.com/hashicorp/nomad/pull/16799
This commit is contained in:
@@ -40,17 +40,38 @@ rules:
|
||||
}
|
||||
...
|
||||
|
||||
# Pattern used by endpoints that are used by both ACLs and Clients.
|
||||
# These endpoints will always have a ctx passed to Authenticate
|
||||
|
||||
# Pattern used by endpoints that are used only for client-to-server.
|
||||
# Authorization can be done after forwarding, but must check the
|
||||
# AllowClientOp policy
|
||||
- pattern-not-inside: |
|
||||
authErr := $A.$B.Authenticate($A.ctx, args)
|
||||
aclObj, err := $A.$B.AuthenticateClientOnly($A.ctx, args)
|
||||
...
|
||||
if done, err := $A.$B.forward($METHOD, ...); done {
|
||||
return err
|
||||
}
|
||||
...
|
||||
... := $A.$B.ResolveClientOrACL(...)
|
||||
if !aclObj.AllowClientOp() {
|
||||
return structs.ErrPermissionDenied
|
||||
}
|
||||
...
|
||||
|
||||
|
||||
# Pattern used by endpoints that are used only for client-to-server.
|
||||
# Authorization can be done after forwarding, but must check the
|
||||
# AllowClientOp policy. This should not be added to any new endpoints.
|
||||
- pattern-not-inside: |
|
||||
aclObj, err := $A.$B.AuthenticateClientOnlyLegacy($A.ctx, args)
|
||||
...
|
||||
if done, err := $A.$B.forward($METHOD, ...); done {
|
||||
return err
|
||||
}
|
||||
...
|
||||
if !aclObj.AllowClientOp() {
|
||||
return structs.ErrPermissionDenied
|
||||
}
|
||||
...
|
||||
|
||||
# Pattern used by ACL endpoints that need to interact with the token directly
|
||||
- pattern-not-inside: |
|
||||
authErr := $A.$B.Authenticate($A.ctx, args)
|
||||
|
||||
Reference in New Issue
Block a user