在 OAuth 重定向中有访问令牌是不是很糟糕 URL
Is it bad to have access token in OAuth redirect URL
我正在构建一个 oauth 登录流程,我不确定我是否做错了,因为我需要通过重定向 URL 发回不记名令牌,例如 /oauth2/redirect?token= [令牌]。但是不建议通过 URL 传递令牌吗?正如在 :
中指出的那样
Don't pass bearer tokens in page URLs: Bearer tokens SHOULD NOT be passed in page URLs (for example, as query string parameters).
Instead, bearer tokens SHOULD be passed in HTTP message headers or message bodies for which confidentiality measures are taken. Browsers, web servers, and other software may not adequately secure URLs in the browser history, web server logs, and other data structures.
If bearer tokens are passed in page URLs, attackers might be able to steal them from the history data, logs, or other unsecured locations.
我一定是在整个流程中漏掉了一些东西,想了解更多关于这件事的信息。感谢任何输入!
更新
可能不正确,但这是我经过一番挖掘后的理解。传递token的三种方式:
- URL(不可取)
- 授权 header
- 请求body
但在oauth重定向用例下,选项2和3不可行。所以选项 1 是唯一可用的选项。如果确实需要,可以对token进行加密,保证安全。
我认为这仅意味着当服务器需要令牌时您不应该使用 GET
请求,而应该使用 POST
或任何合适的请求。在 GET 请求中,参数包含在 URL 中,这些参数最终会出现在日志或其他历史记录中,其他请求类型将发送与请求分开的参数 URL.
P.S。顺便说一句,如果您没有自己实施 OAuth 服务器,则不必发送包含令牌的重定向 url。
基本身份验证 header 提供一点额外的安全性,因为它需要通过 TLS:
In the case of a "Basic" authentication like shown in the figure, the exchange must happen over an HTTPS (TLS) connection to be secure.
https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication
此外,header 没有记录在浏览器历史记录等简单的地方。
根据规范,
it SHOULD NOT be used
unless it is impossible to transport the access token in the
"Authorization" request header field or the HTTP request entity-body.
我正在构建一个 oauth 登录流程,我不确定我是否做错了,因为我需要通过重定向 URL 发回不记名令牌,例如 /oauth2/redirect?token= [令牌]。但是不建议通过 URL 传递令牌吗?正如在
Don't pass bearer tokens in page URLs: Bearer tokens SHOULD NOT be passed in page URLs (for example, as query string parameters).
Instead, bearer tokens SHOULD be passed in HTTP message headers or message bodies for which confidentiality measures are taken. Browsers, web servers, and other software may not adequately secure URLs in the browser history, web server logs, and other data structures.
If bearer tokens are passed in page URLs, attackers might be able to steal them from the history data, logs, or other unsecured locations.
我一定是在整个流程中漏掉了一些东西,想了解更多关于这件事的信息。感谢任何输入!
更新
可能不正确,但这是我经过一番挖掘后的理解。传递token的三种方式:
- URL(不可取)
- 授权 header
- 请求body
但在oauth重定向用例下,选项2和3不可行。所以选项 1 是唯一可用的选项。如果确实需要,可以对token进行加密,保证安全。
我认为这仅意味着当服务器需要令牌时您不应该使用 GET
请求,而应该使用 POST
或任何合适的请求。在 GET 请求中,参数包含在 URL 中,这些参数最终会出现在日志或其他历史记录中,其他请求类型将发送与请求分开的参数 URL.
P.S。顺便说一句,如果您没有自己实施 OAuth 服务器,则不必发送包含令牌的重定向 url。
基本身份验证 header 提供一点额外的安全性,因为它需要通过 TLS:
In the case of a "Basic" authentication like shown in the figure, the exchange must happen over an HTTPS (TLS) connection to be secure.
https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication
此外,header 没有记录在浏览器历史记录等简单的地方。
根据规范,
it SHOULD NOT be used unless it is impossible to transport the access token in the "Authorization" request header field or the HTTP request entity-body.