Skip to content

Commit

Permalink
Fix panic when creating batch tokens for role that doesn't exist. (#8027
Browse files Browse the repository at this point in the history
)
  • Loading branch information
ncabatoff authored Dec 16, 2019
1 parent b8c8e39 commit 59285da
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions vault/token_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -1639,11 +1639,21 @@ func (ts *TokenStore) revokeTreeInternal(ctx context.Context, id string) error {
}

func (c *Core) IsBatchTokenCreationRequest(ctx context.Context, path string) (bool, error) {
c.stateLock.RLock()
defer c.stateLock.RUnlock()

if c.tokenStore == nil {
return false, fmt.Errorf("no token store")
}

name := strings.TrimPrefix(path, "auth/token/create/")
roleEntry, err := c.tokenStore.tokenStoreRole(ctx, name)
if err != nil {
return false, err
}
if roleEntry == nil {
return false, fmt.Errorf("unknown role")
}
return roleEntry.TokenType == logical.TokenTypeBatch, nil
}

Expand Down

0 comments on commit 59285da

Please sign in to comment.