OpenIdConnectAuthenticationHandler:message.State为null或为空
我正在使用UseOpenIdConnectAuthentication中间件为ASP.Net Core应用程序对Dells云访问管理器令牌提供程序进行身份validation(设置为提供OpenId / OAuth2身份validation)。 以下是代码:
app.UseCookieAuthentication(new CookieAuthenticationOptions { AutomaticAuthenticate = true, AutomaticChallenge = true, AuthenticationScheme = "ClientCookie", CookieName = CookieAuthenticationDefaults.CookiePrefix + "ClientCookie", ExpireTimeSpan = TimeSpan.FromMinutes(5), LoginPath = new PathString("/signin"), LogoutPath = new PathString("/signout") }); app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions { RequireHttpsMetadata = false, SaveTokens = true, ClientId = "XYZClient_Id", ClientSecret = "XYZ_ClientSecret", ResponseType = OpenIdConnectResponseType.Code, PostLogoutRedirectUri = "https://example.com", Configuration = new OpenIdConnectConfiguration { AuthorizationEndpoint = "https://CAM.COM/CloudAccessManager/RPSTS/OAuth2/Default.aspx", TokenEndpoint = "https://CAM.COM/CloudAccessManager/RPSTS/OAuth2/Token.aspx", UserInfoEndpoint = "https://CAM.COM/CloudAccessManager/RPSTS/OAuth2/User.aspx", Issuer= "urn:CAM.COM/CloudAccessManager/RPSTS", } });
但是现在我被困在了一个小时。 我收到以下错误:
SecurityTokenInvalidSignatureException:IDX10500:签名validation失败。 没有用于validation签名的安全密钥
我在url querystring中获取代码和状态https://example.com/signin-oidc?code=somecode&state=somestate
任何类型的指导表示赞赏。
更新添加的颁发者签名密钥:
TokenValidationParameters = new TokenValidationParameters { IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(Configuration.GetValue("AppSettings:ClientSecret"))) }
您看到的错误是由于您没有使用OIDC中间件提供的OpenID Connect提供程序配置发现function ,这使得它可以检索用于签署身份令牌的加密密钥。
如果您的提供程序支持此function,请删除整个“ Configuration
节点并改为设置Authority
。 应自动为您注册所有端点。
如果它不支持此function,则必须手动将签名密钥添加到OpenIdConnectOptions.TokenValidationParameters.IssuerSigningKeys
。
上述就是C#学习教程:OpenIdConnectAuthenticationHandler:message.State为null或为空分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/cdevelopment/1026060.html