无法从外部身份验证提供者那里获取票证

时间:2020-05-14 08:45:21

标签: asp.net-core asp.net-identity identityserver4

我正在使用外部身份验证提供程序(ActiveLogin.GrandId.AspNetCore)登录到IdentityServer4服务器。该代码基本上是由IS4 QuickstartUI示例构成的,其中有几行用于ActiveLogin的启动。我的控制者发起了如下挑战:

{
    RedirectUri = Url.Action(nameof(Callback)),
    Items =
    {
        { "returnUrl", returnUrl },
        { "scheme", provider },
        { "cancelReturnUrl", Url.Action("Login","Account",new { returnUrl }) }
    }
};

return Challenge(props, provider);

Callback希望返回带有用户信息的票证

public async Task<IActionResult> Callback()
{
    var result = await HttpContext.AuthenticateAsync(); 
        if (result?.Succeeded != true)

GrandIdAspNetCore继承自Microsoft.AspNetCore.Authentication,当我调试该代码时,我可以看到票证,它看起来像-并返回它:

protected override async Task<HandleRequestResult> HandleRemoteAuthenticateAsync()
{
    var sessionResult = await GetSessionResponseAsync(sessionId);

    var properties = state.AuthenticationProperties;
    var ticket = GetAuthenticationTicket(sessionResult, properties);

    var result = HandleRequestResult.Success(ticket);
    return result;

我猜测AspNetCore身份验证代码出于某种原因删除了票证。可能是它试图将其添加到会话中-但失败了(未设置正确的用户身份)。

我被困在这里,很想听听是否有人对可能出什么问题有任何想法?

这是日志的样子:

[16:14:41 Information] ActiveLogin.Authentication.GrandId.AspNetCore.GrandIdBankIdHandler
AuthenticationScheme: grandid-bankid-otherdevice was challenged.

[16:15:03 Information] ActiveLogin.Authentication.GrandId.AspNetCore.GrandIdBankIdHandler
GrandId (BankId) get session succedded for the sessionId '5d29bae8fe564b313195bd3ac183f94e'

[16:15:03 Information] Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationHandler
AuthenticationScheme: idsrv.external signed in.

[16:16:17 Error] Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware
An unhandled exception has occurred while executing the request.
System.Exception: External authentication error

0 个答案:

没有答案