middleware

package
v0.1.1-rc Latest Latest
Warning

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

Go to latest
Published: Mar 23, 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(verifier TokenVerifier) func(next http.Handler) http.Handler

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

func GetTokenInfoFromContext

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

GetTokenInfoFromContext gets token info from context.

func GokitAuthMiddleware

func GokitAuthMiddleware(verifier TokenVerifier) 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.

Types

type ContextKey

type ContextKey struct{}

ContextKey is a key for context.

type IntrospectVerifier

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

IntrospectVerifier is a token verifier that verifies tokens using the introspection endpoint.

func NewIntrospectVerifier

func NewIntrospectVerifier(c oauthClient) *IntrospectVerifier

NewIntrospectVerifier creates a new IntrospectVerifier.

func (*IntrospectVerifier) VerifyToken

func (i *IntrospectVerifier) VerifyToken(tokenString string, tokenType client.TokenType) (*client.TokenInfo, error)

VerifyToken verifies a token. Implements the Verifier interface.

type JwtVerifier

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

JwtVerifier is a token verifier that verifies JWT tokens.

func NewJwtVerifier

func NewJwtVerifier(signingKey string) *JwtVerifier

NewJwtVerifier creates a new JwtVerifier.

func (*JwtVerifier) VerifyToken

func (j *JwtVerifier) VerifyToken(tokenString string, tokenType client.TokenType) (*client.TokenInfo, error)

VerifyToken verifies a token.

type TokenVerifier

type TokenVerifier interface {
	VerifyToken(token string, tokenType client.TokenType) (*client.TokenInfo, error)
}

TokenVerifier is an 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