mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 10:25:42 +03:00
helper: sanitize method on ACL token object (#24600)
There are several places where we want to redact the secret ID of an ACL token, some of which are in the Enterprise code base for Sentinel. Add a new method `Sanitize` that mirrors the one we have on `Node`. Ref: https://github.com/hashicorp/nomad-enterprise/pull/2087
This commit is contained in:
@@ -474,6 +474,16 @@ func (a *ACLToken) UnmarshalJSON(data []byte) (err error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *ACLToken) Sanitize() *ACLToken {
|
||||
if a == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
out := a.Copy()
|
||||
out.SecretID = ""
|
||||
return out
|
||||
}
|
||||
|
||||
// ACLRole is an abstraction for the ACL system which allows the grouping of
|
||||
// ACL policies into a single object. ACL tokens can be created and linked to
|
||||
// a role; the token then inherits all the permissions granted by the policies.
|
||||
|
||||
@@ -155,8 +155,7 @@ type ServiceRegistrationStreamEvent struct {
|
||||
// NewACLTokenEvent takes a token and creates a new ACLTokenEvent. It creates
|
||||
// a copy of the passed in ACLToken and empties out the copied tokens SecretID
|
||||
func NewACLTokenEvent(token *ACLToken) *ACLTokenEvent {
|
||||
c := token.Copy()
|
||||
c.SecretID = ""
|
||||
c := token.Sanitize()
|
||||
|
||||
return &ACLTokenEvent{
|
||||
ACLToken: c,
|
||||
|
||||
Reference in New Issue
Block a user