Skip to content

Using custom authentication handler #217

Closed Answered by Vampire2008
Vampire2008 asked this question in IdentityServer
Discussion options

You must be logged in to vote

I found solution. I just used my handler as external.

public class AccountController : Controller
{
    [HttpGet]
    public async Task<IActionResult> Login(string returnUrl)
    {
        var result = await HttpContext.AuthenticateAsync("MyScheme");

        if (!result.Succeeded)
        {
            return Challenge("MyScheme");
        }

        var identityServerUser = new IdentityServerUser(result.Principal.FindFirstValue(ClaimTypes.NameIdentifier)!)
        {
            IdentityProvider = "LegacyProvider"
        };
        await HttpContext.SignInAsync(identityServerUser);

        return Redirect(returnUrl);
    }
}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Vampire2008
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant