简体   繁体   中英

Single sign-on for Silverlight 4 app and web application

I have 2 different applications, one is in Silverlight and another is a web application.

I need single sign-on for both.

Scenario is like: any user logged-in to the Silverlight application then there is a menu in that app to open the other web application in logged-in mode.

Both applications have different databases but the user name and password are same in both.

I am using the WCF services for the silverlight application.

Can anybody suggest a solution?

In my opinion you should use one DB for keep current session's token for each logged user. In this case isn't important where you logged you will take log-in token from this db.

I'm assuming you are using ASP.NET and Forms/other authentication and the Silverlight app is from the same web server.

first look at this link and the Silverlight Business application template from Visual Studio:http://msdn.microsoft.com/en-us/library/ee942449(v=VS.91).aspx

A more manual approach could include writing a WCF service that returns or sets the "UserToken" that you store in session on a successful login.

// the wcf service needs these attributes
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)]

// a manual approach: successful login, create a webservice method to call from Silverlight to set the authentication
HttpContext.Current.Session.Add("currentUserToken", userToken);
FormsAuthentication.SetAuthCookie(this.EmailAddressUserControl1.EmailAddressTextBox.Text, false);

Forms Authentication will take care of logging you out on ASP.Net requests, but you'll have to handle session timeouts one service requests yourself.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM