nest-keycloak-grpc
v0.2.0
Published
NestJS gRPC wrapper for Keycloak
Downloads
3
Maintainers
Readme
Nest-Keycloak
Keycloak Connect GRPC wrapper for NestJS
Configuration
This library is configured using environment variables
- KEYCLOAK_BASE_URL
- KEYCLOAK_REALM
- KEYCLOAK_CLIENT_ID
- KEYCLOAK_CLIENT_SECRET
Usage
import { KeycloakGrpcConnectModule } from 'nest-keycloak-grpc';
import { ConfigModule } from '@nestjs/config';
@Module({
imports: [
ConfigModule,
KeycloakGrpcConnectModule,
],
// ...
})
export class ExampleModule {}
Add KeycloakGrpcConnectModule
and ConfigModule
to your modules imports
array.
Guards
- ProtectedGuard
- RoleGuard
These guards should be used in the order above according to the Binding Guards documentation.
Decorators
- Mandate Authentication - MethodDecorator
@Protected()
Depends on theProtectedGuard
- Check Role - RouteParamDecorator
@Role('permission')
Depends on theRoleGuard
NB: Roles on Keycloak are actually implemented as permissions. Permissions mean multiple different things in Keycloak. Keycloak User Groups can be used in place of the common idea of Roles.
Todo
- Make all keycloak options env-configurable (e.g token audience verification )