middleware

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2023 License: Apache-2.0 Imports: 11 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TokenInfoKey = ContextKey{}

TokenInfoKey is a key for token info in context.

Functions

func AuthMiddleware

func AuthMiddleware(verifyFn VerifyTokenFunc) func(next http.Handler) http.Handler

AuthMiddleware is a middleware that checks if the request is authorized.

func GetClientIDFromContext

func GetClientIDFromContext(ctx context.Context) (string, bool)

GetClientIDFromContext gets client id from context.

func GetTokenInfoFromContext

func GetTokenInfoFromContext(ctx context.Context) (*client.TokenInfo, bool)

GetTokenInfoFromContext gets token info from context.

func GetUserIDFromContext

func GetUserIDFromContext(ctx context.Context) (string, bool)

GetUserIDFromContext gets user id from context.

func GokitAuthMiddleware

func GokitAuthMiddleware(verifyFn VerifyTokenFunc) endpoint.Middleware

GokitAuthMiddleware is a middleware for gokit

func SetTokenInfoToContext

func SetTokenInfoToContext(ctx context.Context, info *client.TokenInfo) context.Context

SetTokenInfoToContext sets token info to context.

func VerifyJWT added in v0.1.4

func VerifyJWT(signingKey string) func(string, client.TokenType) (*client.TokenInfo, error)

VerifyJWT verifies a token and returns the token info. This function is compatible with the VerifyTokenFunc interface.

Types

type ContextKey

type ContextKey struct{}

ContextKey is a key for context.

type VerifyTokenFunc added in v0.1.4

type VerifyTokenFunc func(token string, tokenType client.TokenType) (*client.TokenInfo, error)

TokenVerifier is a function interface that can be used to verify tokens.

Jump to

Keyboard shortcuts

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