aspnetcore icon indicating copy to clipboard operation
aspnetcore copied to clipboard

Adding Identity breaks Authentication using OAuth

Open jessehallam opened this issue 7 years ago • 3 comments

Describe the bug

When IServiceCollection.AddAuthentication().AddFacebook() is used, the user is populated with Facebook details after a Challenge sequence. When IServiceCollection.AddIdentity() is put in the mix, this breaks OAuth completely.

To Reproduce

Steps to reproduce the behavior:

  1. ASP.NET Core 2.1 or greater
  2. Minimal example

Expected behavior

When services.AddIdentity is omitted, the JSON output for route / is predictably the following:

{"isAuthenticated":true,"name":Jesse Hallam,"authenticationType":"Facebook"}

Unexpected behavior

When services.AddIdentity is put back in the mix, this "breaks" the OAuth flow in some undocumented way, and the JSON output is becomes:

{"isAuthenticated":false,"name":null,"authenticationType":null}

jessehallam avatar Mar 19 '19 15:03 jessehallam

When Identity is in, a (Facebook) OAuth flow results in an Identity.External cookie being sent. Is there something specific that should be done to get the external user out of the cookie?

Perhaps SignInManager<TUser>.GetExternalLoginInfoAsync() is a candidate for extracting the External cookie, but it returns null.

jessehallam avatar Mar 19 '19 15:03 jessehallam

Without seeing a minimal example of what you're doing here, or indeed what you're expecting its rather hard to help.

But identity is meant to be (nearly) the sole source of truth in an app. Facebook users would have to register a local account into identity in the default scenarios, and then the login flow would go through identity again to map to the local user, rather than have external auth providers.

blowdart avatar Mar 19 '19 20:03 blowdart

We're closing this issue as no response or updates have been provided in a timely manner. If you have more details and are encountering this issue please add a new reply and re-open the issue.

blowdart avatar Apr 04 '19 18:04 blowdart