fix: record API key revoker via created_by_id on revoke#4912
Draft
joybytes wants to merge 1 commit into
Draft
Conversation
644d9a1 to
e19d31b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Changes on this PR
We never recorded who revoked a key, so in this PR we're just propagating that information to the database. We are doing this by following the existing pattern of storing that information on
created_by_idfield.Note: older historical revoke events will show the wrong user (the key creator), because we did not store the revoker separately in the past. This change fixes that for new revokes going forward, but it cannot retroactively fix old row.
A bit of context on how the tables for
api_keysandapi_keys_historywork:We store API keys in two places:
So when a key is revoked:
On admin, audit events are built from the API’s history data (api_key_history), not from the live api_keys row.
So if you want to know what happened over time, look at history; if you want the current state now, look at api_keys.
https://trello.com/c/BwLKBEc4/645-api-key-history-shows-incorrect-data
TODO: