1

Ich integriere Identity Server 4 mit Asp.net 4.5 MVC 4 Web-Anwendung. Nachdem die Aktion Autorisieren auf die Anmeldeseite des Identitätsservers umgeleitet wurde, aber nach der erfolgreichen Anmeldung, kommt sie nicht mehr zur Client-MVC-Anwendung.Asp.net MVC 4.5.2 nicht umleiten nach dem Login mit IdentityServer4

Mein Klient in Identitätsserver 4 ist

new Client { ClientId = "demo", 
        AllowedScopes = new List<string> { "openid"}, 
        AllowedGrantTypes = GrantTypes.Hybrid, 
        RedirectUris = new List<string>{"http://localhost:51048/signin-oidc"},} 

mein Start

app.UseCookieAuthentication(new CookieAuthenticationOptions 
      { 
       AuthenticationType = "Cookies" 
      }); 
      app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions 
      { 
       Authority = "http://localhost:5000", //ID Server 
       ClientId = "demo", 
       ResponseType = "id_token code", 
       SignInAsAuthenticationType = "Cookies", 
       RedirectUri = "http://localhost:51048/signin-oidc", 
       Scope = "openid",    
      }); 
+1

Was die Protokolle sagen die erforderlichen Daten in den Ansprüchen Zugabe? Auch Ihr RedirectUri, das für den Client und das RedirectUri der UseOpenIdConnectAuthentication konfiguriert ist, sind nicht identisch. – Lutando

+0

Die Ports der Umleitung Uri sind nicht übereinstimmend – devqon

+0

Ist die Frage jetzt MVC4 oder ASP.NET Core MVC verwandt? Die Tags scheinen zu verwirren und von der ersten Sicht auf sie nicht asp.net Kern – Tseng

Antwort

0

den UseOpenIdConnectAuthorization Optionen hinzufügen AuthenticationScheme und SigninScheme enthält:

app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions 
{ 
    AuthenticationScheme = "oidc", 
    SignInScheme = "Cookies" 
    // other options omitted... 
}); 
0

Für meinen Fall die Ursache für Bei diesem Fehler wurde das benutzerdefinierte Autorize-Attribut hinzugefügt utes und Öffnen einer Sitzung, nachdem der Benutzer autorisiert wurde, zu speichern, um Benutzerinformationen zu speichern.

[CustomAuthorize] 
public class SecureController 

so für mich die Lösung war keine Sitzung auf AuthorizeCore Funktion zu öffnen, aber, wie folgend

 app.UseCookieAuthentication(new CookieAuthenticationOptions 
     { 
      AuthenticationType = CookieAuthenticationDefaults.AuthenticationType 
     }); 

     app.UseOpenIdConnectAuthentication(

      new OpenIdConnectAuthenticationOptions 
      { 
       ClientId = Settings.Default.AuthenticationOptionsClientId, 
       ClientSecret = Settings.Default.AuthenticationOptionsClientSecret, 
       SignInAsAuthenticationType = CookieAuthenticationDefaults.AuthenticationType, 
       AuthenticationType = Settings.Default.AuthenticationOptionsAuthenticationType, 
       Authority = Settings.Default.AuthenticationOptionsAuthority, 
       RedirectUri = Settings.Default.AuthenticationOptionsRedirectUri, 
       ResponseType = Settings.Default.AuthenticationOptionsResponseType, 
       UseTokenLifetime = Settings.Default.AuthenticationOptionsUseTokenLifetime, 
       AuthenticationMode = AuthenticationMode.Active, 


       Notifications = new OpenIdConnectAuthenticationNotifications 
       { 
        SecurityTokenValidated = async context => 
        { 
         var claimsIdentity = new ClaimsIdentity(context.AuthenticationTicket.Identity.AuthenticationType); 

         claimsIdentity.AddClaim(new Claim("UserData", "User Data Content")); 

         context.AuthenticationTicket = new AuthenticationTicket(
          claimsIdentity, 
          context.AuthenticationTicket.Properties); 
        } 
       } 
      }); 
Verwandte Themen