Cloudrive

Configuration

Every flag the API reads, and the environment variable that sets it.

The binary reads command-line flags only. make run passes them from .env, and the container entrypoint (scripts/entrypoint.sh) turns every non-empty environment variable into its flag. The names below are the environment variables; the flag is the same name in kebab case (DB_DSN → --db-dsn).

App

VariableDefaultRequiredNotes
MACHINE_ID0yesNon-zero, fits in uint16.
ENVdevelopmentproduction disables the localhost rate-limit exemption.
DEBUGfalseDebug log level for the app and Authula.
PORT8080REST API listener.
APP_NAMEgofiShown in emails and Authula.
APP_SECRETyesAuthula signing secret; HMAC key for provider OAuth state.
WEB_URLyesWhere provider OAuth callbacks redirect back to (/storage).
AUTH_BASE_URLhttp://localhost:<PORT>noPublic API URL used by Authula (email links & OAuth2 callbacks) and storage provider OAuth redirect URIs.
CORS_ALLOWED_ORIGINS*Comma-separated. Also Authula's trusted origins.
TRUSTED_PROXIESComma-separated IPs/CIDRs whose X-Forwarded-For is trusted (validated at boot).
RATE_LIMIT_EXEMPT_IPSComma-separated client IPs exempt from the API, auth, and S3 gateway rate limiters (validated at boot).
BLOCKED_IPSComma-separated IPs/CIDRs refused with 403 on the API and S3 gateway.
IP_BLOCK_MAX_FAILURES10Failed password sign-ins (API) or 403s (S3 gateway) within IP_BLOCK_DURATION that auto-block an IP. 0 disables.
IP_BLOCK_DURATION15mFailure counting window and auto-block length. Blocks live in memory, per replica.
SUPER_USERemail:password (8–128 chars), required when SEED_ON_BOOT=true; creates/updates a verified super_user account.

Database

VariableDefaultRequired
DB_DSNyes
DB_MAX_OPEN_CONNS25
DB_MAX_IDLE_CONNS25
DB_MAX_IDLE_TIME15m

Email (Resend)

VariableRequiredNotes
RESEND_API_KEYyes
RESEND_FROM_EMAILyes
RESEND_DEBUG_TO_EMAILyesChecked at boot; not read by the current mail code.

Storage providers

VariableNotes
GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRETGoogle sign-in (Authula) and the Google Drive connector. Both empty disables Google sign-in.
ONEDRIVE_CLIENT_ID, ONEDRIVE_CLIENT_SECRET, ONEDRIVE_TENANT_IDMicrosoft Graph; tenant defaults to common.
DROPBOX_CLIENT_ID, DROPBOX_CLIENT_SECRETDropbox OAuth.
STORAGE_CREDENTIALS_KEYSRequired. Vault keys, key_id:base64(32 bytes), comma-separated; the first one encrypts.

Provider OAuth redirect URIs are AUTH_BASE_URL + /v1/storage/oauth/<provider>/callback; register exactly that in each provider's console. Google sign-in uses AUTH_BASE_URL + /v1/auth/oauth2/callback/google.

S3 gateway

VariableDefaultNotes
S3_API_PORT90000 disables the gateway listener.
S3_STAGING_DIRWhere multipart parts are staged for non-S3 backends (Drive).

S3_CLIENT_ID, S3_CLIENT_SECRET, S3_REGION, S3_ENDPOINT and S3_TOKEN are parsed into the config but not used by the current handlers.

Cloudflare Turnstile

VariableDefaultNotes
TURNSTILE_ENABLEDfalseRequire Cloudflare Turnstile tokens on magic-link sign-in, email/password sign-in/up, and password reset.
TURNSTILE_SECRETRequired when TURNSTILE_ENABLED=true. Turnstile secret key verified against Cloudflare Siteverify.
TURNSTILE_HOSTNAMESComma-separated allowed hostnames validated against Cloudflare's response (recommended in production).

Pair with VITE_TURNSTILE_SITE_KEY in apps/web-ui so the login page renders the widget.

OIDC SSO

VariableDefaultNotes
OIDC_ISSUERDiscovery issuer URL (e.g. https://idp.example.com/application/o/cloudrive/).
OIDC_CLIENT_IDOIDC client ID. Must be set together with OIDC_ISSUER and OIDC_CLIENT_SECRET.
OIDC_CLIENT_SECRETOIDC client secret.
OIDC_PROVIDER_NAMESSOButton label exposed by GET /v1/auth/providers (shown as Continue with <name>).
OIDC_REDIRECT_URLOverride callback URL (defaults to AUTH_BASE_URL + /v1/auth/oauth2/callback/oidc).
OIDC_REQUIRE_EMAIL_VERIFIEDtrueRequire the IdP to return a verified email address before signing in.
OIDC_DISABLE_PASSWORD_LOGINfalseDisable /v1/auth/email-password/* when OIDC is enabled (fails closed with 404 if OIDC is down).
OIDC_LINK_EXISTING_ACCOUNTSfalseLink an OIDC login to an existing user with the same email address.
OIDC_AUTO_PROVISIONfalseAutomatically create a new user account on first OIDC login.

Boot & Observability

VariableDefaultNotes
MIGRATE_ON_BOOTfalseApply embedded migrations at startup; recommended in containers (single replica).
SEED_ON_BOOTfalseRun the idempotent seeders (provider catalog + SUPER_USER) before serving; needs SUPER_USER.
SENTRY_DSNOptional Sentry DSN for panic and error tracking (ENVIRONMENT tags the Sentry environment).
TYPESAFE_API_KEY, TYPESAFE_API_URLOptional typed diagnosis of boot failures.

Rotating the vault key

  1. Generate a key: openssl rand -base64 32.
  2. Put the new entry first, keep the old ones after it: STORAGE_CREDENTIALS_KEYS=v2:<new>,v1:<old>.
  3. Restart. New secrets use v2; existing ones still decrypt through their key_id prefix. Rotating credentials (PUT /v1/storage/accounts/:id/credentials) re-encrypts them.

On this page