Using IdentityServer3 I need to automatically login and redirect a local user back to the client application after the user has completed a registration process. Is there an elegant way to do this? From my digging I suspect not, in which case is there a hack I can use to achieve this?
I was able to achieve this for external users using a custom User Service, but this utilized a partial login. However, for local users they aren't in the authentication process handled by the User Service until they login with a username and password.
Please also note that I don't have access to the users password as the registration process is covered by multiple screens / views as in this instance they are required to verify their email as part of the registration process.
Progress:
I've found this https://github.com/IdentityServer/IdentityServer3/issues/563 but haven't worked out how to trigger the redirect.
I'm attempting to issue an authentication token using:
var localAuthResult = userService.AuthenticateLocalAsync(user);
Request.GetOwinContext().Authentication.SignIn(new ClaimsIdentity(localAuthResult.Result.User.Claims, Thinktecture.IdentityServer.Core.Constants.PrimaryAuthenticationType));
But the best I can do so far is redirect the user back to the login screen:
HttpCookie cookie = Request.Cookies["signin"]; // Stored previously at beginning of registration process
return Redirect("~/core/login?signin=" + cookie.Value);