Skip to content

Return the auth challenge in the WWW-Authenticate when auth fails#1387

Open
KeesV wants to merge 5 commits intoThreeMammals:developfrom
KeesV:dev-return-auth-challenge-on-401
Open

Return the auth challenge in the WWW-Authenticate when auth fails#1387
KeesV wants to merge 5 commits intoThreeMammals:developfrom
KeesV:dev-return-auth-challenge-on-401

Conversation

@KeesV
Copy link
Copy Markdown

@KeesV KeesV commented Dec 7, 2020

Fixes / New Feature

Perform Challenge on failed authentication, and return the generated WWW-Authenticate header in the upstream response.

Proposed Changes

  • In AuthenticationMiddleware.cs: perform a challenge whenever authentication fails. This generates a WWW-Authenticate header on the response.
  • It seems that the httpContext.Response that is available in AuthenticationMiddleware.cs is recreated/overwritten further down the pipeline, so we need to preserve the generated WWW-Authenticate header somewhere. For now, I've put it in the httpContext.Items (suggestions on how to do this in a better way are highly appreciated).
  • Re-apply the WWW-Authenticate header on the response in ResponderMiddleware.cs.

@arnaulddumez
Copy link
Copy Markdown

Same problem for Access-Control-Allow-Origin ??

@raman-m
Copy link
Copy Markdown
Member

raman-m commented Jul 15, 2023

Hi Kees!
Thanks for your interest in Ocelot!

Could you Sync fork please? So, your develop branch is outdated!

@raman-m raman-m self-requested a review July 15, 2023 13:36
@raman-m raman-m force-pushed the dev-return-auth-challenge-on-401 branch from 40f5d8e to 0e5ab4e Compare August 21, 2023 16:05
@raman-m
Copy link
Copy Markdown
Member

raman-m commented Aug 21, 2023

@KeesV
Thanks for the great PR!
Is the PR related to some issue in backlog?

@raman-m raman-m added feature A new feature question Initially seen a question could become a new feature or bug or closed ;) needs feedback Issue is waiting on feedback before acceptance waiting Waiting for answer to question or feedback from issue raiser labels Aug 21, 2023
@KeesV
Copy link
Copy Markdown
Author

KeesV commented Aug 21, 2023

hey @raman-m! Thanks for revitalizing this PR. It's great to see some activity here.
I've synced my fork and added you as a contributor there, should you want to make any changes.
I don't think there's any issue in the backlog for this PR as of now.

@raman-m raman-m force-pushed the dev-return-auth-challenge-on-401 branch from a5b94fd to 9564e2c Compare August 22, 2023 09:39
@raman-m
Copy link
Copy Markdown
Member

raman-m commented Jun 11, 2024

Hello @KeesV !
Are you still with Ocelot?

@raman-m raman-m force-pushed the dev-return-auth-challenge-on-401 branch from e99b633 to 34eb955 Compare November 7, 2024 09:37
@raman-m raman-m added proposal Proposal for a new functionality in Ocelot Authentication Ocelot feature: Authentication and removed feature A new feature question Initially seen a question could become a new feature or bug or closed ;) needs feedback Issue is waiting on feedback before acceptance waiting Waiting for answer to question or feedback from issue raiser labels Nov 7, 2024
@raman-m raman-m force-pushed the develop branch 7 times, most recently from b0cdbd6 to fa54613 Compare April 3, 2025 11:23
@raman-m raman-m force-pushed the develop branch 6 times, most recently from c216cdf to b458f0f Compare April 7, 2025 16:13
@raman-m raman-m force-pushed the develop branch 22 times, most recently from 908d84f to 0678e7a Compare April 19, 2025 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Authentication Ocelot feature: Authentication proposal Proposal for a new functionality in Ocelot

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants