Asp.netBlazor服务器应用在Kubernetes中使用OIDC无法进行重定向。
创始人
2024-09-17 06:00:31
0

在Kubernetes集群上使用OAuth2代理进行身份验证时,会出现Asp.net Blazor 服务器应用无法重定向的问题。这是由于OIDC配置未正确处理。要解决此问题,需要在Asp.net Blazor应用程序中添加以下代码段:

  1. 添加Microsoft.AspNetCore.Authentication.OpenIdConnect NuGet包。

  2. 在Startup.cs文件中,将如下代码段添加到ConfigureServices方法中:

services.AddAuthentication(options => { options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; }) .AddJwtBearer(options => { options.Authority = Configuration["Authority"]; options.Audience = Configuration["Audience"]; }) .AddOpenIdConnect("oidc", options => { options.Authority = Configuration["Authority"]; options.ClientId = Configuration["ClientId"]; options.ClientSecret = Configuration["ClientSecret"]; options.ResponseType = "code"; options.SaveTokens = true; options.GetClaimsFromUserInfoEndpoint = true; options.Scope.Add("openid"); options.Scope.Add("profile"); options.TokenValidationParameters = new TokenValidationParameters { NameClaimType = "name", RoleClaimType = "role" }; });

  1. 在Startup.cs文件中,将如下代码段添加到Configure方法中:

app.UseAuthentication(); app.UseAuthorization();

  1. 阅读Kubernetes Ingress控制器的文档,以确定如何在处理OAuth2代理的情况下正确设置Ingress规则。

  2. 在作为访问Kubernetes的负载均衡器(如NGINX)的机器上,安装OAuth2代理,以处理用户身份验证。

这些步骤提供了Asp.net Blazor服务器应用程序中解决此问题的解决方法。

相关内容

热门资讯

教你透视!hhpoker德州挂... 教你透视!hhpoker德州挂真的有吗,wepoker高级辅助,经验教程(有挂细节)-哔哩哔哩1、超...
解密透视!哈糖大菠萝可以开挂吗... 解密透视!哈糖大菠萝可以开挂吗,模拟器打开hhpoker,教材教程(确实有挂)-哔哩哔哩哈糖大菠萝可...
揭幕透视!约局吧德州透视,po... 揭幕透视!约局吧德州透视,pokemmo脚本辅助下载,经验教程(真是有挂)-哔哩哔哩pokemmo脚...
总结透视!pokermaste... 您好,pokemomo辅助软件这款游戏可以开挂的,确实是有挂的,需要了解加去威信【485275054...
详情透视!we poker免费... 详情透视!we poker免费辅助器,wepoker有用吗,模板教程(有挂秘籍)-哔哩哔哩1、实时w...
开挂透视!wejoker私人辅... 开挂透视!wejoker私人辅助软件,epoker有透视吗,攻略教程(有挂透视)-哔哩哔哩1)wej...
揭幕透视!hhpoker是真的... 揭幕透视!hhpoker是真的吗,wepoker辅助软件价格,妙招教程(有挂方法)-哔哩哔哩1、全新...
揭幕透视!破解辅助插件wepo... 揭幕透视!破解辅助插件wepoker,wepoker买脚本靠谱吗,技法教程(的确有挂)-哔哩哔哩1、...
总结透视!pokemmo脚本手... 总结透视!pokemmo脚本手机版,德州透视hhpoker,大纲教程(有挂方针)-哔哩哔哩1、该软件...
必备透视!wepoker一直输... 必备透视!wepoker一直输的号能继续打吗,hhpoker是真的还是假的,妙招教程(确实有挂)-哔...