middleware

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2022 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	CacheStatusKey    = "Cache-Status"
	CacheStatusHit    = "Hit"
	CacheStatusSource = "Source"
	CacheStatusShared = "Shared "
)
View Source
var (
	ErrorTokenNotAvailable   = errors.New("token not available")
	ErrorCompareScopesFailed = errors.New("compare scopes failed")
	ErrorScopesNotCompared   = errors.New("permission denied")
)

Functions

func AccessLog

func AccessLog(ctx *gin.Context)

func Cache

func Cache(store cache.Cache, expire time.Duration) gin.HandlerFunc

func IntrospectionCheck added in v0.0.2

func IntrospectionCheck(compareScopesFunc CompareScopesFunc, endpoint, clientKey, clientSecret string, cancelFunc CancelFunc) gin.HandlerFunc

func LimitRateWithBucket

func LimitRateWithBucket(interval time.Duration, cap int64) gin.HandlerFunc

func Recover

func Recover(ctx *gin.Context)

func ServerDate

func ServerDate(ctx *gin.Context)

func StartTracing

func StartTracing(ctx *gin.Context)

func TracingClientInterceptor

func TracingClientInterceptor() grpc.UnaryClientInterceptor

func TracingServerInterceptor

func TracingServerInterceptor() grpc.UnaryServerInterceptor

TracingServerInterceptor 拦截器

func TracingServerStreamInterceptor

func TracingServerStreamInterceptor() grpc.StreamServerInterceptor

Types

type CancelFunc added in v0.0.2

type CancelFunc func(ctx *gin.Context, err error)

type CompareScopesFunc added in v0.0.2

type CompareScopesFunc func(ctx *gin.Context, scopes []string) (bool, error)

type IntrospectionReq added in v0.0.2

type IntrospectionReq struct {
	Token         string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"`
	TokenTypeHint string `protobuf:"bytes,2,opt,name=token_type_hint,json=tokenTypeHint,proto3" json:"token_type_hint,omitempty"`
	ClientKey     string `protobuf:"bytes,3,opt,name=client_key,json=clientKey,proto3" json:"client_key,omitempty"`
	ClientSecret  string `protobuf:"bytes,4,opt,name=client_secret,json=clientSecret,proto3" json:"client_secret,omitempty"`
}

type IntrospectionResp added in v0.0.2

type IntrospectionResp struct {
	Active    bool     `protobuf:"varint,1,opt,name=active,proto3" json:"active,omitempty"`
	Scopes    []string `protobuf:"bytes,2,rep,name=scopes,proto3" json:"scopes,omitempty"`
	ClientId  string   `protobuf:"bytes,3,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"`
	Username  string   `protobuf:"bytes,4,opt,name=username,proto3" json:"username,omitempty"`
	TokenType string   `protobuf:"bytes,5,opt,name=token_type,json=tokenType,proto3" json:"token_type,omitempty"`
	Exp       int64    `protobuf:"varint,6,opt,name=exp,proto3" json:"exp,omitempty"`
	Iat       int64    `protobuf:"varint,7,opt,name=iat,proto3" json:"iat,omitempty"`
	Nbf       int64    `protobuf:"varint,8,opt,name=nbf,proto3" json:"nbf,omitempty"`
	Sub       string   `protobuf:"bytes,9,opt,name=sub,proto3" json:"sub,omitempty"`
	Aud       string   `protobuf:"bytes,10,opt,name=aud,proto3" json:"aud,omitempty"`
	Iss       string   `protobuf:"bytes,11,opt,name=iss,proto3" json:"iss,omitempty"`
	Jti       string   `protobuf:"bytes,12,opt,name=jti,proto3" json:"jti,omitempty"`
}

Jump to

Keyboard shortcuts

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