2017-03-10 5 views
0

Ich habe IdentityServer4 mit einer IdentityServer3.AccessTokenValidation (v2.13.0) Web API eingerichtet. Vielleicht, weil der Schlüssel ist nicht ein 509x-ZertifikatIdentityserver4 mit IdentityServer3 AccessTokenValidation

Das Problem ist, dass die Web-API mit IdentityServer4 nicht authentifiziert.

WEB API startup.cs

public void Configuration(IAppBuilder app) 
    { 
     app.UseIdentityServerBearerTokenAuthentication(new IdentityServerBearerTokenAuthenticationOptions 
     { 
      Authority = "http://identity.positive.local:5000", 
      RequiredScopes = new[] { "odbc" } 
     }); 
    } 

IdentityServer4 Startup.cs (http://identity.positive.local:5000)

services.AddIdentityServer() 
      .AddSigningCredential(key) 
      .AddInMemoryIdentityResources(Config.GetIdentityResources()) 
      .AddInMemoryApiResources(Config.GetApiResources()) 
      .AddInMemoryClients(Config.GetClients()); 

IdentityServer4 Config.cs (http://identity.positive.local:5000)

public class Config 
{ 
    public static IEnumerable<IdentityResource> GetIdentityResources() 
    { 
     return new List<IdentityResource> 
     { 
      new IdentityResources.OpenId(), 
      new IdentityResources.Profile(), 
     }; 
    } 

    public static IEnumerable<ApiResource> GetApiResources() 
    { 
     return new List<ApiResource> 
     { 
      new ApiResource("api", "POSI_Master-API"), 
      new ApiResource("odbc", "POSI_Odbc-API") 
     }; 
    } 
    public static IEnumerable<Client> GetClients() 
    { 
     return new List<Client> 
     { 

      new Client 
      { 
       ClientId = "js", 
       ClientName = "JavaScript Client", 
       AllowedGrantTypes = GrantTypes.Implicit, 
       AllowAccessTokensViaBrowser = true, 
       RequireConsent = false, 
       RedirectUris = { "http://products.positive.local/auth" }, 
       PostLogoutRedirectUris = { "http://products.positive.local" }, 
       AllowedCorsOrigins = { "http://products.positive.local" }, 

       AllowedScopes = 
       { 
        IdentityServerConstants.StandardScopes.OpenId, 
        IdentityServerConstants.StandardScopes.Profile, 
        "api", 
        "odbc" 
       }, 
      } 
     }; 
    } 

} 
} 

enter image description here

EDIT:

Ausnahme geworfen: 'System.Reflection.ReflectionTypeLoadException' in mscorlib.dll iisexpress.exe Warnung: 0: Nachricht = 'Exception geworfen während Arten von immer' Microsoft.IdentityModel.Protocol. Erweiterungen, Version = 1.0.40306.1554, Kultur = neutral, PublicKeyToken = 31bf3856ad364e35 '.', Exception = System.Reflection.ReflectionTypeLoadException: kann einen oder mehrere der angeforderten Typen nicht laden. Rufen Sie die Eigenschaft LoaderExceptions für weitere Informationen auf. bei System.Reflection.RuntimeModule.GetTypes (RuntimeModule Modul) bei System.Reflection.RuntimeModule.GetTypes() bei System.Reflection.Assembly.GetTypes() bei System.Web.Http.Tracing.Tracers.DefaultHttpControllerTypeResolverTracer.GetTypesAndTrace (Montage Montage)

<?xml version="1.0" encoding="utf-8"?> 
<packages> 
    <package id="IdentityModel" version="1.13.1" targetFramework="net452" /> 
    <package id="IdentityServer3.AccessTokenValidation" version="2.14.0" targetFramework="net452" /> 
    <package id="Microsoft.AspNet.Cors" version="5.2.3" targetFramework="net452" /> 
    <package id="Microsoft.AspNet.Mvc" version="5.2.3" targetFramework="net452" /> 
    <package id="Microsoft.AspNet.Razor" version="3.2.3" targetFramework="net452" /> 
    <package id="Microsoft.AspNet.WebApi" version="5.2.3" targetFramework="net452" /> 
    <package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net452" /> 
    <package id="Microsoft.AspNet.WebApi.Core" version="5.2.3" targetFramework="net452" /> 
    <package id="Microsoft.AspNet.WebApi.Cors" version="5.2.3" targetFramework="net452" /> 
    <package id="Microsoft.AspNet.WebApi.Tracing" version="5.2.3" targetFramework="net452" /> 
    <package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.3" targetFramework="net452" /> 
    <package id="Microsoft.AspNet.WebPages" version="3.2.3" targetFramework="net452" /> 
    <package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="1.0.3" targetFramework="net452" /> 
    <package id="Microsoft.IdentityModel.Logging" version="1.1.3" targetFramework="net452" /> 
    <package id="Microsoft.IdentityModel.Protocol.Extensions" version="1.0.4.403061554" targetFramework="net452" /> 
    <package id="Microsoft.IdentityModel.Tokens" version="5.1.3" targetFramework="net452" /> 
    <package id="Microsoft.Net.Compilers" version="2.0.1" targetFramework="net452" developmentDependency="true" /> 
    <package id="Microsoft.Owin" version="3.0.1" targetFramework="net452" /> 
    <package id="Microsoft.Owin.Security" version="3.0.1" targetFramework="net452" /> 
    <package id="Microsoft.Owin.Security.Jwt" version="3.0.1" targetFramework="net452" /> 
    <package id="Microsoft.Owin.Security.OAuth" version="3.0.1" targetFramework="net452" /> 
    <package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net452" /> 
    <package id="Newtonsoft.Json" version="9.0.1" targetFramework="net452" /> 
    <package id="Owin" version="1.0" targetFramework="net452" /> 
    <package id="System.IdentityModel.Tokens.Jwt" version="5.1.3" targetFramework="net452" /> 
    <package id="System.Net.Http" version="4.3.1" targetFramework="net452" /> 
</packages> 
+1

Was sagen die Protokolle? Haben Sie in Ihrem Webapi-Projekt die Konsolen-/Debugprotokollierung aktiviert? – Lutando

+0

Hinzugefügt eine mögliche Ausnahme, die es verursachen könnte –

Antwort

0

Es wurden Fragen rund um einen Fehler in Httpclient berichtet - versuchen, die Aktualisierung manuell 4.3.1 bis System.Net.Http.

Wir haben gestern auch unsere Pakete aktualisiert.

In diesem Repo werden verschiedene IS3/4- und API-Szenario-Permutationen ausgeführt.

https://github.com/IdentityServer/CrossVersionIntegrationTests

Vergleichen Sie das mit Ihrem Szenario.

+0

Welches Projekt sprechen wir in crossversionintegrationtest? Ich suche nach .net Framework API zu identityserver4 core? –

+0

Meine Pakete hinzugefügt –

Verwandte Themen