Closed 113223 closed 13 hours ago
Hey @113223! I'm here to help you with any bugs, questions, or contributions you have for the Dify project. Let me know how I can assist you!
The issue you're experiencing seems to be related to the access token not being invalidated immediately upon logout. In the Dify codebase, the logout functionality involves revoking the access token by deleting it from the Redis store using the revoke_token
method in the TokenManager
class. This should prevent further access with the token [1].
Here are a few things you might want to check or try:
Ensure Token Revocation: Verify that the revoke_token
method is being called correctly when the logout action is triggered. This method should delete the token from Redis, effectively invalidating it.
Redis Configuration: Check your Redis configuration to ensure that the token is being stored and deleted as expected. Any issues with Redis connectivity or configuration might affect token revocation.
Frontend Token Removal: Make sure that the frontend is correctly removing the access token from client-side storage upon logout. The removeAccessToken
function should handle this by deleting the token from localStorage
[2].
API Endpoint: Confirm that the API endpoint responsible for handling logout is correctly implemented to interact with the token revocation process.
If these steps do not resolve the issue, there might be a need to further investigate the specific implementation details or any potential bugs in the codebase related to token management.
To continue talking to Dosu, mention @dosu.
This is how JWT works: it will expire quickly after you log out. More importantly, make sure to keep your token safe and avoid any leaks.
rks: it will expire quickly after you log ou
in fact , it will not expire quickly after you log out. when i use AccountService.logout(account=account) function,clear the refresh_token, but access_token is not expire quickly ,the old access_token is still used in the request header, the background interface can still access.
This is as expected. Please confirm that you are familiar with the JWT authorization.
If you have stricter security requirements, you can shorten the validity period of the JWT by adjusting the ACCESS_TOKEN_EXPIRE_MINUTES. However, it will still be usable until it expires.
This is as expected. Please confirm that you are familiar with the JWT authorization.
If you have stricter security requirements, you can shorten the validity period of the JWT by adjusting the ACCESS_TOKEN_EXPIRE_MINUTES. However, it will still be usable until it expires.
get it ,thank you
Self Checks
Dify version
0.11
Cloud or Self Hosted
Self Hosted (Source)
Steps to reproduce
When the user exits within the expiration time of access_token, but the old access_token is still used in the request header, the background interface can still access the problem
✔️ Expected Behavior
When the user exits within the expiration time of access_token, but the old access_token is still used in the request header, the background interface can not access
❌ Actual Behavior
No response