I am trying to secure a REST API using keycloak authorization mechanisms.
My API is in NodeJS with express.
Say I have this API:
http://www.example.com/api/v1/houses
The endpoint supports GET/POST/PUT/DELETE. A house has a name and an owner:
{
name: 'myhouse',
owner: 'smith'
}
Everybody can view houses. You can also create houses, and automatically become the owner. Only the owner can delete a house. It's similar to the photoz example.
Using Keycloak Connect in bearer-only mode works with nodeJS express:
router.get('/houses*', keycloakProtect(), myHandler)
But this provides only Authentication, not Authorization. Basically it just checks that you provided the correct token. KeycloakProtect provides a rudimentary authorization mechanism, based only on role names. However, I would like to use the full power of client authorizations (with resources, scopes and policies)... Is there any NodeJS support for that? If no, how to use the Keycloak API for that?