2016-07-29 80 views
0

我試圖在多個域上爲我的web應用程序實現單點登錄模式。我正要使用窗體身份驗證,但我碰到這個傳來:ASP.NET MVC 5沒有表單身份驗證的單點登錄模式

https://softwareengineering.stackexchange.com/questions/284380/is-formsauthentication-obsolete

如果它是過時的,有什麼推薦的替代解決方案?我有樣結構域:

  • account.domain.com(用戶將登錄使用此)
  • app1.domain.com
  • app2.domain.com
  • app3.domain.com

此外,我面臨的表單身份驗證的主要問題是用戶身份。我有一個自定義的用戶對象,它具有很多屬性。每次從會話中存儲和檢索對象都是一件痛苦的事情。我如何克服這個困難?

+0

我推薦https://github.com/IdentityServer/IdentityServer3以獲得良好開端。它具有我們需要的所有功能。它只是即插即用,用於單點登錄和基於令牌的身份驗證。 – Venky

回答

0

您可以使用ASP.Net身份和聲明。 您不需要使用整個ASP.Net標識隨ASP.Net模板一起提供。

[assembly: OwinStartup(typeof(YOUR_APP.Startup))]  
namespace YOUR_APP 
{ 
    public class Startup 
    { 
     public void Configuration(IAppBuilder app) 
     { 
      app.UseCookieAuthentication(new CookieAuthenticationOptions 
      { 
       AuthenticationType = "ApplicationCookie", 
       LoginPath = new PathString("/Account/Login"), 
       CookieDomain = ".domain.com", 
      }); 
     } 
    } 
} 

你可以閱讀更多如何重聚集在A primer on OWIN cookie authentication middleware for the ASP.NET developer附加索賠。

FYI:確保您在所有web.config文件中設置相同的機器密鑰,以便Cookie可以在站點之間共享。

相關問題