skoruba / IdentityServer4.Admin

The administration for the IdentityServer4 and Asp.Net Core Identity
MIT License
3.56k stars 1.15k forks source link

_signInManager.GetExternalLoginInfoAsync() is always null in ProfileService #976

Open krifalk opened 2 years ago

krifalk commented 2 years ago

I have upgraded my IdentityServer and uses the latest version (2.1.0) of IdentityServer4.Admin. In the previous version I had implemented a custom Profile Service to merge claims from external provider, i.e. Azure AD.

The ProfileService works as expected, but _signInManager.GetExternalLoginInfoAsync() now is always null in ProfileService. In ExternalLoginCallback() in AccountController I have the expected ExternalLoginInfo from Azure AD, including the claims.

Is there something obvious I'm missing here, or why am I not able to user GetExternalLoginInfoAsync() outside the controller anymore?

The custom ProfileService is configured like this: image

IAMHK90 commented 1 year ago

@krifalk, I'm facing the same issue as well. Is it working for you?

krifalk commented 1 year ago

@harikarthik Unfortunately not. I ended up with creating a helper class and calling it from the controller at login. Something like this.

public static class MergeClaims<TUser, TKey> where TUser : IdentityUser<TKey>, new() where TKey : IEquatable<TKey> { public static async Task Do(UserManager<TUser> userManager, TUser user, ExternalLoginInfo externalLoginInfo, List<string> groups) { // Merging the claims here }

Have since then moved on to using Azure B2C for authentication instead. IdentityServer became a dead end.