auth

package
v1.3.41 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2024 License: MIT Imports: 22 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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