auth

package
v0.0.0-...-23bc443 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidCredential error = errors.New("invalid credential")

Functions

func IssueAccessToken

func IssueAccessToken(userId uint) (string, error)

func Logout

func Logout(db *sql.DB) error

func Register

func Register(db *sql.DB, request *requests.AuthRegister) (*models.User, error)

Types

type IssuedToken

type IssuedToken struct {
	AccessToken string `json:"access_token"`
}

func Login

func Login(db *sql.DB, request *requests.AuthLogin) (*IssuedToken, error)

type JWTContextKey

type JWTContextKey string
const UserIdContextKey JWTContextKey = "user_id"

type JwtClaims

type JwtClaims struct {
	UserId uint `json:"user_id"`
	jwt.StandardClaims
}

type JwtClaimsContent

type JwtClaimsContent struct {
	UserId uint   `json:"user_id"`
	Exp    uint64 `json:"exp"`
}

func VerifyAndParseAccessToken

func VerifyAndParseAccessToken(token string) (*JwtClaimsContent, error)

Jump to

Keyboard shortcuts

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