Недавно я нашел пример .NET Aspire из Microsoft, где реализован OpenId Connect с KeyCloak. Аутентификация против бэкэнд API работает.
Решение, однако, не полностью реализует механизм выхода, поэтому я решил попробовать его самостоятельно.
Проблема, которая у меня есть, заключается в том, что когда я перейду к конечной точке входа с помощью Navlink, меня перенаправляют на KeyCloak, и сеанс в KeyCloak будет удален, однако перенаправление обратно в мой спа -салон не работает , как я получаю ошибку отсутствующие параметры: id_token_hint из keycloak. Чтобы установить Options.savetokens = true в конфигурации OpenIdConnect, однако это уже установлено в моей конфигурации, и она все еще не работает. Есть ли что -нибудь еще, что мне нужно настроить для правильной работы?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 Enpoint Configuration < /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>
client config Config < /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" ]
}
Подробнее здесь: https://stackoverflow.com/questions/794 ... token-hint
.NET OPENID CONNECT ONGINOINTING с KeyCloak отсутствуют параметры: id_token_hint ⇐ C#
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
.NET OPENID CONNECT ONGINOINTING с KeyCloak отсутствуют параметры: id_token_hint
Anonymous » » в форуме C# - 0 Ответы
- 9 Просмотры
-
Последнее сообщение Anonymous
-
-
-
.NET OPENID CONNECT ONGINOINTING с KeyCloak отсутствуют параметры: id_token_hint
Anonymous » » в форуме C# - 0 Ответы
- 18 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Как получить конфигурацию OpenId Connect из URL-адреса ./well-known/openid-connect в OWIN?
Anonymous » » в форуме C# - 0 Ответы
- 27 Просмотры
-
Последнее сообщение Anonymous
-