Create indexing from Accessor ID to Token ID

This commit is contained in:
vishalnayak 2016-03-08 13:12:53 -05:00
parent 301776012f
commit c0fb69a8b1
1 changed files with 11 additions and 0 deletions

View File

@ -311,6 +311,17 @@ func (ts *TokenStore) createAccessorID(entry *TokenEntry) error {
return err
}
entry.AccessorID = accessorUUID
// Create salted token and accessor IDs
saltedTokenId := ts.SaltID(entry.ID)
saltedAccessorID := ts.SaltID(entry.AccessorID)
// Create index, mapping the Accessor ID to the Token ID
path := lookupPrefix + saltedTokenId + "/" + saltedAccessorID
le := &logical.StorageEntry{Key: path, Value: []byte(entry.ID)}
if err := ts.view.Put(le); err != nil {
return fmt.Errorf("failed to persist accessor index entry: %v", err)
}
return nil
}