I have been trying to use keycloak authentication and have been stuck on this for a while. This is my code
app.get('/', function(req,res){
res.render('login1');
});
app.get('/login', keycloak.protect(), function (req, res) {
res.render('dashboard', {
result: JSON.stringify(JSON.parse(req.session['keycloak-token']), null, 4)
});
});
So what is happening is, when i go to hostname/login, it redirects me to a login page of my company (we are validating the company employees with their credentials), we have a redirect uri which is http://hostname/login/* , so after keycloak.protect() executes, and user enters his credentials, it goes into infinite loop and the message on the browser is, redirected too many times.
While, ideally what should have happened is, after getting validated, it should come back to /login route, and render dashboard page we have. but it is not happening.