-
-
Notifications
You must be signed in to change notification settings - Fork 795
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
token_expires_in method of oauthlib.Server is ignored by DOT #483
Comments
Yeah, if you asked my opinion, that whole method is reimplementing too much of the logic that's already in oauthlib's create_token. I'd rewrite it if I had some free time. |
It should probably start with passing I'm not sure about the best way of allowing Now, if we are hacking the places where we call that Server constructor (namely Now, after doing these preliminary changes we could try to simply the The rest of the method looks way too long and complicated for something so simple in essence: all it does is saving passed token dictionary to the db. I'm also not entirely sure about all the logic there: when refresh token rotation is disabled it seems to overwrite current access token instance rather than create a new on (which I'd think is more natural or at least is much closer to rotated flow), but more importantly I don't like that rotated vs. non-rotated flows have different side effects and make revocation logic even less clear. I guess part of the reason for weird stuff could be one to one fields being used for refresh/access token relations but sure there are other ways. It would be additionally nice if the save method started returning token instances (and possibly some additional values signalling whether either instance was just created, reused, or simply retrieved) -- those are the method's actual results and subclasses could do more things easier if they could access it directly. The return value is ignored by oauthlib so it wouldn't be a problem. |
My project has a requirement to set the token expiration per some auth cookie validity (means the token expiration is not static, but variable per token been issued. The token expiration is result of some method instead of static oauth2_settings.ACCESS_TOKEN_EXPIRE_SECONDS).
The oauthlib Server init function accepts both static value or callable function as an input:
The oauthlib tokens.py BearerToken class has its own default expiration value set: self.expires_in = expires_in or 3600
Unfortunately token_expires_in is ignored by DOT. The token expiration seems to be hardcoded into the save_bearer_token in oauth2_validators.py.
and
I think that better implementation would be to explicitly pass the oauth2_settings.ACCESS_TOKEN_EXPIRE_SECONDS as token_expires_in value and respect token['expires_in'] in save_bearer_token().
The text was updated successfully, but these errors were encountered: