-
Notifications
You must be signed in to change notification settings - Fork 79
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
Ratelimit doesn't work after token expires #31
Comments
@himalacharya did you find a solution to your problem? can you share here, if it was related to slowapi? |
The problem is that user information cann't be decoded from expired token. However, above problem is solved by try except method.
For unexpired token, it ratelimits user and for expired tokens , it ratelimits client IP address. For no token, ratelimits client IP address |
My concern with your fix is that you seem to be mixing access control into rate-limiting, which could have security implications. In my mind, your access control layer should block the request if the access token is expired, and slowapi should never even see the request. Looking at your problem again, have you tried using 2 limiter instances? one for each type of endpoint? I've not tried this before, so I have no idea if it works, but you should be able to share the data store between them, and it might solve your problem. |
@himalacharya Is this still an issue? |
I am rate limiting on two approaches:
i)based on IP address (for endpoint having no access token)
Works fine
ii) based on user id ( obtained from JWT token)
I have used https://pypi.org/project/fastapi-jwt-auth/ for JWTAuth. On the basis of #25 , in limiter.py
This works fine on unexpired JWT access token and ratelimits user. But when JWT access token expires, then it throws an error.
When accesstoken expires, I need to return HTTP 403 Forbidden access message.
The text was updated successfully, but these errors were encountered: