问题描述
我正在使用Node.JS(快速)和一个名为 keycloak-connect 连接到密钥斗篷服务器.
当我按照描述的那样实现默认机制来保护路由时:
I'm using Node.JS (express) and an NPM called keycloak-connect to connect to a keycloak server.
When I'm implementing the default mechanism as described to protect a route:
app.get( '/about', keycloak.protect(), function(req,resp) {
resp.send( 'Page: ' + req.params.page + '<br><a href="/logout">logout</a>');
} );
我确实引用了密钥斗篷,但是出现以下错误:"无效的参数:redirect_uri "
I do get referred to keycloak, but with following error: "Invalid parameter: redirect_uri"
我的查询字符串是:(用于演示的是xx)
https://xx.xx.xx.xx:8443/auth/realms/master/protocol/openid-connect/auth?client_id=account&state=aa11b27a-8a0b-4a3b-89dc-cb8a303dbde8&redirect_uri=http%3A%2F%2Flocalhost%3A3002%2Fabout%3Fauth_callback%3D1&response_type=code
My query string is: (xx for demonstration)
https://xx.xx.xx.xx:8443/auth/realms/master/protocol/openid-connect/auth?client_id=account&state=aa11b27a-8a0b-4a3b-89dc-cb8a303dbde8&redirect_uri=http%3A%2F%2Flocalhost%3A3002%2Fabout%3Fauth_callback%3D1&response_type=code
我的keycloak.json是:(用于演示的是xx)
My keycloak.json is: (xx for demonstration)
{
"realm": "master",
"realm-public-key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwS00kUaH6OoERNSkFUwxEBxx2SsqmHu9oVQiPs6nlP9fNQm0cK2lpNPphbLzooZL6kivaC4VzXg20F3zY7jRDc4U/XHgXjZVZUXxJ0NeCI5ESDo00EV9xh9XL3xvXslmG0YLWpywtQSYc+XcGDkz87edokbHQIIlQc2sgoVKIKpajZyrI5wnyMhL8JSk+Mdo2T9DeNnZxPkauiKBwWFJReBO51gsoZ49cbD39FRa8pLi8W0TtXoESIf/eGUSdc3revVFR7cjzHUzxF0p0WrLsTA1aBCLkt8yhnq88NqcKsW5mkxRmhLdw20ODTdsmRtm68rjtusMwifo/dZLJ9v5eQIDAQAB",
"auth-server-url": "https://xx.xx.xx.xx:8443/auth",
"ssl-required": "external",
"resource": "account",
"credentials": {
"secret": "9140d4e6-ed05-4899-a3c0-a9cf94ab407d"
},
"use-resource-role-mappings": true
}
密钥斗篷配置:
推荐答案
我猜您是在客户端设置"标签中为您的客户端URL添加了端口.
I guess you added a port to your client URLs in your client settings tab.
例如
root url: https://demo.server.biz:443/cxf
只需卸下端口
root url: https://demo.server.biz/cxf
Valid Redirect URIs
和Web Origins
这篇关于获取“无效参数:redirect_uri".尝试使用KeyCloak进行NODE.JS身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!