I have integrated keycloak with the backend application written in express - nodejs. now either for testing purposes or as a roll-out feature I want to disable keycloak from my API endpoints.
keycloak is initialised as below:
const session = require('express-session');
const Keycloak = require('keycloak-connect');
const memoryStore = new session.MemoryStore();
const kcConfig = {
clientId: config.KEYCLOAK_CLIENT_ID,
bearerOnly: true,
serverUrl: config.KEYCLOAK_SERVER_URL,
realm: config.KEYCLOAK_REALM,
realmPublicKey: config.KEYCLOAK_REALM_PUBLICKEY,
enabled: false
};
app.use(session({
secret: config.KEYCLOAK_SESSION_SECRET,
resave: false,
saveUninitialized: true,
store: memoryStore
}));
keycloak = new Keycloak({ store: memoryStore }, kcConfig);
app.use(keycloak.middleware());
app.get("/api/test",keycloak.protect('realm:app-user'), async (req, res) => {}
I was going through keycloak documentation and I can see the property for Java can be set as keycloak.enabled=false;
So I have added enabled:false
under kcConfig
but no luck. Therefore - I am looking for a property which can be used to toggle on and off keycloak from the application.