Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set TokenParent in the Index to be cached #10833

Merged
merged 3 commits into from
Feb 4, 2021
Merged

Conversation

tvoran
Copy link
Member

@tvoran tvoran commented Feb 3, 2021

It seems like TokenParent should be set on the index about to be stored, instead of the entry that was looked up, so that when a token is revoked, it's possible to lookup all the child tokens when the parent is revoked:

// Clear the parent references of the revoked token in the entries
// belonging to the child tokens of the revoked token.
indexes, err = c.db.GetByPrefix(cachememdb.IndexNameTokenParent, token)
if err != nil {
return false, err
}
for _, index := range indexes {
index.TokenParent = ""
err = c.db.Set(index)
if err != nil {
c.logger.Error("failed to persist index", "error", err)
return false, err
}
}

Copy link
Member

@calvn calvn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice find!

command/agent/cache/lease_cache_test.go Outdated Show resolved Hide resolved
Co-authored-by: Calvin Leung Huang <cleung2010@gmail.com>
@vercel vercel bot temporarily deployed to Preview – vault-storybook February 4, 2021 00:21 Inactive
@vercel vercel bot temporarily deployed to Preview – vault February 4, 2021 00:21 Inactive
@vercel vercel bot temporarily deployed to Preview – vault February 4, 2021 01:34 Inactive
@vercel vercel bot temporarily deployed to Preview – vault-storybook February 4, 2021 01:34 Inactive
@tvoran tvoran merged commit 38a6f4c into master Feb 4, 2021
@tvoran tvoran deleted the fix-agent-tokenparent branch February 4, 2021 02:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants