2014-05-12 82 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