How to do one authentication for two different applications on MVC5?

Asked

Viewed 27 times

-1

Hey there, guys. I have two ASP.NET MVC5 applications on the same server on the same site. I’m trying to make one authentication valid for both projects. I have already set a cookie name for both applications, even though it didn’t work.

I’m trying to share the same login cookie to two differents MVC5 Projects.

I’ve already set the same cookie name to Both Projects, but thats doesnt work.

app.UseCookieAuthentication(new CookieAuthenticationOptions
        {
            AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
            LoginPath = new PathString("/Account/Login"),
            CookieName = "OrienteIntegrada",
            Provider = new CookieAuthenticationProvider
            {
                // Permite que o aplicativo valide o carimbo de segurança quando o usuário efetuar login.
                // Este é um recurso de segurança que é usado quando você altera uma senha ou adiciona um login externo à sua conta.  
                OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
                    validateInterval: TimeSpan.FromMinutes(30),
                    regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
            }
        });

Applications are accessed like this: server/test and server/teste2;

I have to configure something in IIS or in another class related to Identity?

Thanks in advance.

1 answer

1

After setting the machineKey in the web.config file, it worked.

<configuration>
<system.web>
    <machineKey decryptionKey="F6722806843145965513817CEBDECBB1F94808E4A6C0B2F2,IsolateApps" validationKey="C551753B0325187D1759B4FB055B44F7C5077B016C02AF674E8DE69351B69FEFD045A267308AA2DAB81B69919402D7886A6E986473EEEC9556A9003357F5ED45,IsolateApps" />
</system.web>

Browser other questions tagged

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