Unique authentication for multiple projects using Entity Framework

Asked

Viewed 316 times

2

Currently in my Solution I have several ASP.NET web projects, each with the default authentication code of the Entity framework MVC (there are small customizations in the entities only). Projects share the same entities and database.

The problem is when I want to access two projects at once. For example, when accessing the "Financial" project, the "Sales" project that was already logged in, depresses.

How do I keep both projects logged in at the same time with the same user?

1 answer

3


first step is to have a cookie single for all projects, for such, edit your web.config and assign the same name to the Authentication Cookie.

<authentication mode="Forms">
  <forms name=".MY_AUTH_COOKIE_NAME" protection="All" cookieless="AutoDetect" enableCrossAppRedirects="true" path="/" />
</authentication>

But taking into account that the system is already dropping from the other systems when logging into a system, I believe that all applications are to share the same cookie, so you can skip this step.

The second point is to ensure that all applications have the same machinekey, again you will have to configure this in web.config:

<machineKey
  validationKey="336C0D608AF11D8B6613F6D235C980885F74B284254A034FA33E59E39FAB7987BD97F3DE9DEA14A1B625966642CBAC92A46DDB5EBF5CDDB44C7DB0F1CB4D5887"
  decryptionKey="A71C792B7E90217ECBCFCCE25E24466B2E52C3ED686513C2FA2418639624626F"
  validation="SHA1" decryption="AES"
/>

You can refer to the following article to learn how to generate machineKey.: Easiest way to generate Machinekey

If you are using ASP.NET Identity with Entity Framework and placed the tag "Forms-Authentication" erroneously, then read the following article.: Sharing Authentication cookies between Applications

Browser other questions tagged

You are not signed in. Login or sign up in order to post.