grpc

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrMissingReqData returns when the certain required data is missing
	ErrMissingReqData = status.Errorf(codes.Unauthenticated, "Missing required data")
	// ErrMissingAccessToken returns when access token is missing from the request data
	ErrMissingAccessToken = status.Errorf(codes.Unauthenticated, "Access token is required")
	// ErrInvalidAccessToken returns when the access token provided is invalid
	ErrInvalidAccessToken = status.Errorf(codes.Unauthenticated, "Access token is invalid")
	// ErrAccessDenied returns when the data provided is not sufficient to provide access to the requested method
	ErrAccessDenied = status.Errorf(codes.PermissionDenied, "Access denied")
)

Functions

func GetCurrentUserID added in v0.0.3

func GetCurrentUserID(ctx context.Context) (string, error)

GetCurrentUserID returns the current user's ID

func GetCurrentUserRole added in v0.0.3

func GetCurrentUserRole(ctx context.Context) (string, error)

GetCurrentUserRole returns the current user's role

func MetadataByKey

func MetadataByKey(md metadata.MD, key string) (string, error)

MetadataByKey returns the value of the first metadata with the provided key

func SetSessionData added in v0.0.3

func SetSessionData(ctx context.Context, kv ...string)

SetSessionData sets the data to be stored in the session store. The values are passed as a map of (string) key => (string) value

Types

type AuthInterceptor

type AuthInterceptor struct {
	// contains filtered or unexported fields
}

AuthInterceptor is a grpc interceptor for authentication and authorization

func NewAuthInterceptor

func NewAuthInterceptor(jwtManager *manager.JWT) *AuthInterceptor

NewAuthInterceptor returns a new auth interceptor

func (*AuthInterceptor) Stream

func (interceptor *AuthInterceptor) Stream() grpc.StreamServerInterceptor

Stream returns a server interceptor function to authenticate and authorize stream RPC

func (*AuthInterceptor) Unary

func (interceptor *AuthInterceptor) Unary() grpc.UnaryServerInterceptor

Unary returns a server interceptor function to authenticate and authorize unary RPC

Jump to

Keyboard shortcuts

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