Documentation
¶
Index ¶
- Variables
- func AdminAlertsSummary(c echo.Context) error
- func AdminBillingGift(c echo.Context) error
- func AdminBillingTickNow(c echo.Context) error
- func AdminCancelTask(c echo.Context) error
- func AdminCleanupTestUser(c echo.Context) error
- func AdminContactsHandler(c echo.Context) error
- func AdminCopyAll(c echo.Context) error
- func AdminCopyFile(c echo.Context) error
- func AdminCopyUserFiles(c echo.Context) error
- func AdminDeleteFile(c echo.Context) error
- func AdminExportFile(c echo.Context) error
- func AdminForceLogout(c echo.Context) error
- func AdminGetAllCredits(c echo.Context) error
- func AdminGetBillingOverdrawn(c echo.Context) error
- func AdminGetBillingPrice(c echo.Context) error
- func AdminGetBillingSweepSummary(c echo.Context) error
- func AdminGetContactInfo(c echo.Context) error
- func AdminGetUserCredits(c echo.Context) error
- func AdminGetUserStatus(c echo.Context) error
- func AdminListUserFiles(c echo.Context) error
- func AdminListUserShares(c echo.Context) error
- func AdminMiddleware(next echo.HandlerFunc) echo.HandlerFunc
- func AdminOpaqueAuthFinalize(c echo.Context) error
- func AdminOpaqueAuthResponse(c echo.Context) error
- func AdminRevokeShare(c echo.Context) error
- func AdminRevokeUser(c echo.Context) error
- func AdminSecurityEvents(c echo.Context) error
- func AdminSetBillingPrice(c echo.Context) error
- func AdminSetCost(c echo.Context) error
- func AdminSetPrimary(c echo.Context) error
- func AdminSetSecondary(c echo.Context) error
- func AdminSetTertiary(c echo.Context) error
- func AdminStorageStatus(c echo.Context) error
- func AdminSwapProviders(c echo.Context) error
- func AdminSyncStatus(c echo.Context) error
- func AdminSystemHealth(c echo.Context) error
- func AdminSystemStatus(c echo.Context) error
- func AdminTOTPDecryptCheck(c echo.Context) error
- func AdminTaskStatus(c echo.Context) error
- func AdminVerifyAll(c echo.Context) error
- func AdminVerifyStorage(c echo.Context) error
- func ApproveUser(c echo.Context) error
- func BootstrapRegisterFinalize(c echo.Context) error
- func BootstrapRegisterResponse(c echo.Context) error
- func CSPMiddleware(next echo.HandlerFunc) echo.HandlerFunc
- func CancelUpload(c echo.Context) error
- func CompleteUpload(c echo.Context) error
- func CreateExportToken(c echo.Context) error
- func CreateFileShare(c echo.Context) error
- func CreateUploadSession(c echo.Context) error
- func DeleteContactInfo(c echo.Context) error
- func DeleteFile(c echo.Context) error
- func DeleteUser(c echo.Context) error
- func DownloadFileChunk(c echo.Context) error
- func DownloadShareChunk(c echo.Context) error
- func ExportFile(c echo.Context) error
- func FloodGuardMiddleware(next echo.HandlerFunc) echo.HandlerFunc
- func ForceRevokeAllTokens(c echo.Context) error
- func GetArgon2Config(c echo.Context) error
- func GetChunkingConfig(c echo.Context) error
- func GetContactInfo(c echo.Context) error
- func GetFileEnvelope(c echo.Context) error
- func GetFileMeta(c echo.Context) error
- func GetFileMetadataBatch(c echo.Context) error
- func GetPasswordRequirements(c echo.Context) error
- func GetPendingUsers(c echo.Context) error
- func GetShareDownloadMetadata(c echo.Context) error
- func GetShareEnvelope(c echo.Context) error
- func GetSharedFile(c echo.Context) error
- func GetUploadStatus(c echo.Context) error
- func GetUserCredits(c echo.Context) error
- func GetVersion(c echo.Context) error
- func InitTaskRunner(maxWorkers int)
- func InitializeRateLimitManager(rateLimitConfig config.RateLimitConfig) error
- func JSONError(c echo.Context, status int, message string) error
- func JSONResponse(c echo.Context, status int, message string, data interface{}) error
- func ListFiles(c echo.Context) error
- func ListRecentFileMetadata(c echo.Context) error
- func ListShares(c echo.Context) error
- func ListUsers(c echo.Context) error
- func LogAdminAction(db interface{ ... }, adminUsername, action, targetUsername, details string) error
- func LoginRateLimitMiddleware(next echo.HandlerFunc) echo.HandlerFunc
- func Logout(c echo.Context) error
- func NotifyShareNotFound(entityID, shareIDPrefix string)
- func OpaqueAuthFinalize(c echo.Context) error
- func OpaqueAuthResponse(c echo.Context) error
- func OpaqueHealthCheck(c echo.Context) error
- func OpaqueRegisterFinalize(c echo.Context) error
- func OpaqueRegisterResponse(c echo.Context) error
- func PrivacyRequestLogger(next echo.HandlerFunc) echo.HandlerFunc
- func PutContactInfo(c echo.Context) error
- func RateLimitMiddleware(endpointConfig config.EndpointConfig) echo.MiddlewareFunc
- func RateLimitShareAccess(shareID string, c echo.Context, accessFunc func() error) error
- func RefreshToken(c echo.Context) error
- func RegisterRateLimitMiddleware(next echo.HandlerFunc) echo.HandlerFunc
- func RegisterRoutes()
- func RequireAdmin(next echo.HandlerFunc) echo.HandlerFunc
- func RequireApproved(next echo.HandlerFunc) echo.HandlerFunc
- func RequireTOTP(next echo.HandlerFunc) echo.HandlerFunc
- func RevokeAllRefreshTokens(c echo.Context) error
- func RevokeShare(c echo.Context) error
- func RevokeToken(c echo.Context) error
- func ServeRateLimitPage(c echo.Context, retryAfter int, message string) error
- func SetBillingGiftFunc(...)
- func SetBillingProjectionSeams(freeBaseline func() int64, resolveRate func(db *sql.DB) (int64, string, bool))
- func SetBillingSetPriceFunc(fn func(db *sql.DB, priceStr, updatedBy string) (int64, string, error))
- func SetBillingSweepNowFunc(fn func(db *sql.DB) error)
- func SetBillingTickNowFunc(fn func(db *sql.DB) error)
- func ShareEnumerationMiddleware(next echo.HandlerFunc) echo.HandlerFunc
- func ShareRateLimitMiddleware(next echo.HandlerFunc) echo.HandlerFunc
- func TLSVersionCheck(next echo.HandlerFunc) echo.HandlerFunc
- func TOTPAuth(c echo.Context) error
- func TOTPRateLimitMiddleware(endpointType string) echo.MiddlewareFunc
- func TOTPReset(c echo.Context) error
- func TOTPSetup(c echo.Context) error
- func TOTPStatus(c echo.Context) error
- func TOTPVerify(c echo.Context) error
- func TimingProtectionMiddleware(next echo.HandlerFunc) echo.HandlerFunc
- func UpdateUser(c echo.Context) error
- func UpdateUserStorageLimit(c echo.Context) error
- func UploadChunk(c echo.Context) error
- type APIResponse
- type AdminApproveRequest
- type AdminApproveResponse
- type AdminBillingStatus
- type AdminCleanupRequest
- type AdminCleanupResponse
- type AdminOPAQUEStatus
- type AdminTOTPStatus
- type AdminTokenStatus
- type AdminUserInfo
- type AdminUserStatusResponse
- type AuthRateLimitEntry
- type BootstrapRegisterFinalizeRequest
- type BootstrapRegisterInitRequest
- type CopyTaskDetails
- type CopyTaskRequest
- type ExportTokenClaims
- type FileMetadataBatchRequest
- type LogoutRequest
- type OpaqueAuthFinalizeRequest
- type OpaqueAuthInitRequest
- type OpaqueAuthResponseRequest
- type OpaqueHealthCheckResponse
- type OpaqueRegisterFinalizeRequest
- type OpaqueRegisterResponseRequest
- type RateLimitManager
- type RateLimitState
- type RefreshTokenRequest
- type ShareRateLimitEntry
- type ShareRequest
- type ShareResponse
- type StreamingHashState
- type StreamingHashTeeReader
- type TOTPAuthRequest
- type TOTPResetRequest
- type TOTPResetResponse
- type TOTPSetupRequest
- type TOTPSetupResponse
- type TOTPStatusResponse
- type TOTPVerifyRequest
- type TaskRunner
- type VerifyTaskDetails
- type VerifyTaskRequest
Constants ¶
This section is empty.
Variables ¶
var Echo *echo.Echo
Echo is the global echo instance used for routing
Functions ¶
func AdminAlertsSummary ¶
AdminAlertsSummary handles GET /api/admin/alerts/summary Returns storage health warnings for the admin CLI login alert display.
func AdminBillingGift ¶
AdminBillingGift adds positive microcent credit to a user's balance and writes a typed 'gift' transaction. Replaces the old POST /api/admin/credits endpoint (deleted in Section B+C); this is the only path for any admin- initiated positive balance adjustment.
POST /api/admin/billing/gift Body: { "target_username": "...", "amount_usd": "5.00", "reason": "..." }
func AdminBillingTickNow ¶
AdminBillingTickNow forces an immediate tick (and optional sweep) of every active billable user. Intended for the e2e billing test in scripts/testing/e2e-test.sh; gated to ADMIN_DEV_TEST_API_ENABLED so it is physically not registered as a route in production-flavored deployments (see route_config.go for the gating).
POST /api/admin/billing/tick-now Body: { "sweep": false }
func AdminCancelTask ¶
AdminCancelTask handles POST /api/admin/storage/cancel-task/:taskId
func AdminCleanupTestUser ¶
AdminCleanupTestUser performs comprehensive cleanup of test user data
func AdminContactsHandler ¶
AdminContactsHandler returns admin contact information for user support
func AdminCopyAll ¶
AdminCopyAll handles POST /api/admin/storage/copy-all
func AdminCopyFile ¶
AdminCopyFile handles POST /api/admin/storage/copy-file
func AdminCopyUserFiles ¶
AdminCopyUserFiles handles POST /api/admin/storage/copy-user-files
func AdminDeleteFile ¶
AdminDeleteFile deletes a specific file by file_id (from storage + DB)
func AdminExportFile ¶
AdminExportFile handles GET /api/admin/files/:fileId/export Streams a .arkbackup bundle for any user's file (admin only). Authentication: JWT + Admin middleware
func AdminForceLogout ¶
AdminForceLogout allows admin to force-logout a specific user (admin-only endpoint)
func AdminGetAllCredits ¶
AdminGetAllCredits returns the credit balances for every user, plus a per-user current_usage block and aggregate totals. Requires admin privileges. Negative balances are rendered with a leading "-".
func AdminGetBillingOverdrawn ¶
AdminGetBillingOverdrawn lists every user with a negative balance.
GET /api/admin/billing/overdrawn
func AdminGetBillingPrice ¶
AdminGetBillingPrice returns the current customer price and the derived internal rate. Read-only; safe for any admin to call.
GET /api/admin/billing/price
func AdminGetBillingSweepSummary ¶
AdminGetBillingSweepSummary returns per-day aggregates of recent 'usage' transactions plus a point-in-time count of users currently in the negative. Used by the operator UI to spot trends.
GET /api/admin/billing/sweep-summary?days=7
func AdminGetContactInfo ¶
AdminGetContactInfo handles GET /api/admin/users/:username/contact-info Returns contact information for any user (admin only).
func AdminGetUserCredits ¶
AdminGetUserCredits returns the credit information for a specific user. Requires admin privileges. Includes the current_usage and credits_runway blocks.
func AdminGetUserStatus ¶
AdminGetUserStatus returns comprehensive user status information
func AdminListUserFiles ¶
AdminListUserFiles lists all files owned by a specific user
func AdminListUserShares ¶
AdminListUserShares lists all shares owned by a specific user
func AdminMiddleware ¶
func AdminMiddleware(next echo.HandlerFunc) echo.HandlerFunc
AdminMiddleware enforces multi-layer security for admin endpoints
func AdminOpaqueAuthFinalize ¶
AdminOpaqueAuthFinalize completes admin authentication
func AdminOpaqueAuthResponse ¶
AdminOpaqueAuthResponse handles server-side credential response creation for admin login
func AdminRevokeShare ¶
AdminRevokeShare revokes a specific share by share_id
func AdminRevokeUser ¶
AdminRevokeUser revokes a user's access by setting is_approved to false
func AdminSecurityEvents ¶
AdminSecurityEvents exposes existing security event logs via admin API. Supports query parameters for filtering:
- type: filter by event type (e.g. "share_not_found", "opaque_login_failure")
- severity: filter by severity ("INFO", "WARNING", "CRITICAL")
- entity_id: filter by entity ID (HMAC-based, 16-char hex)
- limit: max events to return (default 100, max 500)
func AdminSetBillingPrice ¶
AdminSetBillingPrice updates the customer price and atomically swaps the cached billing rate. The next tick observes the new rate.
POST /api/admin/billing/set-price Body: { "customer_price_usd_per_tb_per_month": "19.99" }
func AdminSetCost ¶
AdminSetCost handles POST /api/admin/storage/set-cost
func AdminSetPrimary ¶
AdminSetPrimary handles POST /api/admin/storage/set-primary
func AdminSetSecondary ¶
AdminSetSecondary handles POST /api/admin/storage/set-secondary
func AdminSetTertiary ¶
AdminSetTertiary handles POST /api/admin/storage/set-tertiary
func AdminStorageStatus ¶
AdminStorageStatus handles GET /api/admin/storage/status Returns configured providers, file counts, sync status, and cost info.
func AdminSwapProviders ¶
AdminSwapProviders handles POST /api/admin/storage/swap-providers
func AdminSyncStatus ¶
AdminSyncStatus handles GET /api/admin/storage/sync-status Returns detailed breakdown of file locations and replication gaps.
func AdminSystemHealth ¶
AdminSystemHealth bridges existing monitoring infrastructure to admin API endpoints
func AdminSystemStatus ¶
AdminSystemStatus returns system status overview including uptime, version, storage and user statistics
func AdminTOTPDecryptCheck ¶
AdminTOTPDecryptCheck provides TOTP diagnostic information for development
func AdminTaskStatus ¶
AdminTaskStatus handles GET /api/admin/storage/task/:taskId
func AdminVerifyAll ¶
AdminVerifyAll handles POST /api/admin/storage/verify-all Initiates a background task that performs HEAD requests against all active file_storage_locations to confirm S3 objects exist and sizes match.
func AdminVerifyStorage ¶
AdminVerifyStorage handles POST /api/admin/storage/verify-storage Runs a full S3 round-trip test (upload, download, hash verify, delete). If provider_id is specified in the JSON body, verifies that provider; otherwise defaults to the primary provider.
func ApproveUser ¶
ApproveUser approves a user and optionally updates their storage limit
func BootstrapRegisterFinalize ¶
BootstrapRegisterFinalize completes the OPAQUE registration for the bootstrap admin.
func BootstrapRegisterResponse ¶
BootstrapRegisterResponse handles the first step of OPAQUE registration for the bootstrap admin.
func CSPMiddleware ¶
func CSPMiddleware(next echo.HandlerFunc) echo.HandlerFunc
CSPMiddleware adds Content Security Policy headers with strict security
func CancelUpload ¶
CancelUpload aborts an in-progress upload session
func CompleteUpload ¶
CompleteUpload finalizes a chunked upload
func CreateExportToken ¶
CreateExportToken handles POST /api/files/:fileId/export-token Returns a short-lived JWT scoped to a single file export. Used by the browser frontend to trigger native downloads without memory buffering.
func CreateFileShare ¶
CreateFileShare creates a new Argon2id-based anonymous file share
func CreateUploadSession ¶
CreateUploadSession initializes a new chunked upload
func DeleteContactInfo ¶
DeleteContactInfo handles DELETE /api/user/contact-info Deletes the authenticated user's contact information.
func DeleteFile ¶
DeleteFile handles file deletion across all storage providers
func DeleteUser ¶
DeleteUser deletes a user and all associated data
func DownloadFileChunk ¶
DownloadFileChunk streams a specific chunk of a file to the client GET /api/files/:fileId/chunks/:chunkIndex Returns the specified chunk (0-indexed) of the file
func DownloadShareChunk ¶
DownloadShareChunk handles downloading a specific chunk of a shared file GET /api/shares/:id/chunks/:chunkIndex
func ExportFile ¶
ExportFile handles GET /api/files/:fileId/export Streams a .arkbackup bundle for the authenticated user's own file. Authentication: JWT + TOTP (via totpProtectedGroup middleware) Also accepts ?token= query param for browser downloads (short-lived export token).
func FloodGuardMiddleware ¶
func FloodGuardMiddleware(next echo.HandlerFunc) echo.HandlerFunc
FloodGuardMiddleware detects and rate-limits entities that generate excessive 401/404 responses (vulnerability scanners, path probers). It wraps the request handler: checking for active blocks before processing, and recording bad responses after processing.
func ForceRevokeAllTokens ¶
ForceRevokeAllTokens implements security-critical revocation for edge cases This function revokes BOTH refresh tokens AND active JWT tokens immediately Used for: OPAQUE credential re-registration, admin force-logout, security breaches
func GetArgon2Config ¶
GetArgon2Config returns the Argon2id parameters configuration from embedded data This ensures TypeScript and Go use the same parameters
func GetChunkingConfig ¶
GetChunkingConfig returns the chunking parameters configuration from embedded data This ensures TypeScript and Go use the same chunk sizes, envelope format, and AES-GCM parameters
func GetContactInfo ¶
GetContactInfo handles GET /api/user/contact-info Returns the authenticated user's own contact information.
func GetFileEnvelope ¶
GetFileEnvelope returns the encrypted FEK and metadata for a file (for share creation)
func GetFileMeta ¶
GetFileMeta returns encrypted file metadata needed for download initialization
func GetFileMetadataBatch ¶
GetFileMetadataBatch returns lightweight encrypted metadata for an explicit batch of owner-owned file IDs.
func GetPasswordRequirements ¶
GetPasswordRequirements returns the password validation requirements from embedded data This ensures TypeScript and Go use the same validation rules
func GetPendingUsers ¶
GetPendingUsers returns a list of users pending approval
func GetShareDownloadMetadata ¶
GetShareDownloadMetadata returns metadata about a shared file's chunks for resumable downloads GET /api/shares/:id/metadata
func GetShareEnvelope ¶
GetShareEnvelope returns the encrypted envelope and salt for a share. The server does NOT receive or process share passwords. Share key derivation (Argon2id) and envelope decryption happen entirely client-side.
func GetSharedFile ¶
GetSharedFile renders the share access page
func GetUploadStatus ¶
GetUploadStatus returns the status of an upload session including which chunks have been uploaded
func GetUserCredits ¶
GetUserCredits returns the current user's signed microcent balance, the transaction history, and -- once the billing meter is wired in (Section D) -- the current_usage and credits_runway blocks.
func GetVersion ¶
GetVersion returns the current Arkfile application version
func InitTaskRunner ¶
func InitTaskRunner(maxWorkers int)
InitTaskRunner creates the global task runner. Called from main.go on startup.
func InitializeRateLimitManager ¶
func InitializeRateLimitManager(rateLimitConfig config.RateLimitConfig) error
InitializeRateLimitManager initializes the global rate limit manager
func JSONResponse ¶
JSONResponse sends a standard JSON response
func ListRecentFileMetadata ¶
ListRecentFileMetadata returns a paginated recent metadata listing for the authenticated owner. This endpoint is intended for owner-side local metadata decryption workflows and does not expose FEKs or chunk/download details.
func ListShares ¶
ListShares returns all shares created by a user
func LogAdminAction ¶
func LogAdminAction(db interface {
Exec(string, ...interface{}) (sql.Result, error)
}, adminUsername, action, targetUsername, details string) error
LogAdminAction logs an admin action to the admin_logs table
func LoginRateLimitMiddleware ¶
func LoginRateLimitMiddleware(next echo.HandlerFunc) echo.HandlerFunc
LoginRateLimitMiddleware provides rate limiting for login endpoints
func NotifyShareNotFound ¶
func NotifyShareNotFound(entityID, shareIDPrefix string)
NotifyShareNotFound should be called by share handlers when a share ID returns 404. It records the hit in the enumeration guard and applies progressive penalties. The share handler should call this AFTER logging the EventShareNotFound security event.
func OpaqueAuthFinalize ¶
OpaqueAuthFinalize completes user authentication
func OpaqueAuthResponse ¶
OpaqueAuthResponse handles server-side credential response creation
func OpaqueHealthCheck ¶
OpaqueHealthCheck verifies that the OPAQUE system is functioning properly
func OpaqueRegisterFinalize ¶
OpaqueRegisterFinalize completes user registration
func OpaqueRegisterResponse ¶
OpaqueRegisterResponse handles server-side registration response creation
func PrivacyRequestLogger ¶
func PrivacyRequestLogger(next echo.HandlerFunc) echo.HandlerFunc
PrivacyRequestLogger is an Echo middleware that logs HTTP requests without exposing raw IP addresses. It uses the entity ID system to replace the client IP with a privacy-preserving HMAC-based identifier.
func PutContactInfo ¶
PutContactInfo handles PUT /api/user/contact-info Creates or updates the authenticated user's contact information.
func RateLimitMiddleware ¶
func RateLimitMiddleware(endpointConfig config.EndpointConfig) echo.MiddlewareFunc
RateLimitMiddleware creates rate limiting middleware for specific endpoints
func RateLimitShareAccess ¶
RateLimitShareAccess wraps share access functions with rate limiting logic
func RefreshToken ¶
RefreshToken handles refresh token requests
func RegisterRateLimitMiddleware ¶
func RegisterRateLimitMiddleware(next echo.HandlerFunc) echo.HandlerFunc
RegisterRateLimitMiddleware provides rate limiting for registration endpoints
func RegisterRoutes ¶
func RegisterRoutes()
RegisterRoutes initializes all routes for the application
func RequireAdmin ¶
func RequireAdmin(next echo.HandlerFunc) echo.HandlerFunc
RequireAdmin ensures the user has admin privileges before allowing access
func RequireApproved ¶
func RequireApproved(next echo.HandlerFunc) echo.HandlerFunc
RequireApproved ensures the user is approved before allowing access. Applied to auth.Echo so all routes in that group inherit it. Contact-info endpoints are intentionally placed in a separate group (pendingAllowedGroup in route_config.go) that omits this middleware, allowing pending users to manage their contact information.
func RequireTOTP ¶
func RequireTOTP(next echo.HandlerFunc) echo.HandlerFunc
RequireTOTP ensures the user has TOTP enabled before allowing access to protected resources. Note: /api/totp/setup and /api/totp/verify are on a separate route group using TOTPJWTMiddleware and never reach this middleware, so no path-based bypass is needed here.
func RevokeAllRefreshTokens ¶
RevokeAllRefreshTokens revokes all refresh tokens for the current user Note: This does NOT revoke active JWT tokens - they will expire automatically within 30 minutes
func ServeRateLimitPage ¶
ServeRateLimitPage returns the 429 error page with appropriate format (HTML for browsers, JSON for API clients)
func SetBillingGiftFunc ¶
func SetBillingGiftFunc(fn func(db *sql.DB, username string, amountUSDMicrocents int64, reason, adminUsername string) (*models.CreditTransaction, error))
SetBillingGiftFunc wires the billing.GiftCredits call.
func SetBillingProjectionSeams ¶
func SetBillingProjectionSeams( freeBaseline func() int64, resolveRate func(db *sql.DB) (int64, string, bool), )
SetBillingProjectionSeams wires the projection helpers to the live billing package. Called once from main.go during startup.
func SetBillingSetPriceFunc ¶
SetBillingSetPriceFunc wires the billing.SetCustomerPrice call.
func SetBillingSweepNowFunc ¶
SetBillingSweepNowFunc wires the dev/test "sweep now" call.
func SetBillingTickNowFunc ¶
SetBillingTickNowFunc wires the dev/test "tick now" call.
func ShareEnumerationMiddleware ¶
func ShareEnumerationMiddleware(next echo.HandlerFunc) echo.HandlerFunc
ShareEnumerationMiddleware protects share endpoints against entity-global enumeration attacks (probing many different share IDs). This runs BEFORE the per-share-ID rate limiter and the handler itself.
It applies to both /shared/:id (HTML page) and /api/public/shares/:id/* endpoints.
func ShareRateLimitMiddleware ¶
func ShareRateLimitMiddleware(next echo.HandlerFunc) echo.HandlerFunc
ShareRateLimitMiddleware provides rate limiting for share access attempts This middleware is designed to work WITH TimingProtectionMiddleware by not short-circuiting timing
func TLSVersionCheck ¶
func TLSVersionCheck(next echo.HandlerFunc) echo.HandlerFunc
TLSVersionCheck middleware adds TLS version information to response headers and logs TLS version usage for analytics
func TOTPRateLimitMiddleware ¶
func TOTPRateLimitMiddleware(endpointType string) echo.MiddlewareFunc
TOTPRateLimitMiddleware provides rate limiting for TOTP endpoints
func TOTPStatus ¶
TOTPStatus returns the TOTP status for a user
func TOTPVerify ¶
TOTPVerify completes TOTP setup by verifying a test code
func TimingProtectionMiddleware ¶
func TimingProtectionMiddleware(next echo.HandlerFunc) echo.HandlerFunc
TimingProtectionMiddleware enforces 1-second minimum response time for anonymous endpoints
func UpdateUserStorageLimit ¶
UpdateUserStorageLimit updates a user's storage limit
func UploadChunk ¶
UploadChunk handles individual chunk uploads
Types ¶
type APIResponse ¶
type APIResponse struct {
Success bool `json:"success"`
Message string `json:"message,omitempty"`
Data interface{} `json:"data,omitempty"`
}
APIResponse represents the standard API response structure
type AdminApproveRequest ¶
type AdminApproveRequest struct {
ApprovedBy string `json:"approved_by" validate:"required"`
StorageLimitBytes *int64 `json:"storage_limit_bytes,omitempty"`
}
AdminApproveRequest represents the request payload for user approval
type AdminApproveResponse ¶
type AdminApproveResponse struct {
Success bool `json:"success"`
Username string `json:"username"`
IsApproved bool `json:"is_approved"`
ApprovedBy string `json:"approved_by"`
ApprovedAt time.Time `json:"approved_at"`
}
AdminApproveResponse represents the response from user approval
type AdminBillingStatus ¶
type AdminBillingStatus struct {
BalanceUSDMicrocents int64 `json:"balance_usd_microcents"`
FormattedBalance string `json:"formatted_balance"`
BillableBytes int64 `json:"billable_bytes"`
CurrentCostPerMonthUSDApprox string `json:"current_cost_per_month_usd_approx"`
LastBilledAt *time.Time `json:"last_billed_at,omitempty"`
}
AdminBillingStatus is the per-user billing snapshot surfaced in /api/admin/users/:username/status. Balances are signed microcents.
type AdminCleanupRequest ¶
type AdminCleanupRequest struct {
Username string `json:"username" validate:"required"`
Confirm bool `json:"confirm" validate:"required"`
}
AdminCleanupRequest represents the request payload for test user cleanup
type AdminCleanupResponse ¶
type AdminCleanupResponse struct {
Success bool `json:"success"`
TablesCleared map[string]int `json:"tables_cleaned"`
TotalRows int `json:"total_rows_affected"`
Details map[string]interface{} `json:"details,omitempty"`
}
AdminCleanupResponse represents the response from test user cleanup
type AdminOPAQUEStatus ¶
type AdminOPAQUEStatus struct {
HasAccount bool `json:"has_account"`
RecordsCount int `json:"records_count"`
}
AdminOPAQUEStatus represents OPAQUE status information
type AdminTOTPStatus ¶
type AdminTOTPStatus struct {
Present bool `json:"present"`
Decryptable bool `json:"decryptable"`
Enabled bool `json:"enabled"`
SetupCompleted bool `json:"setup_completed"`
}
AdminTOTPStatus represents TOTP status information
type AdminTokenStatus ¶
type AdminTokenStatus struct {
ActiveRefreshTokens int `json:"active_refresh_tokens"`
RevokedTokens int `json:"revoked_tokens"`
}
AdminTokenStatus represents token status information
type AdminUserInfo ¶
type AdminUserInfo struct {
ID int64 `json:"id"`
Username string `json:"username"`
IsApproved bool `json:"is_approved"`
IsAdmin bool `json:"is_admin"`
CreatedAt time.Time `json:"created_at"`
}
AdminUserInfo represents basic user information
type AdminUserStatusResponse ¶
type AdminUserStatusResponse struct {
Exists bool `json:"exists"`
Username string `json:"username,omitempty"`
User *AdminUserInfo `json:"user,omitempty"`
TOTP *AdminTOTPStatus `json:"totp,omitempty"`
OPAQUE *AdminOPAQUEStatus `json:"opaque,omitempty"`
Tokens *AdminTokenStatus `json:"tokens,omitempty"`
Billing *AdminBillingStatus `json:"billing,omitempty"`
Details map[string]interface{} `json:"details,omitempty"`
}
AdminUserStatusResponse represents the comprehensive user status response
type AuthRateLimitEntry ¶
type AuthRateLimitEntry struct {
EndpointType string // "login", "register", "totp_verify", "totp_auth"
EntityID string
FailedCount int
LastFailedAttempt *time.Time
NextAllowedAttempt *time.Time
}
AuthRateLimitEntry represents a rate limiting entry for authentication endpoints
type BootstrapRegisterFinalizeRequest ¶
type BootstrapRegisterFinalizeRequest struct {
BootstrapToken string `json:"bootstrap_token"`
SessionID string `json:"session_id"`
Username string `json:"username"`
RegistrationRecord string `json:"registration_record"` // base64 encoded
}
BootstrapRegisterFinalizeRequest represents the final bootstrap registration request
type BootstrapRegisterInitRequest ¶
type BootstrapRegisterInitRequest struct {
BootstrapToken string `json:"bootstrap_token"`
Username string `json:"username"`
RegistrationRequest string `json:"registration_request"` // base64 encoded
}
BootstrapRegisterInitRequest represents the initial bootstrap registration request
type CopyTaskDetails ¶
type CopyTaskDetails struct {
SourceProviderID string `json:"source_provider_id"`
DestProviderID string `json:"destination_provider_id"`
Verify bool `json:"verify"`
SkipExisting bool `json:"skip_existing"`
Username string `json:"username,omitempty"` // set for copy-user-files
FilesCopied int `json:"files_copied"`
FilesSkipped int `json:"files_skipped"`
FilesFailed int `json:"files_failed"`
BytesCopied int64 `json:"bytes_copied"`
CurrentFileBytes int64 `json:"current_file_bytes"` // bytes copied for file in progress
CurrentFileSize int64 `json:"current_file_size"` // total size of file in progress
}
CopyTaskDetails holds the JSON-serializable details stored in admin_tasks.details.
type CopyTaskRequest ¶
type CopyTaskRequest struct {
TaskType string // "copy-all", "copy-user-files", "copy-file"
AdminUsername string
SourceID string
DestID string
Verify bool
SkipExisting bool
Username string // only for copy-user-files
FileID string // only for copy-file
}
CopyTaskRequest describes a copy operation submitted by an admin API handler.
type ExportTokenClaims ¶
type ExportTokenClaims struct {
Username string `json:"username"`
FileID string `json:"file_id"`
Action string `json:"action"`
jwt.RegisteredClaims
}
ExportTokenClaims holds claims for short-lived export download tokens
type FileMetadataBatchRequest ¶
type FileMetadataBatchRequest struct {
FileIDs []string `json:"file_ids"`
}
type LogoutRequest ¶
type LogoutRequest struct {
RefreshToken string `json:"refresh_token"`
}
LogoutRequest represents the request structure for logging out
type OpaqueAuthFinalizeRequest ¶
type OpaqueAuthFinalizeRequest struct {
Username string `json:"username"`
AuthU string `json:"auth_u"` // base64 encoded client authentication token
}
OpaqueAuthFinalizeRequest represents the final authentication request
type OpaqueAuthInitRequest ¶
type OpaqueAuthInitRequest struct {
Username string `json:"username"`
}
OpaqueAuthInitRequest represents the initial authentication request
type OpaqueAuthResponseRequest ¶
type OpaqueAuthResponseRequest struct {
Username string `json:"username"`
CredentialRequest string `json:"credential_request"` // base64 encoded
}
OpaqueAuthResponseRequest represents the credential response request
type OpaqueHealthCheckResponse ¶
type OpaqueHealthCheckResponse struct {
OpaqueReady bool `json:"opaque_ready"`
ServerKeysLoaded bool `json:"server_keys_loaded"`
DatabaseConnected bool `json:"database_connected"`
Status string `json:"status"`
Message string `json:"message"`
}
OpaqueHealthCheckResponse represents the health status of OPAQUE system
type OpaqueRegisterFinalizeRequest ¶
type OpaqueRegisterFinalizeRequest struct {
Username string `json:"username"`
RegistrationRecord string `json:"registration_record"` // base64 encoded
}
OpaqueRegisterFinalizeRequest represents the final registration request
type OpaqueRegisterResponseRequest ¶
type OpaqueRegisterResponseRequest struct {
RegistrationRequest string `json:"registration_request"` // base64 encoded
}
OpaqueRegisterResponseRequest represents the server response request
type RateLimitManager ¶
type RateLimitManager struct {
// contains filtered or unexported fields
}
RateLimitManager manages rate limiting state with privacy-preserving entity IDs
var DefaultRateLimitManager *RateLimitManager
Global rate limit manager instance
func NewRateLimitManager ¶
func NewRateLimitManager(db *sql.DB, rateLimitConfig config.RateLimitConfig) *RateLimitManager
NewRateLimitManager creates a new rate limit manager
func (*RateLimitManager) CheckRateLimit ¶
func (rlm *RateLimitManager) CheckRateLimit(entityID, endpoint string, limit int, windowSize time.Duration) (bool, error)
CheckRateLimit checks if a request should be rate limited
type RateLimitState ¶
type RateLimitState struct {
EntityID string `json:"entity_id"`
TimeWindow string `json:"time_window"`
Endpoint string `json:"endpoint"`
RequestCount int `json:"request_count"`
LastRequest time.Time `json:"last_request"`
ViolationCount int `json:"violation_count"`
PenaltyUntil *time.Time `json:"penalty_until"`
}
RateLimitState represents the current rate limiting state for an entity
type RefreshTokenRequest ¶
type RefreshTokenRequest struct {
RefreshToken string `json:"refresh_token"`
}
RefreshTokenRequest represents the request structure for refreshing a token
type ShareRateLimitEntry ¶
type ShareRateLimitEntry struct {
}
ShareRateLimitEntry represents a rate limiting entry for share access
type ShareRequest ¶
type ShareRequest struct {
}
ShareRequest represents a file sharing request (Argon2id-based anonymous shares)
type ShareResponse ¶
type ShareResponse struct {
}
ShareResponse represents a file share creation response
type StreamingHashState ¶
type StreamingHashState struct {
// contains filtered or unexported fields
}
StreamingHashState manages the running hash calculation during chunked uploads
func NewStreamingHashState ¶
func NewStreamingHashState(sessionID string) *StreamingHashState
NewStreamingHashState creates a new streaming hash state for an upload session
func (*StreamingHashState) FinalizeHash ¶
func (s *StreamingHashState) FinalizeHash() string
FinalizeHash completes the hash calculation and returns the final SHA256 hex string
func (*StreamingHashState) WriteChunk ¶
func (s *StreamingHashState) WriteChunk(data []byte) ([]byte, error)
WriteChunk adds a chunk to the running hash and returns the data unchanged
type StreamingHashTeeReader ¶
type StreamingHashTeeReader struct {
// contains filtered or unexported fields
}
StreamingHashTeeReader wraps an io.Reader to calculate hash while reading
func NewStreamingHashTeeReader ¶
func NewStreamingHashTeeReader(reader io.Reader, expectedHash string) *StreamingHashTeeReader
NewStreamingHashTeeReader creates a new tee reader that calculates hash while reading
func (*StreamingHashTeeReader) GetBytesRead ¶
func (r *StreamingHashTeeReader) GetBytesRead() int64
GetBytesRead returns the total number of bytes read
func (*StreamingHashTeeReader) Read ¶
func (r *StreamingHashTeeReader) Read(p []byte) (n int, err error)
Read implements io.Reader interface, calculating hash as data is read
func (*StreamingHashTeeReader) VerifyHash ¶
func (r *StreamingHashTeeReader) VerifyHash() (bool, string)
VerifyHash checks if the calculated hash matches the expected hash
type TOTPAuthRequest ¶
type TOTPAuthRequest struct {
Code string `json:"code"`
IsBackup bool `json:"is_backup,omitempty"`
}
TOTPAuthRequest represents the request for TOTP authentication
type TOTPResetRequest ¶
type TOTPResetRequest struct {
BackupCode string `json:"backup_code"`
}
TOTPResetRequest represents the request for TOTP reset
type TOTPResetResponse ¶
type TOTPResetResponse struct {
Secret string `json:"secret"`
QRCodeURL string `json:"qr_code_url"`
BackupCodes []string `json:"backup_codes"`
ManualEntry string `json:"manual_entry"`
Message string `json:"message"`
}
TOTPResetResponse represents the response for TOTP reset
type TOTPSetupRequest ¶
type TOTPSetupRequest struct {
}
TOTPSetupRequest represents the request for TOTP setup
type TOTPSetupResponse ¶
type TOTPSetupResponse struct {
Secret string `json:"secret"`
QRCodeURL string `json:"qr_code_url"`
QRCodeImage string `json:"qr_code_image"` // Base64 data URI for QR code PNG
BackupCodes []string `json:"backup_codes"`
ManualEntry string `json:"manual_entry"`
}
TOTPSetupResponse represents the response for TOTP setup
type TOTPStatusResponse ¶
type TOTPStatusResponse struct {
Enabled bool `json:"enabled"`
SetupRequired bool `json:"setup_required"`
LastUsed *time.Time `json:"last_used,omitempty"`
CreatedAt *time.Time `json:"created_at,omitempty"`
}
TOTPStatusResponse represents the TOTP status response
type TOTPVerifyRequest ¶
type TOTPVerifyRequest struct {
Code string `json:"code"`
IsBackup bool `json:"is_backup,omitempty"`
}
TOTPVerifyRequest represents the request for TOTP verification
type TaskRunner ¶
type TaskRunner struct {
// contains filtered or unexported fields
}
TaskRunner manages background copy tasks with concurrency control and cancellation.
func (*TaskRunner) CancelTask ¶
func (tr *TaskRunner) CancelTask(taskID string) bool
CancelTask requests cancellation of a running task.
func (*TaskRunner) SubmitCopyTask ¶
func (tr *TaskRunner) SubmitCopyTask(req CopyTaskRequest) (string, error)
SubmitCopyTask creates an admin_tasks row, then runs the copy in a background goroutine. Returns the task ID immediately.
func (*TaskRunner) SubmitVerifyTask ¶
func (tr *TaskRunner) SubmitVerifyTask(req VerifyTaskRequest) (string, error)
SubmitVerifyTask creates an admin_tasks row and runs the verification in background.
type VerifyTaskDetails ¶
type VerifyTaskDetails struct {
ProviderID string `json:"provider_id,omitempty"` // empty means all providers
Fix bool `json:"fix"`
Concurrency int `json:"concurrency"`
VerifiedOK int `json:"verified_ok"`
Missing int `json:"missing"`
SizeMismatch int `json:"size_mismatch"`
Errors int `json:"errors"`
}
VerifyTaskDetails holds the JSON-serializable details stored in admin_tasks.details.
type VerifyTaskRequest ¶
type VerifyTaskRequest struct {
AdminUsername string
ProviderID string // empty means all providers
Fix bool // if true, mark missing files as "missing" in DB
Concurrency int // parallel HEAD requests (default 10)
}
VerifyTaskRequest describes a verify-all operation submitted by an admin API handler.
Source Files
¶
- admin.go
- admin_auth.go
- admin_billing.go
- admin_storage.go
- admin_task_runner.go
- auth.go
- auth_test_helpers.go
- billing_projection.go
- bootstrap.go
- config.go
- contact_info.go
- credits.go
- downloads.go
- error_pages.go
- export.go
- file_shares.go
- files.go
- flood_guard.go
- handlers.go
- middleware.go
- rate_limiting.go
- response.go
- route_config.go
- share_enumeration.go
- streaming_hash.go
- uploads.go