2016-07-28 15 views
2

Ich bin neu bei IdentityServer3 und fange gerade an, es einzurichten. Es scheint ziemlich gut zu laufen und ich habe an dem Hybrid-Flow für eine MVC-App gearbeitet, ähnlich der in Pluralsight-Kurs von Kevin Dockx (http://www.pluralsight.com/courses/building-securing-restful-api-aspdotnet) , als ich versuchte, IdentityServer mit MVC-Fehler zu konfigurieren, erscheint Microsoft.IdentityModel.Protocols.OpenIdConnectProtocolException: invalid_requestIdentityServer3 mit ServiceStack und MVC Client

ID Server:

new Client 
{ 
    Enabled = true, 
    ClientName = "MVC Client (Hybrid Flow)", 
    ClientId = "mvc", 
    Flow = Flows.Hybrid, 
    RequireConsent = true, 
    RedirectUris = new List<string> 
    {"https://localhost:44358/"},      
} 

var scopes = new List<Scope>{      
    StandardScopes.OpenId, 
    StandardScopes.Profile 
}; 

und die folgende ist der Code aus dem MVC-Client App

public void Configuration(IAppBuilder app) 
    {    
     app.UseCookieAuthentication(new CookieAuthenticationOptions 
     { 
      AuthenticationType = "Cookies", 
      //CookieName = "ourcookiename" 
     }); 

     var options = new OpenIdConnectAuthenticationOptions 
     { 
      ClientId = "mvc", 
      Authority = "https://localhost:44367/identity/", 
      RedirectUri = "https://localhost:44358/", 
      // PostLogoutRedirectUri = "https://localhost:44300/", 
      SignInAsAuthenticationType = "Cookies", 
      ResponseType = "code id_token token", 
      Scope = "openId profile" 
     }; 
     app.UseOpenIdConnectAuthentication(options);   
    } 

Und auch IdentityServer3 mit 012 konfigurierenhttps://github.com/MacLeanElectrical/servicestack-authentication-identityserver `zur Authentifizierung des Dienstes, aber in Global.aspx für neue AppHost(). Init(); es zeigt fehler-

'System.NullReferenceException' occurred in ServiceStack.dll but was not handled in user code 
+0

Sie müssen sich auf die Protokollierung einzuschalten – leastprivilege

Antwort

1

Hier ist, wie ich tue mein

return new[] 
     { 
      new Client 
      { 
       Enabled = true, 
       ClientId = "Client", 
       ClientName = "SomeClient", 
       Flow = Flows.Hybrid, 
       RequireConsent = true, 
       AllowedScopes = new List<string> 
       { 
        "openid", 
        "profile", 
        "roles", 
        "api", 
        "offline_access" 
       }, 
       RedirectUris = new List<string> 
       { 
        Constants.Client 
       }, 

       AccessTokenLifetime = 3600, 

       ClientSecrets = new List<Secret>() 
       { 
        new Secret("secret".Sha256()) 
       } 
      } 
     }; 


var scopes = new List<Scope> 
     { 

      //Identity Scopes 
      StandardScopes.OpenId, 
      StandardScopes.Profile, 

      new Scope 
      { 
       Enabled = true, 
       Name = "roles", 
       DisplayName = "Roles", 
       Description = "The roles you belong to.", 
       Type = ScopeType.Identity, 
       Claims = new List<ScopeClaim> 
       { 
        new ScopeClaim("role") 
       } 
      }, 
      new Scope 
      { 
       Enabled = true, 
       Name="api", 
       DisplayName = "API Scope", 
       Description = "To accesss the API", 
       Type = ScopeType.Resource, 
       Emphasize = false, 
       Claims = new List<ScopeClaim> 
       { 
        new ScopeClaim("role"), 
        new ScopeClaim("id") 
       } 

      }, 

      StandardScopes.OfflineAccess 

     }; 

     return scopes; 
1

ich nicht sehen Sie die AllowedScopes in der Client-Angabe

new Client 
{ 
    Enabled = true, 
    ClientName = "MVC Client (Hybrid Flow)", 
    ClientId = "mvc", 
    Flow = Flows.Hybrid, 
    RequireConsent = true, 
    RedirectUris = new List<string> 
    {"https://localhost:44358/"}, 
    AllowedScopes = new List<string>{      
     "openid", 
     "profile" 
    };     
} 
+0

Ich habe Bereiche hinzugefügt, aber es zeigt denselben Fehler- "Microsoft.IdentityModel.Protocols.OpenIdConnectProtocolException: invalid_request" – pc2307