Skip to content

Commit

Permalink
Handling nomad maxTokenNameLength = 64 (#4009)
Browse files Browse the repository at this point in the history
  • Loading branch information
burdandrei authored and jefferai committed Feb 20, 2018
1 parent 8aeba42 commit 8bb4bda
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions builtin/logical/nomad/path_creds_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ func (b *backend) pathTokenRead(ctx context.Context, req *logical.Request, d *fr
// Generate a name for the token
tokenName := fmt.Sprintf("vault-%s-%s-%d", name, req.DisplayName, time.Now().UnixNano())

// Handling nomad maximum token lenght
// https://github.com/hashicorp/nomad/blob/d9276e22b3b74674996fb548cdb6bc4c70d5b0e4/nomad/structs/structs.go#L115
if len(tokenName) > 64 {
tokenName = tokenName[0:63]
}

// Create it
token, _, err := c.ACLTokens().Create(&api.ACLToken{
Name: tokenName,
Expand Down

0 comments on commit 8bb4bda

Please sign in to comment.