gpt4 book ai didi

asp.net - ASP.NET Core 的 Keycloak 客户端

转载 作者:行者123 更新时间:2023-12-04 13:06:51 26 4
gpt4 key购买 nike

Asp.net Core 是否有任何现有的 Keycloak 客户端? I have found a NuGet package for .net但它不适用于Core。您是否有任何想法如何轻松地与此安全服务器集成(或者可能使用任何其他替代方案)?

最佳答案

对于那些为 .Net 6 后端构建基于 KeyCloak 的身份验证并寻找基于 JWT token 的解决方案的人来说,这里是一个代码,可以在您的应用程序的 ConfigureServices 中添加 Delobytes.AspNetCore.Infrastructure客户:

services.AddKeyCloakAuthentication("SchemeName", true, options =>
{
options.Authority = "https://mykeycloakinstallation.com/auth/realms/myrealm"; //"issuer" endpoint
options.Audience = "account";
options.OpenIdConfigurationEndpoint = "https://mykeycloakinstallation.com/auth/realms/myrealm/.well-known/openid-configuration";
options.TokenValidationParameters = new TokenValidationOptions
{
RequireExpirationTime = true,
RequireSignedTokens = true,
ValidateIssuer = true,
ValidIssuer = "https://mykeycloakinstallation.com/auth/realms/myrealm",
ValidateAudience = true,
ValidAudience = "account",
ValidateIssuerSigningKey = true,
ValidateLifetime = true,
ClockSkew = TimeSpan.FromMinutes(2),
};
});

关于asp.net - ASP.NET Core 的 Keycloak 客户端,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41721032/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com