package
0.0.0-20220822164348-1fb92f6f5a50
Repository: https://github.com/vardius/go-api-boilerplate.git
Documentation: pkg.go.dev

# README

firewall GoDoc

Package firewall allow to guard grpc server

Download:

go get -u github.com/vardius/go-api-boilerplate/pkg/grpc/security/firewall

Package firewall allow to guard grpc server

# Functions

AppendIdentityToOutgoingStreamContext appends identity to outgoing context https://godoc.org/google.golang.org/grpc#WithStreamInterceptor conn, err := grpc.Dial("localhost:5000", grpc.WithStreamInterceptor(AppendIdentityToOutgoingStreamContext())).
AppendIdentityToOutgoingUnaryContext appends identity to outgoing context https://godoc.org/google.golang.org/grpc#WithUnaryInterceptor conn, err := grpc.Dial("localhost:5000", grpc.WithUnaryInterceptor(AppendIdentityToOutgoingUnaryContext())).
GrantAccessForStreamRequest returns error if Identity not set within context or user does not have required permission https://godoc.org/google.golang.org/grpc#StreamInterceptor opts := []grpc.ServerOption{ grpc.StreamInterceptor(GrantAccessForStreamRequest(identity.PermissionUserRead)), } s := grpc.NewServer(opts...) pb.RegisterGreeterServer(s, &server{}).
CheckAccessForUnaryRequest returns error if Identity not set within context or user does not have required permission https://godoc.org/google.golang.org/grpc#UnaryInterceptor opts := []grpc.ServerOption{ grpc.UnaryInterceptor(CheckAccessForUnaryRequest(identity.PermissionUserRead)), } s := grpc.NewServer(opts...) pb.RegisterGreeterServer(s, &server{}).
SetIdentityFromStreamRequest updates context with identity https://godoc.org/google.golang.org/grpc#StreamInterceptor opts := []grpc.ServerOption{ grpc.UnaryInterceptor(SetIdentityFromStreamRequest()), } s := grpc.NewServer(opts...) pb.RegisterGreeterServer(s, &server{}).
SetIdentityFromUnaryRequest updates context with identity https://godoc.org/google.golang.org/grpc#UnaryInterceptor opts := []grpc.ServerOption{ grpc.UnaryInterceptor(SetIdentityFromUnaryRequest()), } s := grpc.NewServer(opts...) pb.RegisterGreeterServer(s, &server{}).