Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WwwAuthenticateParameters fails to create response from headers #3026

Closed
Trimack opened this issue Nov 18, 2021 · 8 comments · Fixed by #3436
Closed

WwwAuthenticateParameters fails to create response from headers #3026

Trimack opened this issue Nov 18, 2021 · 8 comments · Fixed by #3436
Assignees
Labels
Milestone

Comments

@Trimack
Copy link

Trimack commented Nov 18, 2021

The WWWAuthenticate helper fails for

Bearer authorization_uri=https://login.microsoftonline.com/12345678-268e-46c2-8d30-1ad8ad2cd49d/oauth2/authorize, resource_id=https://testingorg0127.crm10.dynamics.com/

There seem to be 2 problems:

  1. MSAL does not know how to parse authorization_uri property
  2. The WWWAUtheticate collection has 1 element, but .Any() returns false

For more details please see here

@bgavrilMS
Copy link
Member

Hi @Trimack - can you please provide an example header that this helper fails on? We do have some unit tests around it, and even integration tests, so I find it hard to believe that it will always fail.

@Trimack
Copy link
Author

Trimack commented Nov 18, 2021

I just did in what I believe to be a related issue in #3027 (comment).

I honestly do not understand why this doesn't work and how is the property supposed to work but here's a screenshot from the VS:
image

@bgavrilMS
Copy link
Member

bgavrilMS commented Nov 18, 2021

Is there a public URI I can access to get this 401 + authenticate header?

@Trimack
Copy link
Author

Trimack commented Nov 18, 2021

An example URI is https://mktcxptip11111810sg891crm08.crm10.dynamics.com/api/data/v9.1.

@bgavrilMS bgavrilMS added this to Triage in MSAL.NET (legacy) via automation Nov 18, 2021
@bgavrilMS bgavrilMS added this to the 4.39.0 milestone Nov 18, 2021
@bgavrilMS bgavrilMS moved this from Triage to Estimated/Committed in MSAL.NET (legacy) Nov 18, 2021
@trwalke trwalke moved this from Estimated/Committed to In Progress in MSAL.NET (legacy) Nov 24, 2021
@trwalke trwalke self-assigned this Nov 24, 2021
@pmaytak pmaytak modified the milestones: 4.39.0, 4.40.0 Nov 29, 2021
@trwalke
Copy link
Member

trwalke commented Dec 2, 2021

So I am able to reproduce this and it Looks like there are some additional configurations that are needed in order for us ot access the data in this header. Not sure why it is different for this endpoint.

This looks like something along the lines of what we need but not 100% sure yet:
https://stackoverflow.com/questions/52333446/core-2-1-refuses-to-respond-with-access-control-expose-headers

Looks like similar things happen in other languages as well
https://stackoverflow.com/questions/61357247/why-is-the-www-authenticate-header-missing-from-when-i-call-api-from-react-app
Based on what I am seeing here, we need the .NET equivalent of "Access-Control-Expose-Headers"

Still investigating

@trwalke trwalke moved this from In Progress to Blocked/Waiting for reply in MSAL.NET (legacy) Dec 7, 2021
@trwalke trwalke moved this from Blocked/Waiting for reply to In Progress in MSAL.NET (legacy) Jan 6, 2022
@bgavrilMS bgavrilMS modified the milestones: 4.40.0, 4.41.0 Jan 10, 2022
@bgavrilMS bgavrilMS moved this from In Progress to Triage in MSAL.NET (legacy) Jan 10, 2022
@gladjohn gladjohn modified the milestones: 4.41.0, 4.42.0 Feb 8, 2022
@alvin-h
Copy link

alvin-h commented Jun 1, 2022

Will a fix for this be prioritized?

I've tried using CreateFromResourceResponseAsync() to which all properties I need (Authority, Resource) returns null.

Manually using a GET request with HttpClient to the resourceUri and passing in the HttpResponseHeaders object from that into CreateFromResponseHeaders() also returns null.

Manually passing in the WWW-Authenticate header value as a string into CreateFromWwwAuthenticateHeaderValue() also returns null.

This is how the header string looks like:
Bearer authorization_uri=https://login.microsoftonline.com/<our-tenant-id>/oauth2/authorize, resource_id=https://<our-api-domain>/

@bgavrilMS
Copy link
Member

Yes, you are right @alvin-h , this is important.

@bgavrilMS bgavrilMS moved this from Triage to Estimated/Committed in MSAL.NET (legacy) Jun 1, 2022
@bgavrilMS bgavrilMS moved this from Estimated/Committed to In Progress in MSAL.NET (legacy) Jul 6, 2022
@trwalke trwalke moved this from In Progress to Blocked/Waiting for reply in MSAL.NET (legacy) Jul 13, 2022
@bgavrilMS bgavrilMS moved this from Blocked/Waiting for reply to Estimated/Committed in MSAL.NET (legacy) Jul 14, 2022
@trwalke trwalke moved this from Estimated/Committed to In Progress in MSAL.NET (legacy) Jul 19, 2022
@trwalke trwalke moved this from In Progress to Blocked/Waiting for reply in MSAL.NET (legacy) Jul 20, 2022
@bgavrilMS
Copy link
Member

@trwalke - aren't you working on this?

@pmaytak pmaytak modified the milestones: 4.46.0, 4.47.0 Aug 3, 2022
@trwalke trwalke closed this as completed Sep 2, 2022
@trwalke trwalke reopened this Sep 2, 2022
@gladjohn gladjohn modified the milestones: 4.47.0, 4.48.0 Sep 17, 2022
@pmaytak pmaytak modified the milestones: 4.48.0, 4.49.0 Nov 2, 2022
@pmaytak pmaytak closed this as completed Dec 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
MSAL.NET (legacy)
  
Blocked/Waiting for reply
Development

Successfully merging a pull request may close this issue.

6 participants