gpt4 book ai didi

spring-boot - POST 请求中的 Oauth2 纯文本凭据?

转载 作者:行者123 更新时间:2023-12-05 03:04:29 24 4
gpt4 key购买 nike

所以我正在 Spring Boot 2 中使用 OAuth2 尝试 Spring Security。

我将此网站作为引用:
https://dzone.com/articles/secure-spring-rest-with-spring-security-and-oauth2

设置授权服务器后,可以使用 http://localhost:8080/oauth/token 从中获取 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 Security 有什么用?我在这里做错了什么吗?大公司没有办法使用它。Spring Security 中是否有任何其他功能可以让我们防止这种情况发生?

最佳答案

您必须使用 HTTPS ( TLS ),请参阅 The OAuth 2.0 Authorization Framework

Token Endpoint

[...]
Since requests to the token endpoint result in the transmission ofclear-text credentials (in the HTTP request and response), theauthorization server MUST require the use of TLS as described inSection 1.6 when sending requests to the token endpoint.

如果您的授权服务器实现允许不安全的通信,则它不符合 OAuth2 规范。

关于spring-boot - POST 请求中的 Oauth2 纯文本凭据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52919324/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com