session

package
v0.29.1 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2026 License: CC0-1.0 Imports: 9 Imported by: 0

Documentation

Overview

Package session implements the panel's HMAC-signed cookie.

Cookie value is base64(json(payload)) + "." + base64(hmac-sha256). We sign payload bytes (not the encoded form) so encoding tweaks don't void existing cookies.

Index

Constants

View Source
const (
	CookieName = "prosa_panel"
	// DefaultTTL mirrors INTENT §6: 30 days.
	DefaultTTL = 30 * 24 * time.Hour
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

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

Manager produces and validates cookies. Construct once with the HMAC key + secure flag and reuse across handlers.

func NewManager

func NewManager(hexKey string, secure bool) *Manager

NewManager builds a Manager. hexKey is the hex-encoded HMAC secret; fall back to using its raw bytes if it isn't actually hex.

func (*Manager) Clear

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

func (*Manager) FromRequest

func (m *Manager) FromRequest(r *http.Request) (Session, bool)

FromRequest returns the verified Session attached to r, or false when the cookie is missing / tampered / expired.

func (*Manager) Issue

func (m *Manager) Issue(w http.ResponseWriter, email string) error

Issue mints a fresh signed cookie for email and writes it to w.

type Session

type Session struct {
	Email     string    `json:"email"`
	IssuedAt  time.Time `json:"iat"`
	ExpiresAt time.Time `json:"exp"`
	CSRF      string    `json:"csrf"`
}

Session is the payload we sign into the cookie. Email is the verified owner email; everything else is derived.

Jump to

Keyboard shortcuts

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