auth

package
v0.0.0-...-ed7ba4f Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package auth : Authentication package

Index

Constants

View Source
const UserKey contextKey = "userID"

UserKey is the key for the user ID in the context

Variables

This section is empty.

Functions

func ComparePasswords

func ComparePasswords(hashed string, plain []byte) bool

ComparePasswords compares a hashed password with a plain text password

func CreateJWT

func CreateJWT(secret []byte, userID int) (string, error)

CreateJWT creates a JWT token

func GetUserIDFromContext

func GetUserIDFromContext(ctx context.Context) int

GetUserIDFromContext gets the user ID from the context

func HashPassword

func HashPassword(password string) (string, error)

HashPassword hashes a password

func WithJWTAuth

func WithJWTAuth(handlerFunc http.HandlerFunc, store types.UserStore) http.HandlerFunc

WithJWTAuth adds JWT authentication to a handler

Types

This section is empty.

Jump to

Keyboard shortcuts

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