feathersjs - RS256 jwt 证书不适用于 FeathersJS
问题描述
我不能让 FeathersJs 沿着 RS256 工作。我使用了生成器,但是
error: NotAuthenticated: error:0906D06C:PEM routines:PEM_read_bio:no start line
当用户使用正确的 JWT 访问令牌登录时我收到了。
"authentication": {
"secret": "whateverSecret",
"strategies": [
"jwt"
],
"path": "/authentication",
"service": "users",
"jwt": {
"header": {
"typ": "access"
},
"audience": "https://yourdomain.com",
"subject": "anonymous",
"issuer": "feathers",
"algorithm": "RS256", //set to RS256
"expiresIn": "1d"
},
"auth0": {
"clientID": "myClientid",
"clientSecret": "myClientSecret",
"successRedirect": "/",
"domain": "myDomain.auth0.com",
"scopes": [
"profile"
]
},
"cookie": {
"enabled": true,
"name": "feathers-jwt",
"httpOnly": false,
"secure": false
}
}
user.hooks.js 内部是默认生成器。
解决方案
RS256 需要更多的配置才能工作。此问题提到确保您的私钥 ( secret
) 是有效证书并包含正确的换行符。
在验证 JWT 时,您可能还必须自定义 JWT 验证程序以将公钥作为签名密钥传递。