I have the following scenario:
A .net 4.6 web forms application is running in the f.e. domain.com
and users register and login using identity 2.2.
There are some admin users that have the Role of Administrator
.
There is also a subdomain f.e. admin.domain.com
, made in .net core 2.2 and now I want the Administrator users only to have access in the subdomain.
What I did:
- First try was to generate a link like
admin.domain.com?email=<hashed email>&datetime=<hashed datetime>
and displaying this link to Admin users in domain in order to jump in the subdomain. Then in the subdomain I tried to read the querystring and determine if the user is authorized to have access to subdomain. In this approach I had many problems and I don't think this is the right solution. - My second approach was to use the Identity user to the subdomain as well, but I realized that the 2 Identities (.NET Framework 4.6 and Core 2.2) are different and I didn't managed to make it work, for example I need the already logged in user in the domain to be authorized in the subdomain automatically. Additionally the subdomain doesn't have any registration procedure, this only exists in the domain.com
I wonder if there is a robust solution to my problem with the 2 identities, at the moment I need to keep at least the identity 2.2 in the domain.com.
Thanks in advance!
If you want to give the second approach a shot, try using the asp.net ticket bridge from this github repository. I used it to facilitate sharing a single identity between asp.net core and web forms authentication - just remember to sync the encryption keys... Hope this helps!
You will need to create your own 'ISecureDataFormat' implementation:
After that, use that when adding cookie authentication (still in asp.net core app):
Remember to use the same signing keys and algorithms in both applications!