You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[oauth2_provider] Hash access and refresh tokens (ansible#641)
Previously, OAuth2 Access tokens including PATs were not hashed or
encrypted in any way, and were stored in plaintext in the database.
Seeing them required direct database access, but it is still better to
hash them, since they are long-lived.
This commit implements hashing (using sha256) of access tokens. Hashing
is unsalted, as we need to be able to key on a stable input - but also
because the tokens are already random strings and a salt adds nothing
more of security.
The input bearer token (used to auth a user) is hashed in
LoggedOAuth2Authentication and stuffed back into the request. This might
seem like a weird place to inject the hash, but it avoids having to
override any DOT internals.
The serializer has been updated to account for the new functionality and
still works the same way as in the past: On POST (new token creation),
the token will be displayed -- after that it will not.
Test fixtures and tests have been updated as well.
---------
Signed-off-by: Rick Elrod <[email protected]>
0 commit comments