Skip to content

Commit

Permalink
Refactor the ACL Bootstrap token code
Browse files Browse the repository at this point in the history
Removed unnecessary structs.
Refactored the SetHeaders code to use just one secret.
Removed parseACLSectrets function as redundant
Removed the ACLSecrets Struct
  • Loading branch information
lhaig committed May 16, 2022
1 parent 74affa6 commit a35ad9c
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 26 deletions.
22 changes: 0 additions & 22 deletions command/agent/acl_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,25 +319,3 @@ func (s *HTTPServer) ExchangeOneTimeToken(resp http.ResponseWriter, req *http.Re
setIndex(resp, out.Index)
return out, nil
}

// parseACLSecrets extracts a map of k/v pairs from the ACL secrets
// header. Silently ignores invalid secrets
func parseACLSecrets(req *http.Request) structs.ACLSecrets {
secretsHeader := req.Header.Get("X-Nomad-Bootstrap-Token")
if secretsHeader == "" {
return nil
}

secrets := map[string]string{}
secretkvs := strings.Split(secretsHeader, ",")
for _, secretkv := range secretkvs {
kv := strings.Split(secretkv, "=")
if len(kv) == 2 {
secrets[kv[0]] = kv[1]
}
}
if len(secrets) == 0 {
return nil
}
return structs.ACLSecrets(secrets)
}
4 changes: 0 additions & 4 deletions nomad/structs/acl.go

This file was deleted.

0 comments on commit a35ad9c

Please sign in to comment.