auth

package
v0.0.0-...-8274928 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const BearerPrefix = "Bearer "
View Source
const KeyUuid = "UUID"

Variables

This section is empty.

Functions

func Auth

func Auth(c *gin.Context)

func PasswordHash

func PasswordHash(password string, salt string) (string, string)

func SetJwtSalt

func SetJwtSalt(salt string) bool

SetJwtSalt Can only be set once

func VerifyJwt

func VerifyJwt(tokenStr string) (uuid string, valid bool)

Types

type JwtClaims

type JwtClaims struct {
	Uuid string    `json:"uuid"`
	Nbf  time.Time `json:"nbf"`
	Iat  time.Time `json:"iat"` // For record only, not for verification
	Exp  time.Time `json:"exp"`
	Rand string    `json:"rand"`
}

func (*JwtClaims) Valid

func (c *JwtClaims) Valid() error

type JwtToken

type JwtToken struct {
	Token *jwt.Token
}

func NewJwt

func NewJwt(uuid string, exp time.Duration) *JwtToken

func ParseJwt

func ParseJwt(tokenStr string) (jwtToken *JwtToken, err error)

func (*JwtToken) Claims

func (j *JwtToken) Claims() *JwtClaims

func (*JwtToken) String

func (j *JwtToken) String() string

func (*JwtToken) StringWithBearerPrefix

func (j *JwtToken) StringWithBearerPrefix() string

func (*JwtToken) Valid

func (j *JwtToken) Valid() bool

Jump to

Keyboard shortcuts

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