Q: Policy Enforcing in node.js keycloak How do I enable policy enforcing in keycloak node.js application.I have integrated a spring boot application with keycloak.How do I do the same configurations in node.js application? Application.properties file is given below. I have to do all the same configurations in node.js.
server.port=8180
keycloak.realm = Multiple
keycloak.auth-server-url = http://localhost:8080/auth
keycloak.resource = multipleparams
keycloak.public-client=false
keycloak.enabled=true
keycloak.credentials.secret=4f0579b0-516f-4eb4-8ad1-47f0613f49cd
keycloak.ssl-required = external
#keycloak.cors=true
keycloak.use-resource-role-mappings=true

keycloak.security-constraints[0].auth-roles[0]=User
keycloak.security-constraints[0].security-collections[0].patterns[0]=/*
keycloak.policy-enforcer-config.enforcement-mode=PERMISSIVE

keycloak.policy-enforcer-config.lazy-load-paths=true
keycloak.policy-enforcer-config.paths[0].path=/multiple/*
keycloak.policy-enforcer-config.paths[0].claimInformationPointConfig.claims[location]={request.parameter['location']}
keycloak.policy-enforcer-config.paths[0].claimInformationPointConfig.claims[branch]={request.parameter['branch']}

keycloak.policy-enforcer-config.on-deny-redirect-to=/accessDenied 


A: I don't think it's officially documented yet but you can see an example of how policy enforcement is done here: https://github.com/keycloak/keycloak-nodejs-connect/blob/master/example/index.js.
app.get('/protected/resource', keycloak.enforcer(['resource:view', 'resource:write'], {
  resource_server_id: 'nodejs-apiserver'
}), function (req, res) {
  res.render('index', {
    result: JSON.stringify(JSON.parse(req.session['keycloak-token']), null, 4),
    event: '1. Access granted to Default Resource\n'
  });
});

