Nestjs - GrpcAuthGuard
GrpcAuthGuard is an agnostic guard for NestJS optimized for grpc scope. You can inject you personalized auth service to customize it. This guard read from metadatas on a grpc call.
The library contains also a decorator, called GRPCUser, that inject the user loaded into your service.
Installation
npm i --save nestjs-guard-grpc
Usage
On you controller use the guard GrpcAuthGuard
@GRPCUser() is a decorator that inject the user loaded from the authentication.
Now you need to build your own auth service that implement the IAuthService interface. For example if you want to use a jwt token you can use the follow service:
;;;;;
Finally inject your own service into GrpcAuthGuard
Testing
The following code is a base grpc client. How you can see the token jwt is part of the metadata field.
; ; ; ;call.on'status',;