【发布时间】:2017-05-25 08:21:48
【问题描述】:
将我的项目升级到 1.1.0 后,我现在遇到针对我的 azure AD 开放 ID 身份验证的身份验证错误。
Fiddler 将错误显示为:
WWW-Authenticate: Bearer error="invalid_request", error_codes="[90010]", error_description="AADSTS90010: JWT 令牌不能与 UserInfo 端点一起使用。%0d%0aTrace。
这与 400 错误、BadRequest 和用户无法登录有关。
app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions
{
AutomaticAuthenticate = true,
AutomaticChallenge = true,
ClientId = Configuration["Authentication:AzureAd:ClientId"],
Authority = Configuration["Authentication:AzureAd:AADInstance"] + Configuration["Authentication:AzureAd:TenantId"],
ClientSecret = Configuration["Authentication:AzureAd:ClientSecret"],
CallbackPath = Configuration["Authentication:AzureAd:CallbackPath"],
ResponseType = OpenIdConnectResponseType.CodeIdToken,
GetClaimsFromUserInfoEndpoint = true,
Events = new OpenIdConnectEvents
{
OnAuthenticationFailed = OnAuthenticationFailed,
OnAuthorizationCodeReceived = OnAuthorizationCodeReceived,
OnMessageReceived = OnMessageReceived,
OnTicketReceived = OnTicketRecieved,
OnTokenValidated = OnTokenValidated,
OnUserInformationReceived = OnUserInformationReceived,
OnTokenResponseReceived = OnTokenResponseRecieved,
OnRemoteFailure = OnRemoteFailure
}
private async Task OnAuthorizationCodeReceived(AuthorizationCodeReceivedContext context)
{
var aadInstance = "https://login.microsoftonline.com/";
var graphResourceId = "https://graph.windows.net";
string userObjectId = (context.Ticket.Principal.FindFirst("http://schemas.microsoft.com/identity/claims/objectidentifier"))?.Value;
ClientCredential clientCred = new ClientCredential(clientId, clientSecret);
AuthenticationContext authContext = new AuthenticationContext(aadInstance + tenant);
AuthenticationResult authResult = await authContext.AcquireTokenByAuthorizationCodeAsync(
context.ProtocolMessage.Code, new Uri(context.Properties.Items[OpenIdConnectDefaults.RedirectUriForCodePropertiesKey]), clientCred, graphResourceId);
context.HandleCodeRedemption(authResult.AccessToken, authResult.IdToken);
}
由于我正在使用 CodeIdToken 并尝试使用 GetClaimsFromuserInfoEndpoint 选项,我现在是否需要以不同的方式处理用户声明?
编辑:如果我注释掉 GetClaimsFromUserInfoEndpoint 这工作正常
【问题讨论】:
标签: azure authentication active-directory openid