Skip to content
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

Improved token expiration management #338

Open
leonid-s-usov opened this issue Dec 15, 2015 · 4 comments
Open

Improved token expiration management #338

leonid-s-usov opened this issue Dec 15, 2015 · 4 comments

Comments

@leonid-s-usov
Copy link

For some reason DOT decided against using the proper OAuthLib way of dealing with token timeouts, and instead overrides the timeout during store_bearer_token in the validator. This approach makes it really difficult to dynamically change the token timeout depending on the request.

More than that, it is also not the way OAuthLib suggests this should be done: the "proper" way is to either override the OAuthLib token class, or simply pass token_expires_in parameter to the Server constructor (which will eventually get to the BearerToken constructor). This parameter may be a callable taking request as a parameter and returning the expiration time in seconds.

I suggest that instead (well, in a backward compatible manner) of today's ACCESS_TOKEN_EXPIRE_SECONDS setting we add an ACCESS_TOKEN_EXPIRES_IN, which may either be a number of seconds or a function taking request and returning seconds. Internally, this value will simply be passed in the Server constructor in the OAuthLibMixin.get_server

Another good outcome is that it will allow getting rid of this bad pattern and a pending TODO

@synasius
Copy link
Contributor

Definitely something we need to address. can you provide a PR?

@leonid-s-usov
Copy link
Author

Well.. The reason I wrote such a detailed description was that most probably this week and the weekend I will not be able to find time for this. It no one else does it until I find some time I will be glad to provide a PR.

@jleclanche
Copy link
Member

See #368. This can be exposed at the same time.

@jleclanche jleclanche modified the milestones: 1.0, 0.11 Feb 17, 2017
@jleclanche
Copy link
Member

I have a patch in issue/338 (3f321b7), but it's not actually working and I don't know why: https://travis-ci.org/evonove/django-oauth-toolkit/jobs/202563178

Ideas? @leonid-s-usov ?

@jleclanche jleclanche modified the milestones: 1.0, 1.1 Jun 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants