go-api-boilerplate: github.com/vardius/go-api-boilerplate/pkg/grpc/middleware/firewall Index | Files

package firewall

import "github.com/vardius/go-api-boilerplate/pkg/grpc/middleware/firewall"

Index

Package Files

firewall.go

Variables

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

func AppendIdentityToOutgoingStreamContext Uses

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 Uses

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 Uses

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 Uses

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{})

Package firewall imports 7 packages (graph) and is imported by 1 packages. Updated 2020-08-04. Refresh now. Tools for package owners.