IdentityServer3 partial login replication was our solution: use a custom cookie to store data between steps.
First, we need to register our user cookie authentication (in Startup.Configure)
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationScheme = "my-partial",
AutomaticAuthenticate = false,
AutomaticChallenge = false
});
The first entry / entry point into the entry workflow must be mapped to GET /account/login(as from IdentityServer4 1.0.0-rc2).
In the second step, after sending and verifying the credentials, we save the username (and, ultimately, any other data) in a cookie.
the code:
var claims = new []
{
new Claim("my-user", username),
new Claim("some-attribute", someAttribute)
};
await HttpContext.Authentication
.SignInAsync("my-partial", new ClaimsPrincipal(new ClaimsIdentity(claims)));
. POST /account/login . , IdentityServer ( RC2). .
- cookie
- cookie
- ""
- returnUrl ( . )
var partialUser = await HttpContext.Authentication.AuthenticateAsync("my-partial");
var username = partialUser?.Claims.FirstOrDefault(c => c.Type == "dr-user")?.Value;
var claims = new [] { };
await HttpContext.Authentication
.SignOutAsync("my-partial");
await HttpContext.Authentication
.SignInAsync(username, username, claims);
return Redirect(returnUrl);
, , , , cookie ..