0

I'm working on a multi-tenant application that can have unlimited subdomains (i.e. tenant1.myapp.com, tenant2.myapp.com, etc.) and I'm having trouble with the Identity cookie. It's authenticating for the entire domain and I would like to authenticate against the root-level domain (i.e. *.myapp.com or simply myapp.com).

I did find the solution for the previous version of .NET Core Identity (curse you progress), but that 2.0+, IdentityOptions.Cookies has been removed.

My question is, how would I implement something like this?

clockwiseq
  • 4,189
  • 9
  • 38
  • 61
  • there might be an easier way if you could inject something into your startup.cs constructor. But in a long way, you can make a scheme something like this https://stackoverflow.com/a/50111175/991609 – Neville Nazerane May 01 '18 at 04:31
  • Thanks Neville. I'll give it a look and see if that works. – clockwiseq May 01 '18 at 04:48
  • Ok, so the problem there is that I'm using Identity and I don't want to implement a custom auth handler. I just want to authenticate someone for the TLD instead of the subdomain. – clockwiseq May 02 '18 at 02:21
  • well, you will still be using identity. the auth handler i had created is technically extending the existing authentication and customizing your features. the defaults would still run – Neville Nazerane May 02 '18 at 02:27
  • But they don't. The login action authenticates, but redirects back to the login action so I'm assuming it's not creating the cookie or something. – clockwiseq May 02 '18 at 04:03
  • for login are you using the services from identity? you should be able to control this using the cookie events too – Neville Nazerane May 02 '18 at 04:10
  • I am. Everything is out of the box Identity with exception of also implementing SaasKit NuGet package. I don't know enough about the authentication to be able to wire up the cookie events. Have a good starting place for me to look? – clockwiseq May 02 '18 at 12:37

0 Answers0