Skip to content

How to process response body on (un)authorized responses? #2007

Answered by raman-m
pilgren asked this question in Q&A
Discussion options

You must be logged in to vote

When creating a custom authentication handler the failure message is not returned in the 401 response from Ocelot.
I would expect this failure message to be in the response body so that the API consumer could get a hint of why the authentication failed.

🆗

Step 1

Why not to define anonymous route to check required auth status?
Please note, anonymous route returns original status code always!

Step 2

After checking that authentication required obtain token from auth-token generation endpoint

Step 3

Make request to the upstream of auth route with token included.


Actual Behavior

The authentication handler is working as expected but I am not able to add anything to the response body when I …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by raman-m
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
Authentication Ocelot feature: Authentication Delegating Handlers Ocelot feature: Delegating Handlers
2 participants
Converted from issue

This discussion was converted from issue #1166 on March 23, 2024 12:30.