firewall

package
v0.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 11, 2020 License: MIT Imports: 7 Imported by: 0

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidRole = status.Errorf(codes.PermissionDenied, "Invalid role")
)

Functions

func AppendIdentityToOutgoingStreamContext

func AppendIdentityToOutgoingStreamContext() grpc.StreamClientInterceptor

AppendIdentityToOutgoingStreamContext appends identity to outgoing context

https://godoc.org/google.golang.org/grpc#WithStreamInterceptor

conn, err := grpc.Dial("localhost:5000", grpc.WithStreamInterceptor(AppendIdentityToOutgoingStreamContext()))

func AppendIdentityToOutgoingUnaryContext

func AppendIdentityToOutgoingUnaryContext() grpc.UnaryClientInterceptor

AppendIdentityToOutgoingUnaryContext appends identity to outgoing context

https://godoc.org/google.golang.org/grpc#WithUnaryInterceptor

conn, err := grpc.Dial("localhost:5000", grpc.WithUnaryInterceptor(AppendIdentityToOutgoingUnaryContext()))

func GrantAccessForStreamRequest

func GrantAccessForStreamRequest(role identity.Role) grpc.StreamServerInterceptor

GrantAccessForStreamRequest returns error if Identity not set within context or user does not have required role

https://godoc.org/google.golang.org/grpc#StreamInterceptor
opts := []grpc.ServerOption{
	grpc.StreamInterceptor(GrantAccessForStreamRequest("admin")),
}

s := grpc.NewServer(opts...) pb.RegisterGreeterServer(s, &server{})

func GrantAccessForUnaryRequest

func GrantAccessForUnaryRequest(role identity.Role) grpc.UnaryServerInterceptor

CheckAccessForUnaryRequest returns error if Identity not set within context or user does not have required role

https://godoc.org/google.golang.org/grpc#UnaryInterceptor
opts := []grpc.ServerOption{
	grpc.UnaryInterceptor(CheckAccessForUnaryRequest("admin")),
}

s := grpc.NewServer(opts...) pb.RegisterGreeterServer(s, &server{})

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL