auth

package
v0.0.0-...-21415ec Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2023 License: AGPL-3.0-or-later Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const ClientNameKey = "client_name"
View Source
const TokenExpiryLengthHours = 8
View Source
const (
	UserKey = "user"
)

Variables

View Source
var ErrSessionError = errors.New("session error")
View Source
var ErrTokenMissing = errors.New("token missing")

Functions

func APIMiddleware

func APIMiddleware(cfg ConfigService, db DatabaseService) echo.MiddlewareFunc

func GenerateJWTString

func GenerateJWTString(jwtSecret string, username string) (string, error)

func LoadUsernameFromSession

func LoadUsernameFromSession(cfg ConfigService, c echo.Context) (string, error)

func Middleware

func Middleware(cfg ConfigService, db DatabaseService) echo.MiddlewareFunc

func ProxyAuthMiddleware

func ProxyAuthMiddleware(cfg ConfigService, db DatabaseService) echo.MiddlewareFunc

func SaveUsernameToSession

func SaveUsernameToSession(cfg ConfigService, c echo.Context, username string) error

func ValidateJWTString

func ValidateJWTString(jwtSecret string, tokenString string) (*string, error)

Types

type Claims

type Claims struct {
	jwt.StandardClaims
	Username string `json:"username"`
}

type ConfigService

type ConfigService interface {
	JWTSecret() string
	ProxyAuthUsernameHeader() string
	ProxyAuthNameHeader() string
}

type DatabaseService

type DatabaseService interface {
	FetchUserByUsername(ctx context.Context, username string) (dbx.User, error)
	CreateUser(ctx context.Context, arg dbx.CreateUserParams) (dbx.User, error)
}

Jump to

Keyboard shortcuts

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