Skip to content

Commit

Permalink
Do not leak tokens in debug logs
Browse files Browse the repository at this point in the history
  • Loading branch information
Colin-b committed Jun 17, 2024
1 parent e184b7f commit 0fb60e4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Type information is now provided following [PEP 561](https://www.python.org/dev/peps/pep-0561/).
- Remove deprecation warnings due to usage of `utcnow` and `utcfromtimestamp`.
- Tokens cache `DEBUG` logs will not display tokens anymore.

### Removed
- Removing support for Python `3.7`.
Expand Down
4 changes: 2 additions & 2 deletions requests_auth/_oauth2/tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def _add_token(
self.tokens[key] = token, expiry, refresh_token
self._save_tokens()
logger.debug(
f'Inserting token expiring on {datetime.datetime.fromtimestamp(expiry, datetime.timezone.utc)} with "{key}" key: {token}'
f'Inserting token expiring on {datetime.datetime.fromtimestamp(expiry, datetime.timezone.utc)} with "{key}" key.'
)

def get_token(
Expand Down Expand Up @@ -184,7 +184,7 @@ def get_token(
return bearer

logger.debug(
f"User was not authenticated: key {key} cannot be found in {self.tokens}."
f"User was not authenticated: key {key} cannot be found in {list(self.tokens)}."
)
raise AuthenticationFailed()

Expand Down

0 comments on commit 0fb60e4

Please sign in to comment.