question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to have multiple OpenID Connect middlewares

See original GitHub issue

I’ve configured multiple OpenID Connect middlewares, each having a different value for OpenIdConnectAuthenticationOptions.AuthenticationType, and registered with: app.UseOpenIdConnectAuthentication(options).

The problem seems to be that when the authentication occurs, the first registered middleware always handles things, instead of the middleware corresponding to the correct authentication type.

Lets say my two middlewares have AuthenticationTypes of “FirstProviderAuthType” and “SecondProviderAuthType”.

I’m kicking off the authentication using something like this:

var properties = new AuthenticationProperties { RedirectUri = "https://something", };
((IOwinContext)context).Authentication.Challenge(properties, "SecondProviderAuthType");

However, in any of the notifications (e.g. OpenIdConnectAuthenticationOptions.Notifications.SecurityTokenReceived), the value of notification.Options.AuthenticationType is always equal to “FirstProviderAuthType”, which is definitely not what I would expect.

Using all 4.0.0 Katana libraries from NuGet.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:16 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
Tratchercommented, Sep 14, 2018

I’d forgotten that OpenIdConnectAuthenticationOptions.RedirectUri is the primary value in this version of OIDC, we’ve removed it from the ASP.NET Core version. Setting RedirectUri to an absolute uri like “http://localhost/custom-signin-oidc” should be adequate for most scenarios, there’s no need to set CallbackPath as it will be derived from RedirectUri.

CallbackPath primarily needs to be overridden when your app is hosted as a sub site like “http://localhost/mysite/”. In that case CallbackPath needs to be set to “/signin-oidc” and RedirectUri needs to be set to “http://localhost/mysite/signin-oidc”. “/mysite” is trimmed by the server before the request reaches the OIDC middleware.

0reactions
praveena-mukcommented, Dec 13, 2018

@MoonStorm / @RobSiklos based on the discussion above i understand this issue is the scenario when OWIN startup + multiple OpenIdConnect Authorities + custom DataProtector are involved. were you able to solve your issue? (asking since the thread is still open) could you maybe post a sample solution?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Multiple OpenIdConnectAuthentication-Middlewares for ...
We are trying to use the marvelous IdentityServer for our product. Your application should be able to work with different tenants and each ......
Read more >
Asp.net Core 2.0 Identity with multiple OIDC providers
I ran into an issue working on an OpenId Connect (OIDC) project recently and it turned out to be due to my usage...
Read more >
Multiple baseUrls for the same express-openid-connect ...
Problem statement. Is it possible to dynamically set baseURL on a per-request basis instead of defined statically one time?
Read more >
getting error while integrating Azure OpenId connect
Hi, I am trying to inegrate Azure openId connect AD authentication, ... IDX20803: Unable to obtain configuration from: '[PII is hidden]'.
Read more >
The OWIN OpenID Connect Middleware
First, you might register multiple redirect_uri values for your app, in which case Azure AD will choose which one to use in a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found