Skip to content
This repository has been archived by the owner on Aug 5, 2024. It is now read-only.

tumelohq/grpc-middleware

Repository files navigation

grpc-mask

GoDoc

A gRPC interceptor to mask errors.

This piece of middleware intends to stop sensitive information from being returned to calling services. Pass in a list of codes you wish to mask, and they shall all be returned as internal server errors, with no further information.

Go get

go get github.com/tumelohq/grpc-middleware/...

Usage

Have a look at the test, we spin up an entire client and server, and plug the middleware in.

Masking

This masks all internal and unknown errors, hiding potentially damaging and sensitive information.

interceptor := grpc.UnaryInterceptor(
    grpcmask.UnaryServerInterceptor(
        codes.Internal,
        codes.Unknown,
    ),
)

Mapping

This maps from one error to another. In this snippet we are mapping Unknown errors to Internal.

interceptor := grpc.UnaryInterceptor(
    grpcmap.UnaryServerInterceptor(map[codes.Code]codes.Code{
        codes.Unknown: codes.Internal,
    }),
)

About

gRPC middleware to mask errors

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •