auth

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: MIT Imports: 16 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	SessionCookie = "dodo_session"
	CSRFCookie    = "dodo_csrf"
	SessionTTL    = 30 * 24 * 60 * 60
)

Variables

This section is empty.

Functions

func ClearSessionCookie

func ClearSessionCookie(w http.ResponseWriter, secure bool)

func HashPassword

func HashPassword(password string) (string, error)

func HashToken

func HashToken(token string) string

func IsSecure

func IsSecure(r *http.Request) bool

func IssueCSRF

func IssueCSRF(w http.ResponseWriter) string

func SetSessionCookie

func SetSessionCookie(w http.ResponseWriter, opts SessionCookieOptions)

func UserFromContext

func UserFromContext(ctx context.Context) *models.User

func VerifyPassword

func VerifyPassword(password, encoded string) bool

func WithUser

func WithUser(ctx context.Context, u *models.User) context.Context

Types

type GeneratedSession

type GeneratedSession struct {
	Full string
	Hash string
}

func GenerateSession

func GenerateSession() (GeneratedSession, error)

type GeneratedToken

type GeneratedToken struct {
	Full   string
	Prefix string
	Hash   string
}

func GenerateAPIToken

func GenerateAPIToken() (GeneratedToken, error)

type LoginRateLimiter

type LoginRateLimiter struct {
	// contains filtered or unexported fields
}

func NewLoginRateLimiter

func NewLoginRateLimiter() *LoginRateLimiter

func (*LoginRateLimiter) Allow

func (l *LoginRateLimiter) Allow(r *http.Request, email string) bool

func (*LoginRateLimiter) RecordFailure

func (l *LoginRateLimiter) RecordFailure(r *http.Request, email string)

func (*LoginRateLimiter) Reset

func (l *LoginRateLimiter) Reset(r *http.Request, email string)

type Middleware

type Middleware struct {
	Store *store.Store
}

func (*Middleware) AuthBearer

func (m *Middleware) AuthBearer(next http.Handler) http.Handler

func (*Middleware) AuthSession

func (m *Middleware) AuthSession(next http.Handler) http.Handler

func (*Middleware) CSRF

func (m *Middleware) CSRF(next http.Handler) http.Handler

func (*Middleware) RequireUser

func (m *Middleware) RequireUser(next http.Handler) http.Handler

func (*Middleware) VerifyPassword

func (m *Middleware) VerifyPassword(u *models.User, current string) error

type SessionCookieOptions

type SessionCookieOptions struct {
	Value    string
	Secure   bool
	Duration time.Duration
}

Jump to

Keyboard shortcuts

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