auth

package
v0.0.0-...-06ea526 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2024 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidAuthToken    = errors.New("invalid auth token")
	ErrInvalidHash         = errors.New("the encoded hash is not in the correct format")
	ErrInvalidRefreshToken = errors.New("invalid refresh token")
	ErrIncorrectPassword   = errors.New("incorrect password")
	ErrIncompatibleVersion = errors.New("incompatible version of argon2")
	ErrUnknownClaimsType   = errors.New("unknown claims type")
)

Functions

func CreateNewSession

func CreateNewSession(ctx context.Context, username, password string) (authToken, refreshToken string, err error)

func CreateNewUser

func CreateNewUser(ctx context.Context, user util.User, password string) (authToken, refreshToken string, err error)

func EndSession

func EndSession(ctx context.Context, oldRefreshToken string) (err error)

func RefreshSession

func RefreshSession(ctx context.Context, oldRefreshToken string) (authToken, refreshToken string, err error)

Types

type AuthUser

type AuthUser struct {
	ID         int64  `json:"id"`
	Email      string `json:"email"`
	Username   string `json:"username"`
	Nickname   string `json:"nickname"`
	IsVerified bool   `json:"is_verified"`
	Avatar     string `json:"avatar"`
}

func GetUser

func GetUser(w http.ResponseWriter, r *http.Request) (user AuthUser)

Jump to

Keyboard shortcuts

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