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

Tokens with no maximum expiration time are not counted towards the maximum number of tokens allowed #280

Open
pablomm opened this issue Sep 7, 2022 · 0 comments · May be fixed by #318
Open

Comments

@pablomm
Copy link

pablomm commented Sep 7, 2022

Description
According to docs, setting the TOKEN_TTL to None will create tokens that never expire.

However, before token creation, when checking that the number active of tokens of a user < token_limit_per_user, tokens without expiry date (expiry=None) are not taken into account.

https://github.com/James1345/django-rest-knox/blob/3a1bc584f9691f4bc19d8a04a98c68c293be9ca6/knox/views.py#L65

Expected behavior

All active tokens, including the latter, would be expected to be taken into account.

Possible solution

I don't know if I'm misunderstanding something, but a change like the following would suffice.

# knox/views.py
from django.db.models import Q

...

token = request.user.auth_token_set.filter(Q(expiry__gt=now) | Q(expiry__isnull=True)) 
morty added a commit to morty/django-rest-knox that referenced this issue Oct 12, 2023
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

Successfully merging a pull request may close this issue.

1 participant