0

Ich erhalte weiterhin einen Fehler beim Authentifizieren mit IdentityServer4. Ich habe mir ein paar Ressourcen zu diesem Thema angesehen, aber alle beziehen sich nicht auf mein Problem. Ich bin eine json Anfrage https://localhost:44377/signin-oidc machen, aber das ist, was aus der AspCore Authentication DLLIdentity Server 4, message.State ist null oder leer

Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectMiddleware protokolliert: Information: Fehler von RemoteAuthentication: OpenIdConnectAuthenticationHandler: message.State ist null oder leer ..

Meine Startup.cs Konfiguration sieht wie folgt aus:

services.AddIdentityServer() 
    .AddInMemoryIdentityResources(Config.GetIdentityResources()) 
    .AddInMemoryApiResources(Config.GetApiResources()) 
    .AddInMemoryClients(Config.GetClients()) 
    .AddTestUsers(Config.GetTestUsers()) 
    .AddTemporarySigningCredential(); 



app.UseIdentityServer(); 
app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationScheme = "cookie" }); 
app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions 
{ 
    ClientId = "openIdConnectClient", 
    Authority = "https://localhost:44377/", 
    SignInScheme = "cookie", 
    TokenValidationParameters = new TokenValidationParameters 
    { 
     IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes("clientpassword")) 
    }, 
    CallbackPath = "/signin-oidc" 
}); 

und der Client ich Zugang lo bin versucht, oks wie diese

new Client 
{ 
    ClientId = "openIdConnectClient", 
    ClientName = "Example Implicit Client Application", 
    AllowedGrantTypes = GrantTypes.Implicit, 
    AllowedScopes = new List<string> 
    { 
     IdentityServerConstants.StandardScopes.OpenId, 
     IdentityServerConstants.StandardScopes.Profile, 
     IdentityServerConstants.StandardScopes.Email, 
     "role", 
     "customAPI" 
    }, 
    ClientSecrets = new List<Secret> { 
     new Secret("superSecretPassword".Sha256())}, 
    RedirectUris = new List<string> {"https://localhost:44377/signin-oidc"}, 
    PostLogoutRedirectUris = new List<string> {"https://localhost:44377"} 
} 
+0

Sie haben eine Tonne Beispiele im idserver Repo. Hast du dort nachgesehen? –

+0

Ich habe sie angeschaut, ich habe auch zusammen mit Tutorials gefolgt. Ich möchte nur die Authentifizierung mit einem Testbenutzer, ich möchte nicht ihre Datenbank migrieren. –

+0

haben Sie die Middleware-Bestellung korrekt? Dies ist sehr spezifisch und muss korrekt sein –

Antwort

0

ich Sie setzen AuthenticationScheme = "oidc" unter app.UseOpenIdConnectAuthentication müssen glauben.

app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions 
{ 
    AuthenticationScheme = "oidc" 
    ClientId = "openIdConnectClient", 
    Authority = "https://localhost:44377/", 
    SignInScheme = "cookie", 
    TokenValidationParameters = new TokenValidationParameters 
    { 
     IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes("clientpassword")) 
    }, 
    CallbackPath = "/signin-oidc" 
}); 
Verwandte Themen