auth

package module
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: MIT Imports: 4 Imported by: 2 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.

README

modules/auth

Official Lesstruct module: authentication — credential login with JWT sessions, self-service registration, email verification, password reset, and first-login bootstrap, all behind async-tolerant admin handlers.

Layout (module template)

module.go            # kernel.Module (single registry-facing file)
api/                 # browser handlers (agent UPPER_SNAKE envelope) + seams
domain/              # Auth/Login/Registration/Verification/PasswordReset services (4.0c)
admin/               # admin-shell manifest (empty: auth is chrome)
testutil/            # kernel fixture for module tests

Handlers

The api.AuthHandler serves login, registration, verification, and password reset; api.FirstLoginHandler serves setup status and completion. Both write through kernel/httpx (byte-identical to the pre-module internal/api/response writers by contract). Login mints JWTs through the TokenIssuer seam (verification stays core-side in middleware); account emails flow through the Mailer seam; admin notifications through the NotificationRecorder seam (core adapter persists them with identical escaped text). Core mounts the handlers explicitly through structural AuthSurface/FirstLoginSurface interfaces in routes.go, so routes stay module-agnostic and paths never drift.

Documentation

Overview

Package auth is the official authentication module: credential login, self-service registration, email verification, password reset, and first-login bootstrap over the admin handler surface.

Index

Constants

View Source
const Name = "auth"

Name is the registry key for this module.

View Source
const Version = "0.1.0"

Version is the module version reported via Module.Version.

Variables

This section is empty.

Functions

This section is empty.

Types

type Module

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

Module is the auth kernel module.

func New

func New(opts ...Option) *Module

New builds the module, adopting the composition root's wiring. The handlers are built once here so every realm serves the same instances.

func (*Module) AdminManifest

func (m *Module) AdminManifest() kernel.AdminExtensionManifest

AdminManifest declares this module's admin-shell extensions. Auth is chrome, not a navigation surface: login and setup screens render outside the shell.

func (*Module) AuthHandler

func (m *Module) AuthHandler() *api.AuthHandler

AuthHandler exposes the auth handler for core mounting. Core mounts it explicitly (rather than via RouteProvider) because the surface spans the public auth group, where a single RegisterRoutes call cannot express the per-route anonymous contract.

func (*Module) FirstLoginHandler

func (m *Module) FirstLoginHandler() *api.FirstLoginHandler

FirstLoginHandler exposes the first-login handler for core mounting. Same explicit-mount deviation as the auth surface.

func (*Module) Init

func (m *Module) Init(_ kernel.Kernel) error

Init wires the module. The handlers are already built by New; Init only validates presence.

func (*Module) Name

func (m *Module) Name() string

Name returns the registry key.

func (*Module) Optional

func (m *Module) Optional() []string

Optional lists soft dependencies. There are none: every collaborator is either adopted or required.

func (*Module) Requires

func (m *Module) Requires() []string

Requires lists hard dependencies. Authentication resolves users, matching the retired wrapper edge.

func (*Module) Shutdown

func (m *Module) Shutdown() error

Shutdown releases module resources. There are none beyond memory.

func (*Module) Version

func (m *Module) Version() string

Version returns the module version.

type Option

type Option func(*Module)

Option configures a Module. The composition root supplies every option; direct construction without options yields a standalone module whose handlers serve nil services (they must not be invoked unconfigured).

func WithAdminApprovalRequired

func WithAdminApprovalRequired() Option

WithAdminApprovalRequired configures the admin-approval registration mode on the auth handler.

func WithAuthService

func WithAuthService(service *authdomain.AuthService) Option

WithAuthService adopts the default-credentials auth service.

func WithBlockedEmailChecker

func WithBlockedEmailChecker(checker api.BlockedEmailChecker) Option

WithBlockedEmailChecker adopts the blocked-email checker.

func WithCredentialPolicy

func WithCredentialPolicy(policy authdomain.CredentialPolicy) Option

WithCredentialPolicy adopts the credential policy for the first-login handler's password and email validation.

func WithFailedLoginStore

func WithFailedLoginStore(store authdomain.FailedLoginAttemptRepo) Option

WithFailedLoginStore adopts the failed-login store for the lockout-email flow. The domain FailedLoginAttemptRepo covers it directly.

func WithFirstLoginService

func WithFirstLoginService(service *authdomain.FirstLoginService) Option

WithFirstLoginService adopts the first-login service.

func WithLogger

func WithLogger(logger kernel.Logger) Option

WithLogger attaches the module logger. Without one handler failures are dropped (discard sink).

func WithLoginService

func WithLoginService(service *authdomain.LoginService) Option

WithLoginService adopts the login service.

func WithMFADeliverer

func WithMFADeliverer(deliverer api.MFACodeDeliverer) Option

WithMFADeliverer adopts the login-code deliverer (email in production, the dev log sink only under DEV_MODE without SMTP).

func WithMFAService

func WithMFAService(service *authdomain.MFAService) Option

WithMFAService adopts the login MFA service.

func WithMailer

func WithMailer(mailer api.Mailer) Option

WithMailer adopts the account mailer.

func WithNotificationRecorder

func WithNotificationRecorder(recorder api.NotificationRecorder) Option

WithNotificationRecorder adopts the admin notification recorder.

func WithPasswordResetService

func WithPasswordResetService(service *authdomain.PasswordResetService) Option

WithPasswordResetService adopts the password-reset service.

func WithRegistrationService

func WithRegistrationService(service *authdomain.RegistrationService) Option

WithRegistrationService adopts the registration service.

func WithTokenIssuer

func WithTokenIssuer(issuer api.TokenIssuer) Option

WithTokenIssuer adopts the JWT issuer for login sessions.

func WithUserStore

func WithUserStore(store api.UserStore) Option

WithUserStore adopts the user store for handler-level lookups.

func WithVerificationService

func WithVerificationService(service *authdomain.VerificationService) Option

WithVerificationService adopts the verification service.

Directories

Path Synopsis
Package admin owns this module's admin-shell manifest: the declarative UI the single admin SPA renders for authentication.
Package admin owns this module's admin-shell manifest: the declarative UI the single admin SPA renders for authentication.
api
Package testutil provides the kernel fixture module tests run against.
Package testutil provides the kernel fixture module tests run against.

Jump to

Keyboard shortcuts

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