hasura / hasura/graphql-engine

Auth hook custom error message

Open
#7,295 2 comments 2 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
32.1k
Forks
3k
PR merge metrics
PR metrics pending

Description

Hi devs,

I'm facing an issue where I can't set a custom response message from my auth hook.

**My understanding of the system:**

**response code 401:**
returns **"Authentication hook unauthorized this request"** as error message
[401 error ](
https://github.com/hasura/graphql-engine/blob/2152911e240627add0a5b6b69b052efaa924c338/server/src-lib/Hasura/Server/Auth/WebHook.hs#L128
)

**response code anything other than [401,200]:**

returns a 500 error with this message: **"Invalid response from authorization hook"**
[500 error](https://github.com/hasura/graphql-engine/blob/2152911e240627add0a5b6b69b052efaa924c338/server/src-lib/Hasura/Server/Auth/WebHook.hs#L132)

I'm receiving my custom error message in Hasura server logs but not in response.

Is there any solution to receive a custom error message instead of these predefined ones?

thanks a lot

Contributor guide

Open the contributing guide

Research direction

Start with server/src-lib/Hasura/Server/Auth/WebHook.hs at the response handling around the linked lines. Trace how authentication-hook responses become GraphQL API errors and check for related tests or response fixtures. Done means the intended custom error-message behavior is defined and covered for unauthorized and other invalid hook responses.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, haskell
Domain
api, authentication
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.