Repository navigation
Conversation
…rrors * Clear the key cache on unlink and when a key is (un)archived, so a deleted or archived key stops working right away instead of when the cache happens to be cleared. * The error for an unknown key no longer contains the submitted key (it ended up in logs and error pages) and the message is translatable. * An unknown key now answers 401, like a missing one, instead of a user error, and the failure log reports the caller address.
Store only the SHA-256 of a key instead of the key itself, so that
reading the table, a backup or a restored dump does not give usable
keys. Keys are long random values: a fast hash is enough and the lookup
becomes an indexed search instead of a loop over all the keys.
* Enabled by default, optional ("Store API keys hashed" in the settings).
Enabling it also hashes the keys already stored.
* Keys stored in plain text keep working, so a database can be switched
progressively.
* The upgrade disables it on databases already having keys, as code
reading the keys would break.
* auth_api_key_server_env never hashes: the key comes from the
environment.
* The neutralization clears the hash too.
* Last use date of the key, shown in the keys list and updated at most once an hour with a plain SQL update to avoid a write on each request. * Search view with filters for the keys never used or not used for 10, 30 or 60 days, to find the keys that are not used anymore, and for the archived keys. * `_retrieve_uid_from_api_key` is no longer cached: it would bypass the checks other modules add to `_retrieve_api_key` that depend on time. The id lookup below it still is.
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.
Depends on/includes:
[18.0][FIX] auth_api_key: revoke keys immediately and do not leak them in errors #1086
*[18.0][IMP] auth_api_key: store keys hashed #1087
Last use date of the key, shown in the keys list and updated at most once an hour with a plain SQL update (no write on each request).
Search view with filters for the keys never used or not used for 10, 30 or 60 days, to find the keys that are not used anymore, and for the archived keys.
_retrieve_uid_from_api_keyis no longer cached: it would bypass the checks other modules add to_retrieve_api_keythat depend on time (see the expiration in the newauth_api_key_expire). The id lookup below it still is.