Documentation
¶
Index ¶
- func ContextGetToken(ctx context.Context) (*jwt.Token, error)
- func ContextWithToken(ctx context.Context, token *jwt.Token) context.Context
- func MustContextGetToken(ctx context.Context) *jwt.Token
- type Issuer
- type Middleware
- func (m *Middleware) HandleHTTP(h http.Handler) http.HandlerFunc
- func (m *Middleware) UnaryClientInterceptor(ctx context.Context, method string, req, reply interface{}, ...) error
- func (m *Middleware) UnaryServerInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, ...) (resp interface{}, err error)
- type Validator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContextGetToken ¶
ContextGetToken tries to get the token from the context it returns an error if the token is missing or invalid
It DOES NOT validate the token claims or signature That would require the public key and should have been handled by the process that set the token originally
func ContextWithToken ¶
ContextWithToken adds the given token to the given context
Types ¶
type Issuer ¶
type Issuer struct {
// contains filtered or unexported fields
}
START ISSUER OMIT Issuer handles JWT issuing
type Middleware ¶
type Middleware struct { // embed the validator to make token calls cleaner Validator }
Middleware handles all jwt parsing and validation automatically when used
func NewMiddleware ¶
func NewMiddleware(publicKeyPath string) (*Middleware, error)
NewMiddleware creates a new middleware that validates using the given public key file
func (*Middleware) HandleHTTP ¶
func (m *Middleware) HandleHTTP(h http.Handler) http.HandlerFunc
func (*Middleware) UnaryClientInterceptor ¶
func (m *Middleware) UnaryClientInterceptor(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error
func (*Middleware) UnaryServerInterceptor ¶
func (m *Middleware) UnaryServerInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error)
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
START VALIDATOR OMIT Validator does parsing and validation of JWT token
func NewValidator ¶
NewValidator returns a new validator by parsing the given file path as a ed25519 public key