Documentation
¶
Overview ¶
Package server wires together the HTTP server, TLS configuration, middleware chain, and route registration for The Vault. It provides graceful shutdown on SIGTERM/SIGINT and configures TLS 1.3 as the minimum version when enabled.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Deps ¶
type Deps struct {
Config *config.Config
AuthSvc *service.AuthService
TokenSvc *service.TokenService
MFASvc *service.MFAService
Keys map[string]*rsa.PublicKey
Cache cache.Cache
AuditLog *audit.Logger
// Repositories
Users repository.UserRepository
Devices repository.DeviceRepository
Tokens repository.RefreshTokenRepository
Clients repository.ClientRepository
TOTP repository.TOTPRepository
WebAuthn repository.WebAuthnRepository
BackupCodes repository.BackupCodeRepository
PwHistory repository.PasswordHistoryRepository
Social repository.SocialAccountRepository
// LoginCountries backs the new-location notice and, because that data is
// location data about a person, the erasure cascade. The auth service takes it
// directly from main; erasure needs it here.
LoginCountries repository.LoginCountryRepository
// ServiceDocs backs the service-scoped JSON document store. Nil unless
// VAULT_SVCDOC_ENABLED, in which case the routes are not mounted at all.
ServiceDocs repository.ServiceDocumentRepository
// Mint backs POST /mint. Built in main rather than here because
// service.NewMintService returns an error on an unsafe mint policy and
// setupRoutes cannot fail; nil unless minting is configured.
Mint *service.MintService
// Email
EmailSender email.Sender
// Mailer applies per-app white-label branding/templates. Optional: when nil,
// handlers fall back to their constructor-built global mailer.
Mailer *email.Mailer
// OAuth2 providers
OAuthProviders map[string]oauth2.Provider
// Master key for TOTP encryption
MasterKey []byte
HMACSecret []byte
Pepper string
// HIBP breach check
HIBP *service.HIBPClient
HIBPEnabled bool
// Readiness
ReadyDeps *handler.ReadyzDeps
// Honeypot (nil unless profile=honeypot)
HoneypotAlerter *honeypot.Alerter
// IPIntel is the IP-intelligence table used to raise rate-limit scrutiny on
// VPN/hosting/Tor addresses (never to block them). Nil leaves the auth
// limiters at their default weight, so the feature is opt-in.
IPIntel *ipintel.DB
// Metrics (nil unless VAULT_METRICS_ENABLED=true)
Metrics *metrics.Collector
// KeyStore (nil unless VAULT_KEY_ROTATION_DB=true)
KeyStore *keystore.KeyStore
// KMS backs the POST /kms/unwrap envelope-unwrap oracle (life42 data-root
// re-root). Nil unless a KMS root key is configured (KMS_ROOT_KEY_FILE), in
// which case the endpoint is not mounted at all.
KMS *kms.Service
// Identity & Blob storage
Identity repository.IdentityRepository
Blobs repository.BlobRepository
// Account-recovery escrow log (append-only). Required to build the
// ErasureService that backs the self-service /user/account endpoint.
Recovery repository.AccountRecoveryRepository
// RecoveryPublicKey is the RSA public key used to encrypt recovery records.
// Nil disables escrow (deletion still works, but is not recoverable).
RecoveryPublicKey *rsa.PublicKey
// AuditEvents is the audit repository used for read-back of user-scoped
// events in the data-export endpoint. The AuditLog logger wraps the same
// repository for writes.
AuditEvents repository.AuditRepository
}
Deps holds all dependencies injected into the server, including services, repositories, cache, audit logger, email sender, and OAuth2 providers.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the main HTTP server for The Vault. It manages the middleware chain, route registration, TLS configuration, and graceful shutdown.
func (*Server) Chain ¶ added in v1.0.3
Chain wraps inner in the middleware every request to the API passes through, in the order the listener applies it: recovery, request ID, logger, security headers, IP access, CORS, app context, client IP, the body cap, and the honeypot logger on a honeypot deployment.
Start serves Chain(setupRoutes()), and this is the only place the chain is assembled. That matters more than the tidiness: the body cap and its exemption list were certified by a suite that built its own middleware.MaxBody with its own limit, so exempting every path here left the certification green. Evidence that drives this method reads the arguments the deployment actually installs.
func (*Server) Start ¶
Start applies the process-wide middleware configuration, registers all routes, wraps them in Server.Chain, and starts the HTTP(S) server. It blocks until a SIGTERM or SIGINT signal triggers graceful shutdown.