hasura / hasura/graphql-engine

JWT mode returns multiple unauthorised responses types

Open
#9,251 0 comments 0 reactions 0 assignees View on GitHub
k/enhancement t/gql-services
Dominant language
TypeScript
Stars
32.1k
Forks
3k
PR merge metrics
PR metrics pending

Description

How is one supposed to catch unauthorised responses ? There are (to my knowledge) three types of errors when authentication isn't what's expected :
**No token is passed**
```
{
"errors": [
{
"extensions": {
"code": "validation-failed",
"path": "$.selectionSet.XXX"
},
"message": "field 'XXX' not found in type: 'mutation_root'"
}
]
}
```
**Malformed token**
```
{
"errors": [
{
"extensions": {
"code": "invalid-jwt",
"path": "$"
},
"message": "Could not verify JWT: JWSError (JSONDecodeError \"Not valid base64url\")"
}
]
}
```
**Invalid JWT Signature**
```
{
"errors": [
{
"extensions": {
"code": "invalid-jwt",
"path": "$"
},
"message": "Could not verify JWT: JWSError JWSInvalidSignature"
}
]
}
```
**All of these are 200 responses** : how can the client (i.e Apollo) setup the refresh token rule with these ? Shouldn't they all be 401 in the end ?
Related to [8659](https://github.com/hasura/graphql-engine/issues/8659)

Contributor guide

Open the contributing guide

Research direction

Start with the JWT mode behavior described in this issue and the related issue #8659. Compare the no-token, malformed-token, and invalid-signature examples, including their HTTP status and GraphQL error codes. Done means the expected unauthorized response behavior and Apollo refresh-token handling are clearly established.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql
Domain
api, authentication
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.