Skip to content

Commit

Permalink
eventstream: Handle missing policy documents in event streams (#15495) (
Browse files Browse the repository at this point in the history
#16177)

Fixes #15493

Co-authored-by: Will Nicholson <[email protected]>
  • Loading branch information
hc-github-team-nomad-core and wjnicholson authored Feb 14, 2023
1 parent 38e4dc7 commit b1957db
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .changelog/15495.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
event stream: Fixed a bug where undefined ACL policies on the request's ACL would result in incorrect authentication errors
```
7 changes: 6 additions & 1 deletion nomad/stream/event_broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,14 @@ func aclObjFromSnapshotForTokenSecretID(aclSnapshot ACLTokenProvider, aclCache *
aclPolicies := make([]*structs.ACLPolicy, 0, len(aclToken.Policies))
for _, policyName := range aclToken.Policies {
policy, err := aclSnapshot.ACLPolicyByName(nil, policyName)
if err != nil || policy == nil {
if err != nil {
return nil, errors.New("error finding acl policy")
}
if policy == nil {
// Ignore policies that don't exist, since they don't grant any
// more privilege.
continue
}
aclPolicies = append(aclPolicies, policy)
}

Expand Down

0 comments on commit b1957db

Please sign in to comment.