I'm unable to connect to Keycloak from Loopback.
I've been trying to use the keycloak-connect lib:
https://github.com/keycloak/keycloak-nodejs-connect
This is my current server/boot/root.js
module.exports = function (server) {
var session = require('express-session');
var Keycloak = require('keycloak-connect');
var memoryStore = new session.MemoryStore();
var keycloak = new Keycloak({
store: memoryStore
});
server.use(session({
secret: 'xxx',
resave: false,
saveUninitialized: true,
store: memoryStore,
}))
server.use(keycloak.middleware({}));
server.get('/*', keycloak.protect(), function (req, resp) {
resp.send('hello');
})
};'
Seems quite simple but it gets stuck in a redirection loop.
I've also tried swapping
server.use(session
with
server.use(keycloak
But then see "Cannot read property 'keycloak-token' of undefined"
Been stuck on this for a while and tried everything. Any other ideas?
Thanks in advance!