Silverlight用户身份验证
我目前正在开发需要某种用户身份验证的Silverlight 3应用程序,因为从WCF服务提取的数据是特定于用户的。目标受众是普通互联网,因此没有可供认证的广告 以下是我对这种情况提出的一些问题:Silverlight用户身份验证,silverlight,security,authentication,silverlight-3.0,Silverlight,Security,Authentication,Silverlight 3.0,我目前正在开发需要某种用户身份验证的Silverlight 3应用程序,因为从WCF服务提取的数据是特定于用户的。目标受众是普通互联网,因此没有可供认证的广告 以下是我对这种情况提出的一些问题: 是否有一个框架或其他机制可以支持我 您建议在Silverlight应用程序内进行身份验证,还是通过forms auth等外部机制进行身份验证?哪个更安全 浏览器外支持如何 我会考虑使用ASP.NET中存在的验证类。然后,您可以使用.NETRIA服务(甚至简单地说,WCF)与身份验证服务通信 我使用了
- 是否有一个框架或其他机制可以支持我
- 您建议在Silverlight应用程序内进行身份验证,还是通过forms auth等外部机制进行身份验证?哪个更安全李>
- 浏览器外支持如何
我会考虑使用ASP.NET中存在的验证类。然后,您可以使用.NETRIA服务(甚至简单地说,WCF)与身份验证服务通信
我使用了ASP.NET的身份验证。只需使用MembershipProvider(或实现您自己的)。 然后转到查看如何公开身份验证服务 然后在WCF服务中,执行以下操作(托管在ASP中):
希望能有所帮助。您有使用此解决方案的经验吗?有。我使用了SL3和.NETRIA服务。这是我正在开发的一个概念验证应用程序,但我可以远程创建和登录用户。
public class MyWCFService : IMyWCFService
{
// retrieve your UserId from the MembershipProvider
private int GetUserId()
{
MembershipUser user = Membership.GetUser();
int userId = (int)user.ProviderUserKey;
return userId;
}
// check if user is authenticated
private bool IsUserAuthenticated()
{
return HttpContext.Current.User.Identity.IsAuthenticated;
}
public void Subscribe()
{
if (!IsUserAuthenticated())
{
throw new SecurityException("You must be authenticated to be able to use this service.");
}
int userId = GetUserId();
DoStuff(userId);
}
}