Implements a master toggle for security features across config, CLI, and application logic. This allows granular control over whether the advanced security middleware and protections are active globally.
129 lines
4.2 KiB
Go
129 lines
4.2 KiB
Go
package config
|
|
|
|
type Source string
|
|
|
|
const (
|
|
SourceDefault Source = "default"
|
|
SourceEnv Source = "environment"
|
|
SourceDB Source = "db override"
|
|
)
|
|
|
|
type AdminEnabledMode string
|
|
|
|
const (
|
|
AdminEnabledAuto AdminEnabledMode = "auto"
|
|
AdminEnabledTrue AdminEnabledMode = "true"
|
|
AdminEnabledFalse AdminEnabledMode = "false"
|
|
)
|
|
|
|
const (
|
|
SettingGuestUploadsEnabled = "guest_uploads_enabled"
|
|
SettingAPIEnabled = "api_enabled"
|
|
SettingZipDownloadsEnabled = "zip_downloads_enabled"
|
|
SettingOneTimeDownloadsEnabled = "one_time_downloads_enabled"
|
|
SettingOneTimeDownloadExpirySecs = "one_time_download_expiry_seconds"
|
|
SettingOneTimeDownloadRetryFail = "one_time_download_retry_on_failure"
|
|
SettingRenewOnAccessEnabled = "renew_on_access_enabled"
|
|
SettingRenewOnDownloadEnabled = "renew_on_download_enabled"
|
|
SettingDefaultGuestExpirySecs = "default_guest_expiry_seconds"
|
|
SettingMaxGuestExpirySecs = "max_guest_expiry_seconds"
|
|
SettingGlobalMaxFileSizeBytes = "global_max_file_size_gb"
|
|
SettingGlobalMaxBoxSizeBytes = "global_max_box_size_gb"
|
|
SettingDefaultUserMaxFileBytes = "default_user_max_file_size_gb"
|
|
SettingDefaultUserMaxBoxBytes = "default_user_max_box_size_gb"
|
|
SettingSessionTTLSeconds = "session_ttl_seconds"
|
|
SettingBoxPollIntervalMS = "box_poll_interval_ms"
|
|
SettingThumbnailBatchSize = "thumbnail_batch_size"
|
|
SettingThumbnailIntervalSeconds = "thumbnail_interval_seconds"
|
|
SettingDataDir = "data_dir"
|
|
SettingActivityRetentionSeconds = "activity_retention_seconds"
|
|
SettingSecurityEnabled = "security_enabled"
|
|
SettingSecurityIPWhitelist = "security_ip_whitelist"
|
|
SettingSecurityAdminIPWhitelist = "security_admin_ip_whitelist"
|
|
SettingTrustedProxyCIDRs = "trusted_proxy_cidrs"
|
|
SettingSecurityLoginWindowSecs = "security_login_window_seconds"
|
|
SettingSecurityLoginMaxAttempts = "security_login_max_attempts"
|
|
SettingSecurityBanSeconds = "security_ban_seconds"
|
|
SettingSecurityScanWindowSecs = "security_scan_window_seconds"
|
|
SettingSecurityScanMaxAttempts = "security_scan_max_attempts"
|
|
SettingSecurityUploadWindowSecs = "security_upload_window_seconds"
|
|
SettingSecurityUploadMaxRequests = "security_upload_max_requests"
|
|
SettingSecurityUploadMaxGB = "security_upload_max_gb"
|
|
)
|
|
|
|
type SettingType string
|
|
|
|
const (
|
|
SettingTypeBool SettingType = "bool"
|
|
SettingTypeInt64 SettingType = "int64"
|
|
SettingTypeInt SettingType = "int"
|
|
SettingTypeText SettingType = "text"
|
|
SettingTypeSizeGB SettingType = "size_gb"
|
|
)
|
|
|
|
type SettingDefinition struct {
|
|
Key string
|
|
EnvName string
|
|
Label string
|
|
Type SettingType
|
|
Editable bool
|
|
HardLimit bool
|
|
Minimum int64
|
|
}
|
|
|
|
type SettingRow struct {
|
|
Definition SettingDefinition
|
|
Value string
|
|
Source Source
|
|
}
|
|
|
|
type Config struct {
|
|
DataDir string
|
|
UploadsDir string
|
|
DBDir string
|
|
|
|
AdminPassword string
|
|
AdminUsername string
|
|
AdminEmail string
|
|
AdminEnabled AdminEnabledMode
|
|
AdminCookieSecure bool
|
|
AllowAdminSettingsOverride bool
|
|
|
|
GuestUploadsEnabled bool
|
|
APIEnabled bool
|
|
ZipDownloadsEnabled bool
|
|
OneTimeDownloadsEnabled bool
|
|
OneTimeDownloadExpirySeconds int64
|
|
OneTimeDownloadRetryOnFailure bool
|
|
RenewOnAccessEnabled bool
|
|
RenewOnDownloadEnabled bool
|
|
|
|
DefaultGuestExpirySeconds int64
|
|
MaxGuestExpirySeconds int64
|
|
GlobalMaxFileSizeBytes int64
|
|
GlobalMaxBoxSizeBytes int64
|
|
DefaultUserMaxFileSizeBytes int64
|
|
DefaultUserMaxBoxSizeBytes int64
|
|
SessionTTLSeconds int64
|
|
BoxPollIntervalMS int
|
|
ThumbnailBatchSize int
|
|
ThumbnailIntervalSeconds int
|
|
ActivityRetentionSeconds int64
|
|
SecurityEnabled bool
|
|
SecurityIPWhitelist string
|
|
SecurityAdminIPWhitelist string
|
|
TrustedProxyCIDRs string
|
|
SecurityLoginWindowSeconds int64
|
|
SecurityLoginMaxAttempts int
|
|
SecurityBanSeconds int64
|
|
SecurityScanWindowSeconds int64
|
|
SecurityScanMaxAttempts int
|
|
SecurityUploadWindowSeconds int64
|
|
SecurityUploadMaxRequests int
|
|
SecurityUploadMaxBytes int64
|
|
|
|
sources map[string]Source
|
|
values map[string]string
|
|
defaults map[string]string
|
|
}
|