【问题标题】:Silverlight user authenticationSilverlight 用户身份验证
【发布时间】:2009-07-15 20:18:07
【问题描述】:

我目前正在开发一个需要某种用户身份验证的 Silverlight 3 应用,因为从 WCF 服务中提取的数据是特定于用户的。目标受众是普通的互联网 - 所以没有 AD 需要进行身份验证。

以下是我对这种情况的一些问题:

  • 是否有支持我的框架或其他机制?
  • 您会建议在 Silverlight 应用程序中进行身份验证,还是通过表单身份验证等外部机制进行身份验证?哪个更安全?
  • 浏览器外支持怎么样?

【问题讨论】:

    标签: silverlight security authentication silverlight-3.0


    【解决方案1】:

    我使用了 ASP.NET 的身份验证。只需使用 MembershipProvider (或实现您自己的)。 那就去http://www.silverlightshow.net/items/Accessing-the-ASP.NET-Authentication-Profile-and-Role-Service-in-Silverlight.aspx看看如何暴露认证服务吧。

    然后在您的 WCF 服务中,您执行以下操作(托管在 ASP 中):

    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);
            }
    }
    

    希望对您有所帮助。

    【讨论】:

      【解决方案2】:

      我会考虑使用 ASP.NET 中存在的身份验证类。然后,您可以使用 .NET RIA 服务(甚至简单地说,WCF)与身份验证服务进行通信。

      Consider this article as a primer.

      【讨论】:

      • 您有使用此解决方案的经验吗?
      • 是的。我使用了 SL3 和 .NET RIA 服务。这是我正在开发的概念验证应用程序,但我可以远程创建和登录用户。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-04-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-24
      • 1970-01-01
      相关资源
      最近更新 更多