保护Web API /令牌端点

Ang*_*ieM 3 api ssl access-token web asp.net-web-api

我有一个Web API项目,遵循此处概述的基本帐户身份验证过程:http://www.asp.net/web-api/overview/security/individual-accounts-in-web-api.我的问题是我应该用SSL(或其他东西)保护/ Token enpoint吗?否则,对"myURL/Token"的API调用只是通过明文发送,其用户名和密码在其正文中?

我在Web API SSL上阅读了这篇文章:http://www.asp.net/web-api/overview/security/working-with-ssl-in-web-api但我不知道我应该把它放在哪里[RequireHttps]属性,因为/ Token enpoint实际上不是控制器动作.

感谢您提供的任何指导!

Saa*_*nch 5

是的,您应该将令牌端点设置为安全.

Setup.Auth.csOAuthurizationServerOptions下的文件中,您可以指定Token端点是否需要SSL.

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

AllowInsecureHttp将迫使网址是SSL与否.