defaults

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package defaults provides the core Aegis route mounting with OpenAPI documentation.

This package exists as a sub-package of router to break the circular import between router and plugins/openapi:

defaults → router       (for Router interface and MountRoutes)
defaults → plugins/openapi (for Doc/Route types)
plugins/openapi → router  (for MountRoutes Router param)

No cycle: router does NOT import defaults, plugins/openapi does NOT import defaults.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MountRoutes

func MountRoutes(r router.Router, authService *core.AuthService, config *core.AuthConfig, prefix string, rateLimiter *core.RateLimiter)

MountRoutes mounts all core Aegis authentication routes and registers their OpenAPI documentation.

This function:

  1. Registers HTTP handlers directly
  2. Calls openapi.Doc() for each route to register API documentation

Routes mounted:

POST   {prefix}/login           - Email+password login (if enabled)
POST   {prefix}/signup          - Email+password registration (if enabled)
POST   {prefix}/logout          - Invalidate session (auth required)
GET    {prefix}/session         - Get current session with user data (auth required)
GET    {prefix}/sessions        - List all user sessions (auth required)
DELETE {prefix}/sessions/{id}   - Revoke specific session (auth required)
DELETE {prefix}/sessions        - Revoke all sessions (auth required)
POST   {prefix}/session/refresh - Refresh session with refresh token

Parameters:

  • r: HTTP router implementing the Router interface
  • authService: Core authentication service with all sub-services
  • config: Authentication configuration (controls which routes are enabled)
  • prefix: URL prefix for all routes (e.g., "/auth/default")
  • rateLimiter: Optional rate limiter for public endpoints (can be nil)

Types

type Handlers

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

Handlers provides HTTP handlers for core Aegis authentication routes.

All handlers have been made private (lowercase) to encourage programmatic use of the underlying core services. This struct serves as a mounting point for the router.

func NewHandlers

func NewHandlers(auth *core.AuthService) *Handlers

NewHandlers creates a new Handlers instance with the given AuthService.

Jump to

Keyboard shortcuts

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