auths

package
v2.7.5 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecryptData added in v2.3.0

func DecryptData(ep *Encipherer, typ DecryptType, src string, res any) error

func EncryptData added in v2.3.0

func EncryptData(ep *Encipherer, typ EncryptType, src any) (string, error)

Types

type DecryptType added in v2.3.0

type DecryptType int
const (
	DecryptTypeAes       DecryptType //1-aes解密
	DecryptTypeRsaPrikey             //2-rsa私钥解密
	DecryptTypeRsaPubkey             //2-rsa公钥解密
)

type Encipherer

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

func NewEncipherer

func NewEncipherer(options ...Option) *Encipherer

func (*Encipherer) AesCbcDecrypt

func (e *Encipherer) AesCbcDecrypt(data string) ([]byte, error)

func (*Encipherer) AesCbcEncrypt

func (e *Encipherer) AesCbcEncrypt(data []byte) (string, error)

func (*Encipherer) GetAesSecretKey

func (e *Encipherer) GetAesSecretKey() (string, string)

func (*Encipherer) RsaPrikeyDecrypt

func (e *Encipherer) RsaPrikeyDecrypt(data string) ([]byte, error)

func (*Encipherer) RsaPrikeyEncrypt

func (e *Encipherer) RsaPrikeyEncrypt(data []byte) (string, error)

func (*Encipherer) RsaPubkeyDecrypt

func (e *Encipherer) RsaPubkeyDecrypt(data string) ([]byte, error)

func (*Encipherer) RsaPubkeyEncrypt

func (e *Encipherer) RsaPubkeyEncrypt(data []byte) (string, error)

type EncryptType added in v2.3.0

type EncryptType int
const (
	EncryptTypeAes       EncryptType //1-aes加密
	EncryptTypeRsaPrikey             //2-rsa私钥加密
	EncryptTypeRsaPubkey             //2-rsag公钥加密
)

type JwtData

type JwtData interface {
	UserId() int64
}

type JwtMiddleware

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

func NewJwtMiddleware

func NewJwtMiddleware(user JwtUser) *JwtMiddleware

func (*JwtMiddleware) GetAuthor

func (g *JwtMiddleware) GetAuthor() *jwt.GinJWTMiddleware

func (*JwtMiddleware) IdentityHandler

func (g *JwtMiddleware) IdentityHandler(c *gin.Context) interface{}

func (*JwtMiddleware) PayloadFunc

func (g *JwtMiddleware) PayloadFunc(data interface{}) jwt.MapClaims

func (*JwtMiddleware) Verifier

func (g *JwtMiddleware) Verifier(data interface{}, c *gin.Context) bool

type JwtUser

type JwtUser interface {
	Authenticator(c *gin.Context) (interface{}, error)
	// User can define own Unauthorized func.
	Unauthorized(c *gin.Context, code int, message string)
	// User can define own LoginResponse func.
	LoginResponse(c *gin.Context, code int, message string, time time.Time)
	// User can define own LogoutResponse func.
	LogoutResponse(c *gin.Context, code int)
	// User can define own RefreshResponse func.
	RefreshResponse(c *gin.Context, code int, message string, time time.Time)
}

type Option

type Option func(e *Encipherer)

func WithAesIv

func WithAesIv(aesIv string) Option

func WithAesKey

func WithAesKey(aesKey string) Option

func WithRsaPriKey

func WithRsaPriKey(priKey string) Option

func WithRsaPubKey

func WithRsaPubKey(pubKey string) Option

func WithSerializer added in v2.6.8

func WithSerializer(serializer serialize.Serializer) Option

Jump to

Keyboard shortcuts

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