2014-05-12 85 views
3

我有一個Web API項目,它遵循以下概述的基本帳戶驗證過程:http://www.asp.net/web-api/overview/security/individual-accounts-in-web-api。我的問題是,我應該使用SSL(還是其他)來保護/ Token入口點?否則,對「myURL/Token」的API調用僅通過明文形式發送,其正文中包含用戶名和密碼?保護Web API /令牌端點

我在Web API SSL閱讀這篇文章:http://www.asp.net/web-api/overview/security/working-with-ssl-in-web-api但我不知道我應該放置[RequireHttps]屬性的位置,因爲/ Token enpoint並不是一個真正的控制器動作。

感謝您提供任何指導!

+0

[如何在ASP.Net應用程序中使用HTTPS]的可能重複(http://stackoverflow.com/questions/539732/how-to-use-https-in-an-asp-net-application) – jww

回答

5

是的,你應該讓令牌端點保持安全。

在OAuthurizationServerOptions下的Setup.Auth.cs文件中,您可以指定爲令牌終點需要SSL還是不需要。

OAuthOptions = new OAuthAuthorizationServerOptions 
    { 
    TokenEndpointPath = new PathString("/Token"), 
    Provider = new ApplicationOAuthProvider(PublicClientId), 
    AuthorizeEndpointPath = new PathString("/api/Account/ExternalLogin"), 
    AccessTokenExpireTimeSpan = TimeSpan.FromMinutes(20), 
    AllowInsecureHttp = false 
    }; 

AllowInsecureHttp將迫使網址是SSL與否。

+1

感謝您的幫助。我必須失明:)。 – AngieM