interceptor

package
v0.0.0-...-5346f80 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AuthorizationKey is metadata key
	AuthorizationKey = "authorization"
	// SessionAuthorizationType is the type in authorization header
	SessionAuthorizationType = "session"
)

Variables

View Source
var (
	// ErrMetadataNotFound is returned when metadata not found in context
	ErrMetadataNotFound = errors.New("metadata not found in context")
	// ErrInvalidAuthorizationMetadata is returned when authorization metadata is invalid
	ErrInvalidAuthorizationMetadata = status.Error(codes.InvalidArgument, "Invalid authorization metadata")
)

Functions

func ErrorUnaryServerInterceptor

func ErrorUnaryServerInterceptor() grpc.UnaryServerInterceptor

ErrorUnaryServerInterceptor returns the error handling interceptor

func GetCurrentUserID

func GetCurrentUserID(ctx context.Context) (id model.UserID, ok bool)

GetCurrentUserID returns the current user's id from context

func GetSessionID

func GetSessionID(ctx context.Context) (id string, ok bool)

GetSessionID returns the session id from context

func RecoverUnaryServerInterceptor

func RecoverUnaryServerInterceptor() grpc.UnaryServerInterceptor

RecoverUnaryServerInterceptor returns the recover interceptor

func ValidationUnaryServerInterceptor

func ValidationUnaryServerInterceptor() grpc.UnaryServerInterceptor

ValidationUnaryServerInterceptor returns the validation interceptor

Types

type Authorizator

type Authorizator struct {
	di.StoreComponent
}

Authorizator provide the authorization interceptor

func NewAuthorizator

func NewAuthorizator(store di.StoreComponent) *Authorizator

NewAuthorizator returns new Authorizator

func (*Authorizator) UnaryServerInterceptor

func (a *Authorizator) UnaryServerInterceptor() grpc.UnaryServerInterceptor

UnaryServerInterceptor returns authorization UnaryServerInterceptor

Jump to

Keyboard shortcuts

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