通过 HTTPS 发送时,rest api 查询参数是否安全?

Are rest api query parameters secure when sending via HTTPS?

我公开了以下 rest api 方法

[OperationContract]
[WebInvoke(Method = "GET", UriTemplate = "/GetStuff?userName={userName}&password={password}&howMany={howMany}", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
Things[] GetStuff(string userName, string password, int howMany);

作为查询字符串的一部分通过 https 发送用户名和密码是否安全,或者是否有更好的身份验证方法?

不,他们不是。正如评论中提到的,如果有人窃取了您的日志,他们就可以访问所有查询参数。 (在你的情况下,敏感信息)。

查询参数(正确地)用于非幂等请求(如 GET)以过滤您的结果集。

另一方面,header 值是安全的。这就是为什么我们通常发送 authentication/authorization headers 而不是查询参数。

查看 authorization header 中的示例。

The HTTP Authorization request header contains the credentials to authenticate a user agent with a server, usually, but not necessarily, after the server has responded with a 401 Unauthorized status and the WWW-Authenticate header.