firewall

package
v0.0.1-0...-6deec57 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2022 License: MIT Imports: 7 Imported by: 0

README

firewall GoDoc

Package firewall allow to guard grpc server

Download:

go get -u github.com/bradishungry/go-api-learning/pkg/grpc/security/firewall

Package firewall allow to guard grpc server

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

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(permission identity.Permission) grpc.StreamServerInterceptor

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

func GrantAccessForUnaryRequest

func GrantAccessForUnaryRequest(permission identity.Permission) grpc.UnaryServerInterceptor

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

func SetIdentityFromStreamRequest

func SetIdentityFromStreamRequest() grpc.StreamServerInterceptor

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

func SetIdentityFromUnaryRequest

func SetIdentityFromUnaryRequest() grpc.UnaryServerInterceptor

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

Types

This section is empty.

Jump to

Keyboard shortcuts

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