Closed mdmoura closed 4 years ago
@brockallen I found the problem and it happens when ProfileService is added:
services.AddScoped<IProfileService, ProfileService>();
With this I am not redirected do SPA client's login callback after external login even if the login is successful on IS.
I even tried with a very simple ProfileService:
public class ProfileService : IProfileService {
private readonly IUserClaimsPrincipalFactory<User> _claimsFactory;
private readonly UserManager<User> _userManager;
public ProfileService(UserManager<User> userManager, IUserClaimsPrincipalFactory<User> claimsFactory) {
_userManager = userManager;
_claimsFactory = claimsFactory;
}
public async Task GetProfileDataAsync(ProfileDataRequestContext context) {
User user = await _userManager.GetUserAsync(context.Subject);
ClaimsPrincipal principal = await _claimsFactory.CreateAsync(user);
context.IssuedClaims = principal.Claims.ToList();
}
public async Task IsActiveAsync(IsActiveContext context) {
User user = await _userManager.GetUserAsync(context.Subject);
context.IsActive = (user != null) && user.Enabled;
}
}
Am I missing something or is this a bug?
I'd suggest you test with our pre-built samples. You should see that they work. Then compare those to yours.
I am using the ASP.Net Core Identity Template with an Angular SPA client.
Starting the login process on the SPA I am redirected to Identity Server 4 login page.
If I login with Username/Password I am redirected back to the login callback url of the SPA:
AccountController > Login code that fires the redirect (
return Redirect(model.ReturnUrl)
):But if I login using Google's External authentication after I give the consent in Google I am redirected to Identity Server 4's Login page but I am never redirected to the SPA callback url:
ExternalController > Callback code that fires the redirect (
return Redirect(returnUrl)
):I checked the
Model.ReturnUrl
andreturnUrl
and they are similar:What am I missing?