【问题标题】:MongoDB Atlas api returns two headersMongoDB Atlas api 返回两个标头
【发布时间】:2019-08-05 10:37:06
【问题描述】:

MongoDB Atlas API(生成程序化 API 密钥)返回两个标头

验证成功后,它会返回两个响应 401 的标头和另一个响应 200(带数据)的标头

curl -i -u "<username>:<apiKey>" --digest "https://cloud.mongodb.com/api/atlas/v1.0/groups/<group-id>/databaseUsers/admin/<dbusername>?pretty=true"

HTTP/2 401 
www-authenticate: Digest realm="MMS Public API", domain="",     nonce="/xGsFcHm0TT69utb5fj0AQGKV85ihlY7", algorithm=MD5, qop="auth", stale=false
content-type: application/json
date: Mon, 05 Aug 2019 10:28:16 GMT
content-length: 106

HTTP/2 401 
www-authenticate: Digest realm="MMS Public API", domain="",     nonce="cpvM848g/8JJfZ42OyaD7xt4365jP3kI", algorithm=MD5, qop="auth", stale=false
content-type: application/json
date: Mon, 05 Aug 2019 10:28:16 GMT
content-length: 106

{
  "reason" : "Unauthorized",
  "error" : 401,
  "detail" : "You are not authorized for this resource."
}

它应该只返回一个标题而不是两个

【问题讨论】:

    标签: mongodb mongodb-atlas


    【解决方案1】:

    这就是摘要式身份验证的工作原理

    请阅读以下 wiki 文章中名为 Example with explanation 的部分

    https://en.wikipedia.org/wiki/Digest_access_authentication

    另请注意,文档中未提及,但用户名是公钥,密码是编程 API 密钥的私钥。

    【讨论】:

      猜你喜欢
      • 2019-10-27
      • 2019-08-18
      • 1970-01-01
      • 2018-06-13
      • 2016-12-25
      • 2021-06-30
      • 2020-10-17
      • 1970-01-01
      • 2021-11-14
      相关资源
      最近更新 更多