auth

package
v0.0.0-...-4f9d474 Latest Latest
Warning

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

Go to latest
Published: May 29, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const AuthzAudience = "skt.authz.changaolee.com"

AuthzAudience 定义 jwt 中 audience 字段的值.

Variables

View Source
var (
	ErrMissingKID    = errors.New("Invalid token format: missing kid field in claims")
	ErrMissingSecret = errors.New("Can not obtain secret information from cache")
)

Functions

func KeyExpired

func KeyExpired(expires int64) bool

KeyExpired 检查一个 key 是否过期.

Types

type AutoStrategy

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

AutoStrategy 定义了可自动选择的身份认证策略. 支持在 Basic 和 JWT Bearer 认证间切换.

func NewAutoStrategy

func NewAutoStrategy(basic, jwt middleware.AuthStrategy) AutoStrategy

NewAutoStrategy 基于给定的 Basic 和 JWT Bearer 认证策略创建一个 AutoStrategy.

func (AutoStrategy) AuthFunc

func (a AutoStrategy) AuthFunc() gin.HandlerFunc

type BasicStrategy

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

BasicStrategy 定义 Basic 认证策略.

func NewBasicStrategy

func NewBasicStrategy(compare CompareFunc) BasicStrategy

NewBasicStrategy 基于给定的 compare 方法创建一个 Basic 认证策略.

func (BasicStrategy) AuthFunc

func (b BasicStrategy) AuthFunc() gin.HandlerFunc

AuthFunc 定义 Basic 认证策略作为 Gin 中间件.

type CacheStrategy

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

CacheStrategy 定义 Cache 认证策略(基于缓存实现的 JWT Bearer 认证).

func NewCacheStrategy

func NewCacheStrategy(get getSecretFunc) CacheStrategy

NewCacheStrategy 基于给定的 get 方法创建一个 Cache 认证策略.

func (CacheStrategy) AuthFunc

func (cache CacheStrategy) AuthFunc() gin.HandlerFunc

type CompareFunc

type CompareFunc func(username string, password string) bool

type JWTStrategy

type JWTStrategy struct {
	ginjwt.GinJWTMiddleware
}

func NewJWTStrategy

func NewJWTStrategy(gjwt ginjwt.GinJWTMiddleware) JWTStrategy

NewJWTStrategy 创建一个 JWT Bearer 认证策略.

func (JWTStrategy) AuthFunc

func (j JWTStrategy) AuthFunc() gin.HandlerFunc

AuthFunc 定义 JWT Bearer 认证策略作为 Gin 中间件.

type Secret

type Secret struct {
	Username string
	ID       string
	Key      string
	Expires  int64
}

Jump to

Keyboard shortcuts

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