dazinator / AspNetCore.LegacyAuthCookieCompat

Provides classes to encrypt / decrypt asp.net 2 / 3.5 / 4 and 4.5 FormsAuthenticationTickets (cookies) without relying on system.web
MIT License
74 stars 18 forks source link

dotnet core webapi integration examples #8

Closed mac2000 closed 6 years ago

mac2000 commented 6 years ago

Is there any examples of integration with dotnet core webapi (or mvc)?

If I understand things right we may:

  1. User CookieAuthentication with custom events handler
  2. Write own auth middleware
  3. something else...

There is way to many approaches to choose from, maybe someone may share their experience?

In our case we wish to have JWT based auth in our API but still auth users coming from legacy app by cookie

dazinator commented 6 years ago

I personally use cookie auth, and jwt auth in the same website, as two different auth handlers. Ultimately the auth handler needs to construct a ClaimsPrincipal for the authenticated user.

JWT handler can do this from a JWT token. You would need to write your own handler to do this from a webforms auth cookie created by another site - and this library just helps with the decryption part so you can get access to the user details embedded within that cooke, and then create the ClaimsPrincipal as you see fit.

No samples that I know of. You should be able to find docs about writing an auth handler for webapi though.