U
U
Uncle Seryozha2016-07-12 21:48:45
ASP.NET
Uncle Seryozha, 2016-07-12 21:48:45

How to implement SSO on subdomains?

There is one project consisting of several smaller projects. Each project is a web application, all hosted on different subdomains (eg auth.project.local, admin.project.local, portal.project.local etc.). The authorization project uses ASP.NET Identity. How to make it so that you can log in to auth.project.local once and authorization is no longer required for admin and portal. Tried to change cookieDomain - does not help.

app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = "ProjectCookie",
                LoginPath = new PathString("/"),
                CookieName = "AppSession",
                CookieDomain = ".project.local",
                Provider = new CookieAuthenticationProvider
                {
                    OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<UserManager<User, long>, User, long>(
                        validateInterval: TimeSpan.FromMinutes(10),
                        regenerateIdentityCallback: (manager, user) => user.GenerateUserIdentityAsync(manager),
                        getUserIdCallback: id => id.GetUserId<long>()
                   )
                }

There is also one more question: how to make it so that on a subdomain, for example, portal.project.local, if the user is not authorized, a redirect to auth.project.local is carried out with a returnUrl referring to portal.project.local?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
#
#algooptimize #bottize, 2016-07-12
@littledragon

stackoverflow.com/questions/19166599/asp-net-ident...
Is the config the same everywhere?
Write the full path instead of / in the loginpaf, I myself have not tried it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question