Reputation: 5844
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>');
} );
I do get referred to keycloak, but with following error: "Invalid parameter: redirect_uri"
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
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
}
keycloak configuration:
Upvotes: 10
Views: 16245
Reputation: 1
I do not know if you will continue with the doubt but I had to configure the node server with https calls in the following way:
var fs = require('fs');
var https = require('https');
.....
const HOST = 'your_site.com';
const PORT = process.env.PORT || 3001;
const key = fs.readFileSync('./certs/private.pem');
const cert = fs.readFileSync('./certs/public.pem');
const https_options = {
key: key,
cert: cert
};
var serverKeycloak = https.createServer(https_options, appKeyCloak);
serverKeycloak.listen(PORT, HOST);
...
then the adapter automatically send to keycloak the https
Upvotes: 0
Reputation: 1706
I guess you added a port to your client URLs in your client settings tab.
e.g.
root url: https://demo.server.biz:443/cxf
just remove the port
root url: https://demo.server.biz/cxf
the same goes for Valid Redirect URIs
and Web Origins
Upvotes: 17