【发布时间】:2018-02-16 05:42:20
【问题描述】:
所以我在让 Keycloak-Connect 示例正常工作时遇到了一些问题。
基本上,我在我的虚拟机上使用 Keycloak 进行了快速路由的简单检查
(10.10.10.54:8081) 如下。
app.get('/api*', keycloak.protect(), (req, res) => res.status(200).send({
message: 'Hit API Backend!',
}));
我的 Keycloak 服务器在一个单独的虚拟机上(对于这个例子 http://keycloak.myexternaldomain.ca/auth/)
我一直在做的测试是。
RESULT=`curl --data "grant_type=password&client_secret=mysecret&client_id=account&username=myusername&password=mypassword" http://keycloak.myexternaldomain.ca/auth/realms/TEST/protocol/openid-connect/token`
这每次都会返回正确的访问令牌,
TOKEN=`echo $RESULT | sed 's/.*access_token":"//g' | sed 's/".*//g'`
将token解析成变量。
curl http://10.10.10.54:8081/api -H "Authorization: bearer $TOKEN"
仍然不断返回拒绝访问,我在一个类似的例子中尝试了这个,Keycloak-Quickstart Node Service 看看是否有更详细的错误。我收到的是
Validate grant failed
Grant validation failed. Reason: invalid token (wrong ISS)
虽然如果我稍等片刻,它会给我一个 Expired Token 错误,所以我觉得我在正确的轨道上。
所以很明显,我发出令牌的地方与预期的不匹配有什么问题吗?我可以通过 cURLing 调用从 keycloak 服务器本身获取用户凭据
curl --data "grant_type=password&token=$TOKEN&client_secret=secret&client_id=account&username=myaccount&password=mypassword" http://keycloak.myexternaldomain.ca/auth/realms/TEST/protocol/openid-connect/token/introspect
我是否误解了我应该如何使用 Keycloak,或者这是一个设置问题?
提前致谢
【问题讨论】:
标签: node.js express openid keycloak keycloak-services