Auto-redirect to external IdP #79
-
IdentityServer version7 .NET version8 DescriptionI am working on a POC where I need to have IdentityServer behave as Federation Gateway (similar to https://docs.duendesoftware.com/identityserver/v7/ui/federation/). However, I need to have this IdentityServer not go thru a home realm discovery via the UI but auto-redirect to the external IdP. The detection will be done using the client-id in the connect/authorize request. What I am experiencing is that the IdentityServer is always presenting it's login UI with the buttons for each external IdP. I am unsure as to where to put this detection logic in the local IdentityServer so that the auto-redirect kicks in; Any working sample and/or suggestions would be highly appreciated! Reproduction stepsNo response Expected behaviorIdentityServer recieves the connect/authorize request with the client-id and after after my logic determines which external Idp to use, redirect user to that IdP without IdentityServer's UI for home realm discovery. LogsNo response Additional contextNo response |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
Heya @sanjeev-saxena-us 👋 Getting IdentityServer to auto-redirect to an external provider is relatively easy - I'll assume you don't need to logically switch between multiple external providers for the same client, just that depending on the client, you need to always redirect to a specific external provider (do correct me if I'm wrong). Have you looked at the Setting Where there being only 1 external provider and no local login, your client should be redirected to that external provider automatically. I did have a working demo of this a few weeks ago, but I don't think I committed the branch and can't remember what I did with the project locally 😅 If I happen to find it I'll link to the branch. |
Beta Was this translation helpful? Give feedback.
-
Hey @StuFrankish , Thanks for the suggestions. In IdentityServer, modified code based on your suggestions: var p = new OidcProvider
{
Scheme = "demoidsrv",
DisplayName = "IdentityServer (dynamic)",
Authority = "https://demo.duendesoftware.com",
ClientId = "login",
}; Client: var c = new Client
{
ClientId = "login",
ClientSecrets = { new Secret("secret".Sha256()) },
AllowedGrantTypes = GrantTypes.Code,
RedirectUris = { "https://localhost:5001/signin-oidc" },
FrontChannelLogoutUri = "https://localhost:5001/signout-oidc",
PostLogoutRedirectUris = { "https://localhost:5001/signout-callback-oidc" },
EnableLocalLogin = false,
IdentityProviderRestrictions = new[] { "demoidsrv"},
} Questions:
However, as a test, if I replace the line identified in the above image with (notice that I removed "/Index"): Thoughts? |
Beta Was this translation helpful? Give feedback.
-
Now, being auto-redirected and after being authenticated by the external IdP https://demo.duendesoftware.com, I do get redirected back to the client app but am getting the following: @StuFrankish any chance you have been able to find the working example branch? |
Beta Was this translation helpful? Give feedback.
Heya @sanjeev-saxena-us 👋
Getting IdentityServer to auto-redirect to an external provider is relatively easy - I'll assume you don't need to logically switch between multiple external providers for the same client, just that depending on the client, you need to always redirect to a specific external provider (do correct me if I'm wrong).
Have you looked at the
EnableLocalLogin
andIdentityProviderRestrictions
properties in the client configuration?Setting
EnableLocalLogin
tofalse
, will remove the username & password fields from the default UI.Specifying external providers in the
IdentityProviderRestrictions
collection will restrict that client to just the specified providers.See the d…