auth

package
v1.3.39 Latest Latest
Warning

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

Go to latest
Published: May 28, 2024 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComparePassword

func ComparePassword(hash, password string) bool

func EncSign

func EncSign(bytes []byte, enc string) string

func HashPassword

func HashPassword(password string) (string, error)

func ParseSignFormat

func ParseSignFormat(fstr string) []string

func RandString

func RandString(n int) string

func UrlSign

func UrlSign(url string, fields map[string]string, format []string,
	algo, enc, secret string, expire int) (string, error)

func ValidateSign

func ValidateSign(url string, format []string, enc, secret string) error

Types

type EchoAuth

type EchoAuth struct {
	Jwt         *JwtAuth
	StoreClaims []string
	TokenQuery  string //If set, it will try to get the query token from this query param
}

func (*EchoAuth) Auth

func (e *EchoAuth) Auth(c echo.Context) error

func (*EchoAuth) AuthHandler

func (e *EchoAuth) AuthHandler(handle func(c echo.Context) error) func(c echo.Context) error

type JwtAuth

type JwtAuth struct {
	Conf JwtConf
}

func NewJwtAuth

func NewJwtAuth(secret []byte) *JwtAuth

func (*JwtAuth) GenToken

func (a *JwtAuth) GenToken(claims typex.JsonMap) (string, error)

func (*JwtAuth) Verify

func (a *JwtAuth) Verify(tokenString string) (*JwtToken, error)

type JwtConf

type JwtConf struct {
	Secret []byte
	Method jwt.SigningMethod
}

type JwtToken

type JwtToken struct {
	Method    jwt.SigningMethod
	Header    typex.JsonMap
	Claims    typex.JsonMap
	Signature string
}

type SignCfg

type SignCfg struct {
	SignEnable bool     `json:"signEnable,omitempty"`
	SignFormat []string `json:"signFormat,omitempty"`
	SignSecret string   `json:"signSecret,omitempty"`
	SignAlgo   string   `json:"signAlgo,omitempty"`
	SignEnc    string   `json:"signAlgo,omitempty"`
	SignExpire int      `json:"signExpire,omitempty"`
}

func ParseSignCfg

func ParseSignCfg(prefix string) *SignCfg

func (*SignCfg) Merge

func (sc *SignCfg) Merge(sc2 *SignCfg)

func (*SignCfg) Validate

func (sc *SignCfg) Validate() error

Jump to

Keyboard shortcuts

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