Cod*_*ero 9 c# asp.net-identity openid-connect oauth2 asp.net-core
我正在为 ASP.Net Core 应用程序使用 UseOpenIdConnectAuthentication 中间件来对 Dells Cloud 访问管理器令牌提供程序进行身份验证(设置以提供 OpenId/OAuth2 身份验证)。以下是代码:
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",
}
});
Run Code Online (Sandbox Code Playgroud)
但我现在被困在某一点上几个小时。我收到以下错误:
SecurityTokenInvalidSignatureException: IDX10500: 签名验证失败。没有用于验证签名的安全密钥
我在 url 查询字符串中获取代码和状态 https://example.com/signin-oidc?code=somecode&state=somestate
任何类型的指导表示赞赏。
更新添加发行人签名密钥:
TokenValidationParameters = new TokenValidationParameters
{
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(Configuration.GetValue<string>("AppSettings:ClientSecret")))
}
Run Code Online (Sandbox Code Playgroud)
您看到的错误是因为您没有使用OIDC 中间件提供的OpenID Connect 提供程序配置发现功能,该功能允许它检索用于签署身份令牌的加密密钥。
如果您的提供商支持此功能,请移除整个Configuration
节点并进行设置Authority
。所有端点都应该自动为您注册。
如果它不支持此功能,则您必须手动将签名密钥添加到OpenIdConnectOptions.TokenValidationParameters.IssuerSigningKeys
.
归档时间: |
|
查看次数: |
11852 次 |
最近记录: |