auth

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package auth implements single-user session authentication using a signed cookie. The move to multi-user later replaces the credential check and the uid baked into the cookie; the cookie mechanism stays the same.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

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

Manager issues and validates session cookies, and authenticates API tokens.

func New

func New(cfg *config.Config, c *crypto.Cipher) *Manager

func (*Manager) APIAuthed

func (m *Manager) APIAuthed(r *http.Request) bool

APIAuthed reports whether the request is authenticated by either a valid session cookie or a valid API bearer token.

func (*Manager) Authed

func (m *Manager) Authed(r *http.Request) bool

Authed reports whether the request carries a valid session.

func (*Manager) Check

func (m *Manager) Check(user, pass string) bool

Check verifies admin credentials.

func (*Manager) Clear

func (m *Manager) Clear(w http.ResponseWriter)

Clear removes the session cookie (logout).

func (*Manager) Require

func (m *Manager) Require(next http.Handler) http.Handler

Require is middleware that 401s API requests lacking a valid session cookie or API bearer token.

func (*Manager) SetSession

func (m *Manager) SetSession(w http.ResponseWriter, uid uint)

SetSession writes the session cookie after a successful login.

func (*Manager) WithDB

func (m *Manager) WithDB(db *gorm.DB) *Manager

WithDB attaches a database so API requests can authenticate via bearer token.

Jump to

Keyboard shortcuts

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