A NestJS gRPC wrapper for Keycloak that provides guards (`ProtectedGuard`, `RoleGuard`) and decorators (`@Protected`, `@Role`) for authenticating and authorizing gRPC calls via Keycloak. Current version 0.2.0, requires `@grpc/grpc-js`, NestJS 8, and `keycloak-connect` between 17 and 18. Configurable via environment variables. Essentially a bridge between NestJS gRPC services and Keycloak's role-based access control, with automatic token validation and permission checking. Limited documentation and active development; not widely adopted.
npm install nest-keycloak-grpcNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows minimal setup: import module, add to NestJS imports, and use @Protected() decorator with guards on a gRPC method.
Pin keycloak-connect to ^17.0.0 or ^18.0.0, check for updates to package supporting newer Keycloak.
Understand that in Keycloak, roles are sometimes permissions; use Keycloak groups for traditional roles.
Ensure to pass permission names (e.g., 'read:resource') as defined in Keycloak client scopes/permissions.
Add environment variables for required options; if more control needed, consider forking the package or using keycloak-connect directly.
Run: npm install nest-keycloak-grpc @grpc/grpc-js @nestjs/common @nestjs/core @nestjs/config keycloak-connect
Set the required environment variables in your deployment or .env file.
Add ConfigModule.forRoot() before KeycloakGrpcConnectModule in the imports array.