POST 请求中的 Oauth2 纯文本凭据?
Oauth2 plain text credentials in POST request?
所以我正在尝试 Spring 在 Spring Boot 2 中使用 OAuth2 的安全性。
我将此网站作为参考:
https://dzone.com/articles/secure-spring-rest-with-spring-security-and-oauth2
设置授权服务器后,可以使用 http://localhost:8080/oauth/token 端点通过传递 POST 请求从中获取令牌。
让我感到不安的是 POST 请求必须将我的用户名和密码作为纯文本
POST /oauth/token HTTP/1.1
Host: localhost:8080
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="grant_type"
password
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="username"
admin
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="password"
password
------WebKitFormBoundary7MA4YWxkTrZu0gW--
这不是一个非常大的安全威胁吗?
难道从客户端到服务器的每个路由器都能够看到 POST 正文的内容吗?
现在要解决这个问题,假设我在 javascript 中使用客户端对称加密算法来加密密码。由于所有客户端都将获得相同的加密算法,因此沿途的路由器可以对称地解码我的密码。这还不够好。
如果我必须将凭据作为纯文本传递,那么 Spring 安全性有什么用?
我在这里做错了什么吗?大公司没有办法使用它。
Spring 安全性中是否有任何其他设施可以让我们防止这种情况发生?
您必须使用 HTTPS (TLS), see The OAuth 2.0 Authorization Framework
Token Endpoint
[...]
Since requests to the token endpoint result in the transmission of
clear-text credentials (in the HTTP request and response), the
authorization server MUST require the use of TLS as described in
Section 1.6 when sending requests to the token endpoint.
如果您的授权服务器实现允许不安全的通信,则它不符合 OAuth2 规范。
所以我正在尝试 Spring 在 Spring Boot 2 中使用 OAuth2 的安全性。
我将此网站作为参考:
https://dzone.com/articles/secure-spring-rest-with-spring-security-and-oauth2
设置授权服务器后,可以使用 http://localhost:8080/oauth/token 端点通过传递 POST 请求从中获取令牌。
让我感到不安的是 POST 请求必须将我的用户名和密码作为纯文本
POST /oauth/token HTTP/1.1
Host: localhost:8080
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="grant_type"
password
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="username"
admin
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="password"
password
------WebKitFormBoundary7MA4YWxkTrZu0gW--
这不是一个非常大的安全威胁吗? 难道从客户端到服务器的每个路由器都能够看到 POST 正文的内容吗?
现在要解决这个问题,假设我在 javascript 中使用客户端对称加密算法来加密密码。由于所有客户端都将获得相同的加密算法,因此沿途的路由器可以对称地解码我的密码。这还不够好。
如果我必须将凭据作为纯文本传递,那么 Spring 安全性有什么用? 我在这里做错了什么吗?大公司没有办法使用它。 Spring 安全性中是否有任何其他设施可以让我们防止这种情况发生?
您必须使用 HTTPS (TLS), see The OAuth 2.0 Authorization Framework
Token Endpoint
[...]
Since requests to the token endpoint result in the transmission of clear-text credentials (in the HTTP request and response), the authorization server MUST require the use of TLS as described in Section 1.6 when sending requests to the token endpoint.
如果您的授权服务器实现允许不安全的通信,则它不符合 OAuth2 规范。