簡體   English   中英

使用WCF服務進行身份驗證移動應用程序功能調用

[英]Authentication mobile apps function call with WCF Service

我剛剛開始為我的移動應用程序創建WCF服務。 目前,我在單一解決方案中有多個項目。

  • 主網站項目
  • Edmx項目
  • WCF lib項目

認證功能

     public List<AuthenticateModel> Authenticate(string UserName, string Password)
            {
                SimpleMembershipInitializer _initialized = new SimpleMembershipInitializer();
                bool validate = System.Web.Security.Membership.ValidateUser(UserName, Password);
                AuthenticateModel model = new AuthenticateModel();
                if (validate)
                {
                    model.userID = IDUser
                }
                Return model;
            }

現在,我怎么知道同一位登錄用戶正在調用另一個函數。 如果這里有什么方法可以將會話保持為Web? 還是通過任何證書或令牌進行驗證(如果是,則如何通過令牌並實現它)?

    [OperationContract]
    [WebInvoke(UriTemplate = "GetAllrecords/?paramId={paramId}", Method = "GET", ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)]
    List<SomeModel> GetAllrecords(int paramId)
    {
         Return something; // Return requested data
    }

任何幫助將不勝感激。

如果有時間,您應該閱讀

http://www.codeproject.com/Articles/630986/Cross-Platform-Authentication-With-ASP-NET-Web-API

它着重於Web API,但討論了令牌的使用。

在我們的身份驗證方法中,我們返回生成的令牌,該令牌以用戶和角色保留在服務器上。

Webclient(在我們的示例中是使用angularjs構建的)使用請求標頭中的令牌組成請求。 然后,我們在網絡api中檢查每個請求,提取令牌並將其與持久令牌進行比較。

解決方案很多,我們不是很安全,但是對我們來說已經足夠了。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM