auth

package
v0.43.11 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ACCESS_TOKEN  = "access-token"
	REFRESH_TOKEN = "refresh-token"
)

Variables

This section is empty.

Functions

func AuthMiddleware

func AuthMiddleware(next http.Handler) http.Handler

func NewAccessToken

func NewAccessToken(claims UserClaims, secret string) (string, error)

func NewRefreshToken

func NewRefreshToken(claims jwt.StandardClaims, secret string) (string, error)

func ParseRefreshToken

func ParseRefreshToken(refreshToken string, secret string) *jwt.StandardClaims

func Router

func Router() chi.Router

Types

type AuthUser added in v0.43.7

type AuthUser struct {
	// Nickname is the user's very username.
	Nickname string `json:"nickname"`

	// Passphrase is a legacy format converted to string from a raw byte stream
	// (do not use anymore as this will be removed in future versions).
	Passphrase string `json:"passphrase"`

	// PassphraseHex is a hexadecimal representation of a passphrase (a SHA-512 checksum).
	// Use 'echo $PASS | sha512sum' for example to get the hex format.
	PassphraseHex string `json:"passphrase_hex"`
}

type UserClaims

type UserClaims struct {
	Nickname string `json:"nickname"`
	//User     models.User `json:"user"`
	jwt.StandardClaims
}

func ParseAccessToken

func ParseAccessToken(accessToken string, secret string) *UserClaims

Jump to

Keyboard shortcuts

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