-
Notifications
You must be signed in to change notification settings - Fork 16
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
Treat expired JWT token as an unregistered user #286
Comments
This might not be a good idea. What I can tell, all API endpoints don't seem to return 401 even if the token is expired. For example the URL /hearings/list makes API calls listed below, only first and last fails when using expired token and those are endpoints that will require authentication with permission class.
I would argue that the API works like it should, and at least the above endpoints shouldn't even return data to anonymous users so the UI would be more confused that before. Especially if the UI still thinks user is logged in (because it has the JWT token and no errors are returned from API?) Could it be better that the UI purges the JWT token from API request if 401 with this error string is returned:
Or UI could automatically prompt user to login again. However, if there is need to tinker with the authentication, here is the relevant place to do so: Question is should we implement this to helusers app instead kerrokantasi project or override the helusers authentication class in kerrokantasi project? |
Hm. Here the problem is not the user endpoint, but the Of course, if somebody passes an expired token, it would be much cleaner to let the UI know that is the case, but in this case even the user does not realize they still have the token; they probably have forgotten already that they were logged in. So this is in a way a special case, because we want the same endpoint to return things to both authenticated and unauthenticated users. And that is the origin of the problem. I would fix this for the time being by overriding this in kerrokantasi specifically; that is because this is very much a service specific feature where the endpoint may return different data depending on the presence of authentication. I'm not sure if we want this to be the general behavior in all Helsinki services. |
Should the overridden authentication class be used specifically for the |
Currently, if a user tries to use an endpoint with an expired token, the API always returns 401 even if the data would be available without a token.
While this is sensible given the assumption that the user really meant to use the token, it is problematic from the UI point of view, since all users with expired tokens will suddenly encounter API errors on all public pages, and they have no idea what is going on.
As long as we don't have silent autorenewal of the JWT token, the API should perhaps return the same response as to a request without a token, if the token is invalid?
The text was updated successfully, but these errors were encountered: