.NET OpenID CONTER -Anmeldung mit KeyCloak Fehlende Parameter: id_token_HintC#

Ein Treffpunkt für C#-Programmierer
Guest
 .NET OpenID CONTER -Anmeldung mit KeyCloak Fehlende Parameter: id_token_Hint

Post by Guest »

Ich habe kürzlich ein .NET -ASPIRE -Beispiel von Microsoft gefunden, in dem OpenID eine Verbindung mit Keycloak implementiert ist. Die Authentifizierung gegen die Backend -API funktioniert. Ich selbst. Umleiten Sie zurück zu meinem Spa, funktioniert nicht, da ich den Fehler mit fehlenden Parametern erhalte: ID_TOKE_HINT von keycloak.
Ich habe einen anderen gefunden Stackoverflow -Post, wobei die Lösung Optionen festlegen sollte. Gibt es noch etwas, das ich so konfigurieren muss, damit es ordnungsgemäß funktioniert?

Code: Select all

var oidcScheme = OpenIdConnectDefaults.AuthenticationScheme;
builder.Services.AddAuthentication(oidcScheme)
.AddKeycloakOpenIdConnect("keycloak", realm: "WeatherShop", oidcScheme, options =>
{
options.ClientId = "WeatherWeb";
options.ResponseType = OpenIdConnectResponseType.Code;
options.Scope.Add("weather:all");
options.RequireHttpsMetadata = false;
options.TokenValidationParameters.NameClaimType = JwtRegisteredClaimNames.Name;
options.SaveTokens = true;
options.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
})
.AddCookie(CookieAuthenticationDefaults.AuthenticationScheme);
< /code>
OpenID Connect Enoint -Konfiguration < /p>
internal static IEndpointConventionBuilder MapLoginAndLogout(this IEndpointRouteBuilder endpoints)
{
var group = endpoints.MapGroup("authentication");

// This redirects the user to the Keycloak login page and, after successful login, redirects them to the home page.
group.MapGet("/login", () => TypedResults.Challenge(new AuthenticationProperties { RedirectUri = "/" }))
.AllowAnonymous();

// This logs the user out of the application and redirects them to the home page.
group.MapGet("/logout", () => TypedResults.SignOut(new AuthenticationProperties { RedirectUri = "/" },
[CookieAuthenticationDefaults.AuthenticationScheme, OpenIdConnectDefaults.AuthenticationScheme]));

return group;
}
< /code>
KeyCloak Client -Konfiguration < /p>
{
"id" : "016c17d1-8e0f-4a67-9116-86b4691ba99c",
"clientId" : "WeatherWeb",
"name" : "",
"description" : "",
"rootUrl" : "",
"adminUrl" : "",
"baseUrl" : "",
"surrogateAuthRequired" : false,
"enabled" : true,
"alwaysDisplayInConsole" : false,
"clientAuthenticatorType" : "client-secret",
"redirectUris" : [ "https://localhost:7058/signin-oidc" ],
"webOrigins" : [ "https://localhost:7058" ],
"notBefore" : 0,
"bearerOnly" : false,
"consentRequired" : false,
"standardFlowEnabled" : true,
"implicitFlowEnabled" : false,
"directAccessGrantsEnabled" : false,
"serviceAccountsEnabled" : false,
"publicClient" : true,
"frontchannelLogout" : true,
"protocol" : "openid-connect",
"attributes" : {
"oidc.ciba.grant.enabled" : "false",
"post.logout.redirect.uris" : "https://localhost:7058/signout-callback-oidc",
"oauth2.device.authorization.grant.enabled" : "false",
"backchannel.logout.session.required" : "true",
"backchannel.logout.revoke.offline.tokens" : "false"
},
"authenticationFlowBindingOverrides" : { },
"fullScopeAllowed" : true,
"nodeReRegistrationTimeout" : -1,
"defaultClientScopes" : [ "web-origins", "acr", "profile", "roles", "email" ],
"optionalClientScopes" : [ "address", "phone", "offline_access", "weather:all", "microprofile-jwt" ]
}

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post