这是indexloc提供的服务,不要输入任何密码
Skip to content

Cookie JWT token expected even when unauthorised role set #7272

@bitscraps

Description

@bitscraps

I appear to be having an issue whilst using JWT tokens via cookies. For unauthenticated requests, I am not sending a cookie. From the documentation, I'm expecting these requests to use the role set in HASURA_GRAPHQL_UNAUTHORIZED_ROLE. However, instead, i get an error response:

    "errors": [
        {
            "extensions": {
                "path": "$",
                "code": "invalid-headers"
            },
            "message": "Could not find access_token in Cookie header"
        }
    ]
}

Authenticated requests with a JWT token work fine. However, we need to make a request first to get an access token that is falling foul of this expectation that there should be a cookie header. The documentation for this UNAUTHORIZED_ROLE talks about authorization header's which we are not using. Is this option supported with JWT cookie authentication?

These are the options being passed to the Hasura docker image:

HASURA_GRAPHQL_JWT_SECRET: '{"type":"HS256", "key": "my_key", "header": { "type": "Cookie", "name": "access_token" } }'
HASURA_GRAPHQL_UNAUTHORIZED_ROLE: public

Comments in the code suggest that it should be using the unauthorized role.

-- Iff no "Authorization"/"Cookie" header was passed, we will fall back to the

If i switch to using the authorization header rather than a cookie, and i don't send a header it allows the request to continue, presumably using the UNAUTHORIZED ROLE

Metadata

Metadata

Labels

k/bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions