jwt

package
v0.0.0-...-745208b Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2022 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ContextKey grpc.Key = "jwt"
)

Variables

View Source
var (
	ErrMissingBearer error = errors.New("missing token")
	ErrBadAuthString error = errors.New("bad authorization string")
)

Functions

func StreamInterceptor

func StreamInterceptor(aservice AuthenticationService) grpc.StreamServerInterceptor

StreamInterceptor will use the authentication service to get the data from JWT token, and put it into a new context, that will be passed to the interceptors chain

func UnaryInterceptor

func UnaryInterceptor(aservice AuthenticationService) grpc.UnaryServerInterceptor

UnaryInterceptor will use the authentication service to get the data from JWT token, and put it into a new context, that will be passed to the interceptors chain

Types

type AuthenticationService

type AuthenticationService interface {
	// Data return the parsed jwt token data field, usually known as session.
	Data(signedToken string) (any, error)

	// Allow is used to check if the current path is an unprotected endpoint. If so, allow it.
	Allow(path string) bool
}

Jump to

Keyboard shortcuts

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