use 401 for expired or malformed tokens#23
Merged
timbod7 merged 2 commits intoadl-lang:masterfrom Apr 15, 2025
Merged
Conversation
timbod7
reviewed
Apr 15, 2025
Contributor
There was a problem hiding this comment.
modulo the comment I'm fine with this change it seems to match the http spec better.
But I fail to see how why this is important:
Allows frontend to use 401 as a trigger for requesting new token or prompting user to login.
as I think the existing approach where the token is refreshed prior to expiring is prefereable:
it seems unfortunate that we've lost this behaviour in the ts/ui/ code. On cloning for a new project the first thing I'd do would be to copy ts/api-workbench/src/hooks/use-app-state.ts into ts/ui/ for the auth and referesh behaviour.
| @@ -199,7 +199,7 @@ fn claims_from_bearer_token( | |||
| let jwt = jwt::bearer_token_from_auth_header(auth_header).ok_or(forbidden())?; | |||
Contributor
There was a problem hiding this comment.
should this be unauthorized() also?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Allows frontend to use 401 as a trigger for requesting new token or prompting user to login.
403s suggest developer error in frontend, i.e. the app should not allow users to hit endpoints they don't have the right role for.
whilst this weakens the "all requests are 200, errors are checked in userland" rule, it would be handled once centrally in an app.