IdentityServer / IdentityServer4

OpenID Connect and OAuth 2.0 Framework for ASP.NET Core
https://identityserver.io
Apache License 2.0
9.23k stars 4.01k forks source link

Return back to Identity Server if ADFS User Login fails #4378

Closed vkalpana09 closed 4 years ago

vkalpana09 commented 4 years ago

I have the IdentityServer4 connected to ADFS and im able to login with right user credentials. I have enabled IWA and i have a secanrio like if the User clicks cancel it should return back to Identity Server application. As of now if i click cancel it just shows me 401 error page with ADFS URL.

image



 services.AddAuthentication().AddOpenIdConnect("adfs", "ADFS Authentication", options =>
 {
      options.SignInScheme = IdentityServerConstants.ExternalCookieAuthenticationScheme;
      options.SignOutScheme = IdentityServerConstants.SignoutScheme;
      options.Authority = "ADFS URL";
      ptions.ClientId = "Client  Id";
      options.ResponseType = "code";
      options.CallbackPath = "/signin-adfs";
      options.SignedOutCallbackPath = "/signout-callback-adfs";
      options.RemoteSignOutPath = "/signout-adfs";
      options.RequireHttpsMetadata = true;
      options.BackchannelHttpHandler = GetHandler();      
       options.ClientSecret = "Client Secret";
       options.SaveTokens = true;
       options.TokenValidationParameters = new TokenValidationParameters
       {
             NameClaimType = "name",
             RoleClaimType = "role"
         };
         options.GetClaimsFromUserInfoEndpoint = true;
 });
vkalpana09 commented 4 years ago

I am still waiting for inputs. Please suggest.

lazycoder07 commented 4 years ago

I had similar problem with Azure using openId. We handled it using events,

options.Events = new OpenIdConnectEvents { OnRemoteFailure = ctx => { switch (ctx.Failure.Message) { case string error when error.Contains("Error message which is received"): ctx.HandleResponse(); ctx.Response.Redirect("your page") } } };

vkalpana09 commented 4 years ago

Thanks for the reply. I will check this. So this u have written in startup class.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Questions are community supported only and the authors/maintainers may or may not have time to reply. If you or your company would like commercial support, please see here for more information.

github-actions[bot] commented 3 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.