-
Notifications
You must be signed in to change notification settings - Fork 19
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
Propose PR solving issues #97 and #98 #99
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
""" | ||
|
||
from collections import UserDict | ||
from typing import Any | ||
|
||
|
||
class HTTPHeaderDict(UserDict): | ||
|
@@ -33,8 +34,24 @@ class HTTPHeaderDict(UserDict): | |
d['hElLo'] == 'world' # >>> True | ||
""" | ||
|
||
def __init__(self, dict=None, /, **kwargs): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Positional-only parameters are supported starting from Python 3.8. I'm not sure whether we still need to support Python 3.7, but for now, I would stick to maintaining that compatibility. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That was mainly copied from original code from |
||
"""Object initialization.""" | ||
super().__init__(dict, **kwargs) | ||
self.data = {k.lower(): v for k, v in self.data.items()} | ||
|
||
def __setitem__(self, key: str, value: str): | ||
super().__setitem__(key.lower(), value) | ||
|
||
def __getitem__(self, key: str): | ||
return super().__getitem__(key.lower()) | ||
|
||
def __delitem__(self, key: str): | ||
"""Item deletion.""" | ||
return super().__delitem__(key.lower()) | ||
|
||
def get(self, key: str, default: Any = None): | ||
"""Case-insentive get.""" | ||
try: | ||
return self[key] | ||
except KeyError: | ||
return default |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,6 @@ | |
else: | ||
from typing_extensions import get_args | ||
|
||
from .utils import generate_token | ||
from .errors import ( | ||
InvalidClientError, | ||
InvalidRedirectURIError, | ||
|
@@ -33,6 +32,7 @@ | |
) | ||
from .storage import TStorage | ||
from .types import CodeChallengeMethod | ||
from .utils import generate_token | ||
|
||
|
||
class ResponseTypeBase(Generic[TRequest, TStorage]): | ||
|
@@ -115,12 +115,10 @@ async def create_authorization_response( | |
generate_token(48), | ||
) | ||
return TokenResponse( | ||
expires_in=token.expires_in, | ||
refresh_token_expires_in=token.refresh_token_expires_in, | ||
access_token=token.access_token, | ||
refresh_token=token.refresh_token, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I got a bit confused about removing the refresh_token from the response. How will the client get a refresh token if it needs to update the access_token? Auth0 uses the offline_access scope for this: https://auth0.com/docs/secure/tokens/refresh-tokens/get-refresh-tokens This document says that the response MAY contain a refresh_token: https://www.oauth.com/oauth2-servers/making-authenticated-requests/refreshing-an-access-token/ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another solution could be a feature flag. If it's enabled, the refresh token won't be returned in the response. This way, backward compatibility won't be broken, while still adhering to the behavior outlined in the RFC6749 standard. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, I see your point @aliev. However, this is something very specific of the Implicit Grant. Indeed, the RFC 6749 clearly mentions that this flow was not conceived for refresh tokens:
(source: RFC 6749, section "4.2 Implicit Grant") And also here:
Regarding this Auth0 link you paste before, the blog is very generic explanation about refresh token, so I guess they didn't really mean it in a concrete context like Implicit Grant. I think this may be why. In any case, your proposal here:
looks quite fine to me so that it leaves the decision to the implementer to be fully compliant or not! Thanks again @aliev !!! Cheers PS: by the way, sorry for the long time I took in replying you, but your know, I was off in my summer break :P There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @PrieJos ! Shall we try to deliver this MR as well? As I mentioned, the safest way would be to implement a feature flag disabled by default. You could add it, for example, in the Settings: https://github.com/aliev/aioauth/blob/master/aioauth/config.py#L15 We should also remove the changes related to HTTPHeaderDict from this PR, as they are already in the master branch. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @aliev Sorry for the long time to reply. I totally oversee the notification. Sorry again. Yes, that would be great. I will take a look and come out with a suggestion so that you can review it. Cheers, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @PrieJos No worries, thank you for your contribution again! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
scope=token.scope, | ||
token_type=token.token_type, | ||
expires_in=token.expires_in, | ||
scope=token.scope, | ||
) | ||
|
||
|
||
|
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.
To "solidify" these changes, I would create a test file for collections.py (e.g., test_collections.py) with tests like these: