You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am implementing a custom RemoteAuthenticationHandler for ASP.NET Core applications (.NET 8), but cannot redirect to the application's endpoint after establishing the user's identity. I was able to see a 302 response in browser's network trace, but the location header does not contain the redirect URL argument passed to Context.Response.Redirect() (the header has a value of "/").
Below is the gist of my HandleRemoteAuthenticateAsync() method. Any suggestion is appreciated.
public class MySsoHandler : RemoteAuthenticationHandler<MySsoOptions>
{
protected override async Task<HandleRequestResult> HandleRemoteAuthenticateAsync()
{
// Build identity. Some code is omitted for clarity.
var identity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme);
var principal = new ClaimsPrincipal(identity);
await Context.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, principal, new AuthenticationProperties()
{
IsPersistent = true
});
// Want to redirect to application endpoint since the user identity is established
// variable "redirectURL" has value of "https://localhost/AspNetCoreSample/Sample/login" at this point but the location header of the response message (302) has a value of "/" in browser's message trace.
Context.Response.Redirect(redirectUrl);
return HandleRequestResult.Success(new AuthenticationTicket(principal, new AuthenticationProperties(), Scheme.Name));
}
}
The text was updated successfully, but these errors were encountered:
Instead of explicitly calling Context.Response.Redirect(), setting AuthenticationProperties.RedirectUri property appears to be the right thing to do.
var authProperties = new AuthenticationProperties()
{
RedirectUri = redirectUrl,
};
var ticket = new AuthenticationTicket(principal, authProperties, Scheme.Name);
return HandleRequestResult.Success(ticket);
I am implementing a custom RemoteAuthenticationHandler for ASP.NET Core applications (.NET 8), but cannot redirect to the application's endpoint after establishing the user's identity. I was able to see a 302 response in browser's network trace, but the location header does not contain the redirect URL argument passed to
Context.Response.Redirect()
(the header has a value of "/").Below is the gist of my HandleRemoteAuthenticateAsync() method. Any suggestion is appreciated.
The text was updated successfully, but these errors were encountered: