appx

package
v0.0.0-...-c870998 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2025 License: Apache-2.0 Imports: 31 Imported by: 1

Documentation

Index

Constants

View Source
const TRACER_GCP = Tracer("gcp")
View Source
const TRACER_JAEGER = Tracer("jaeger")

Variables

This section is empty.

Functions

func AuthInfoMiddleware

func AuthInfoMiddleware(key any) func(http.Handler) http.Handler

AuthInfoMiddleware loads claim from context and attach the user info.

func AuthMiddleware

func AuthMiddleware(providers []JWTProvider, key any, optional bool) (func(http.Handler) http.Handler, error)

func ContextMiddleware

func ContextMiddleware(key, value any) func(http.Handler) http.Handler

func ContextMiddlewareBy

func ContextMiddlewareBy(c func(http.ResponseWriter, *http.Request) context.Context) func(http.Handler) http.Handler

func GetRequestIDFromContext

func GetRequestIDFromContext(ctx context.Context) string

func GraphQLHandler

func GraphQLHandler(c GraphQLHandlerConfig) http.Handler

func InitTracer

func InitTracer(ctx context.Context, conf *TracerConfig) io.Closer

func RequestIDMiddleware

func RequestIDMiddleware() func(http.Handler) http.Handler

Types

type AuthInfo

type AuthInfo struct {
	Token         string
	Sub           string
	Iss           string
	Name          string
	Email         string
	EmailVerified *bool
}

type GraphQLHandlerConfig

type GraphQLHandlerConfig struct {
	Schema          graphql.ExecutableSchema
	Dev             bool
	Context         func(r *http.Request) context.Context
	ComplexityLimit int
}

type JWTMultipleValidator

type JWTMultipleValidator []JWTValidator

func NewJWTMultipleValidator

func NewJWTMultipleValidator(providers []JWTProvider) (JWTMultipleValidator, error)

func (JWTMultipleValidator) ValidateToken

func (mv JWTMultipleValidator) ValidateToken(ctx context.Context, tokenString string) (interface{}, error)

ValidateToken tries to validate the token with each validator concurrently NOTE: the last validation error only is returned

type JWTProvider

type JWTProvider struct {
	ISS     string
	JWKSURI *string
	AUD     []string
	ALG     *string
	TTL     *int
}

type JWTValidator

type JWTValidator interface {
	ValidateToken(ctx context.Context, tokenString string) (interface{}, error)
}

type JWTValidatorWithError

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

JWTValidatorWithError wraps "validator.Validator and attach iss and aud to the error message to make it easy to track errors.

func NewJWTValidatorWithError

func NewJWTValidatorWithError(
	keyFunc func(context.Context) (interface{}, error),
	signatureAlgorithm validator.SignatureAlgorithm,
	issuerURL string,
	audience []string,
	opts ...validator.Option,
) (*JWTValidatorWithError, error)

func (*JWTValidatorWithError) ValidateToken

func (v *JWTValidatorWithError) ValidateToken(ctx context.Context, token string) (interface{}, error)

type NamedURI

type NamedURI struct {
	Name string
	URI  string
}

func (*NamedURI) UnmarshalText

func (n *NamedURI) UnmarshalText(text []byte) error

type Tracer

type Tracer string

type TracerConfig

type TracerConfig struct {
	Name         string
	Tracer       Tracer
	TracerSample float64
}

Jump to

Keyboard shortcuts

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