admin

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package admin manages the bootstrap flow and dashboard authentication.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidCredentials = errors.New("invalid username or password")

ErrInvalidCredentials is returned when a login attempt fails.

Functions

This section is empty.

Types

type Service

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

Service manages admin users and persistent dashboard sessions.

func New

func New(database *db.DB, providerSvc *provider.Service) *Service

New constructs a new admin Service.

func (*Service) Bootstrap

func (s *Service) Bootstrap(username, password string) error

Bootstrap creates the initial admin account and marks the DB as bootstrapped. Returns an error if already bootstrapped.

func (*Service) CleanupExpiredSessions

func (s *Service) CleanupExpiredSessions() error

CleanupExpiredSessions removes expired sessions from the database.

func (*Service) Login

func (s *Service) Login(username, password string, rememberMe bool) (string, time.Time, error)

Login validates credentials and returns a session token with expiration.

func (*Service) Logout

func (s *Service) Logout(token string)

Logout invalidates a session token.

func (*Service) ValidateSession

func (s *Service) ValidateSession(token string) (string, bool)

ValidateSession returns the username for a valid, non-expired session token. Auto-refreshes the session expiration on each call (sliding window).

type Session

type Session struct {
	Token      string    `json:"token"`
	Username   string    `json:"username"`
	CreatedAt  time.Time `json:"created_at"`
	ExpiresAt  time.Time `json:"expires_at"`
	RememberMe bool      `json:"remember_me"`
}

Session is a persistent dashboard session.

Jump to

Keyboard shortcuts

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