为什么使用 Auth0 的 CouchDB JWT 身份验证对我不起作用?
Why is the CouchDB JWT Authentication with Auth0 not working for me?
我一直在尝试将 CouchDB 中的 JWT 身份验证方法与 Auth0 一起使用。按照 https://docs.couchdb.org/en/stable/api/server/authn.html#jwt-authentication 的文档,我在我的 default.ini 文件中添加了 authentication_handlers 并像这样配置 jwt_auth 和 jwt_keys:
[jwt_auth]
; List of claims to validate
required_claims = alg,kid,sub
[jwt_keys]
rsa:<kid> = -----BEGIN PUBLIC KEY-----\n
<PublicKey>
\n-----END PUBLIC KEY-----\n
我从 Auth0 (https://[myDomain]/.well-known/jwks.json) 得到了孩子和 public 密钥。现在,当我请求 JWT 令牌并将其添加到针对 _session 端点的 CouchDB 请求时,我得到以下响应:
{
"ok": true,
"userCtx": {
"name": null,
"roles": []
},
"info": {
"authentication_handlers": [
"cookie",
"default"
]
}
}
我觉得我在 default.ini 文件中做错了什么。谁能帮帮我?
您似乎没有在 CouchDB 中启用 JWT 身份验证。我这样说是因为:
"info": {
"authentication_handlers": [
"cookie",
"default"
]
}
还应该包括"jwt"
.
为此,CouchDB 配置中的 [chttpd]
块应包括:
{chttpd_auth, jwt_authentication_handler}
此外,我认为您不需要列出这三个必需的声明。前几天我才开始工作,因为 Couch 需要这些,所以你不需要列出它们。事实上,当我列出其中任何一个时,我收到了关于“重复要求”之类的错误。
此外,请确保 JWT 中没有 iss
(颁发者)声明。这个问题可能会在未来的版本中得到解决,但截至撰写本文时,要使其与 Couch 3.1 一起使用,我必须明确确保没有 iss
声明。
更多详情in this issue。
所以这很尴尬,但我的问题是我没有输入 PEM 格式的 public 密钥,所以我所要做的就是使用这个命令:
curl https://[myDomain]/pem -s | openssl x509 -pubkey -noout
获取 PEM 格式并使用它来配置 CouchDB。
我一直在尝试将 CouchDB 中的 JWT 身份验证方法与 Auth0 一起使用。按照 https://docs.couchdb.org/en/stable/api/server/authn.html#jwt-authentication 的文档,我在我的 default.ini 文件中添加了 authentication_handlers 并像这样配置 jwt_auth 和 jwt_keys:
[jwt_auth]
; List of claims to validate
required_claims = alg,kid,sub
[jwt_keys]
rsa:<kid> = -----BEGIN PUBLIC KEY-----\n
<PublicKey>
\n-----END PUBLIC KEY-----\n
我从 Auth0 (https://[myDomain]/.well-known/jwks.json) 得到了孩子和 public 密钥。现在,当我请求 JWT 令牌并将其添加到针对 _session 端点的 CouchDB 请求时,我得到以下响应:
{
"ok": true,
"userCtx": {
"name": null,
"roles": []
},
"info": {
"authentication_handlers": [
"cookie",
"default"
]
}
}
我觉得我在 default.ini 文件中做错了什么。谁能帮帮我?
您似乎没有在 CouchDB 中启用 JWT 身份验证。我这样说是因为:
"info": {
"authentication_handlers": [
"cookie",
"default"
]
}
还应该包括"jwt"
.
为此,CouchDB 配置中的 [chttpd]
块应包括:
{chttpd_auth, jwt_authentication_handler}
此外,我认为您不需要列出这三个必需的声明。前几天我才开始工作,因为 Couch 需要这些,所以你不需要列出它们。事实上,当我列出其中任何一个时,我收到了关于“重复要求”之类的错误。
此外,请确保 JWT 中没有 iss
(颁发者)声明。这个问题可能会在未来的版本中得到解决,但截至撰写本文时,要使其与 Couch 3.1 一起使用,我必须明确确保没有 iss
声明。
更多详情in this issue。
所以这很尴尬,但我的问题是我没有输入 PEM 格式的 public 密钥,所以我所要做的就是使用这个命令:
curl https://[myDomain]/pem -s | openssl x509 -pubkey -noout
获取 PEM 格式并使用它来配置 CouchDB。