-
-
Notifications
You must be signed in to change notification settings - Fork 31.1k
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
Track refresh token last usage information #16408
Track refresh token last usage information #16408
Conversation
homeassistant/auth/__init__.py
Outdated
@@ -277,8 +277,11 @@ def get_auth_mfa_module(self, module_id: str) \ | |||
|
|||
@callback | |||
def async_create_access_token(self, | |||
refresh_token: models.RefreshToken) -> str: | |||
refresh_token: models.RefreshToken, | |||
used_by: Optional[str] = None) -> str: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we rename last_used_by
to last_used_ip
just so it's more descriptive
homeassistant/auth/auth_store.py
Outdated
@@ -224,7 +236,10 @@ def __init__(self, hass: HomeAssistant) -> None: | |||
access_token_expiration=timedelta( | |||
seconds=rt_dict['access_token_expiration']), | |||
token=rt_dict['token'], | |||
jwt_key=rt_dict['jwt_key'] | |||
jwt_key=rt_dict['jwt_key'], | |||
last_used_at=dt_util.parse_datetime(last_used_at_str) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a fan of inline if-statements that wrap two lines.
cdf3f7f
to
a63a6eb
Compare
homeassistant/auth/auth_store.py
Outdated
@@ -1,6 +1,6 @@ | |||
"""Storage for auth models.""" | |||
from collections import OrderedDict | |||
from datetime import timedelta | |||
from datetime import timedelta, datetime |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'datetime.datetime' imported but unused
a63a6eb
to
a96326b
Compare
I forgot about this PR 😨 |
a96326b
to
f097fab
Compare
* Extend refresh_token to support last_used_at and last_used_by * Address code review comment * Remove unused code * Add it to websocket response * Fix typing
Description:
Add
last_used_at
(datetime) andlast_used_by
(IP address string) fields torefresh_token
Related issue (if applicable): fixes #15196
Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.github.io#<home-assistant.github.io PR number goes here>
Example entry for
configuration.yaml
(if applicable):Checklist:
tox
. Your PR cannot be merged unless tests passIf user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
REQUIREMENTS
variable (example).requirements_all.txt
by runningscript/gen_requirements_all.py
..coveragerc
.If the code does not interact with devices: