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).
| Variable | Default | Required | Notes |
|---|
MACHINE_ID | 0 | yes | Non-zero, fits in uint16. |
ENV | development | | production disables the localhost rate-limit exemption. |
DEBUG | false | | Debug log level for the app and Authula. |
PORT | 8080 | | REST API listener. |
APP_NAME | gofi | | Shown in emails and Authula. |
APP_SECRET | | yes | Authula signing secret; HMAC key for provider OAuth state. |
WEB_URL | | yes | Where provider OAuth callbacks redirect back to (/storage). |
AUTH_BASE_URL | http://localhost:<PORT> | no | Public 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_PROXIES | | | Comma-separated IPs/CIDRs whose X-Forwarded-For is trusted (validated at boot). |
RATE_LIMIT_EXEMPT_IPS | | | Comma-separated client IPs exempt from the API, auth, and S3 gateway rate limiters (validated at boot). |
BLOCKED_IPS | | | Comma-separated IPs/CIDRs refused with 403 on the API and S3 gateway. |
IP_BLOCK_MAX_FAILURES | 10 | | Failed password sign-ins (API) or 403s (S3 gateway) within IP_BLOCK_DURATION that auto-block an IP. 0 disables. |
IP_BLOCK_DURATION | 15m | | Failure counting window and auto-block length. Blocks live in memory, per replica. |
SUPER_USER | | | email:password (8–128 chars), required when SEED_ON_BOOT=true; creates/updates a verified super_user account. |
| Variable | Default | Required |
|---|
DB_DSN | | yes |
DB_MAX_OPEN_CONNS | 25 | |
DB_MAX_IDLE_CONNS | 25 | |
DB_MAX_IDLE_TIME | 15m | |
| Variable | Required | Notes |
|---|
RESEND_API_KEY | yes | |
RESEND_FROM_EMAIL | yes | |
RESEND_DEBUG_TO_EMAIL | yes | Checked at boot; not read by the current mail code. |
| Variable | Notes |
|---|
GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET | Google sign-in (Authula) and the Google Drive connector. Both empty disables Google sign-in. |
ONEDRIVE_CLIENT_ID, ONEDRIVE_CLIENT_SECRET, ONEDRIVE_TENANT_ID | Microsoft Graph; tenant defaults to common. |
DROPBOX_CLIENT_ID, DROPBOX_CLIENT_SECRET | Dropbox OAuth. |
STORAGE_CREDENTIALS_KEYS | Required. 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.
| Variable | Default | Notes |
|---|
S3_API_PORT | 9000 | 0 disables the gateway listener. |
S3_STAGING_DIR | | Where 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.
| Variable | Default | Notes |
|---|
TURNSTILE_ENABLED | false | Require Cloudflare Turnstile tokens on magic-link sign-in, email/password sign-in/up, and password reset. |
TURNSTILE_SECRET | | Required when TURNSTILE_ENABLED=true. Turnstile secret key verified against Cloudflare Siteverify. |
TURNSTILE_HOSTNAMES | | Comma-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.
| Variable | Default | Notes |
|---|
OIDC_ISSUER | | Discovery issuer URL (e.g. https://idp.example.com/application/o/cloudrive/). |
OIDC_CLIENT_ID | | OIDC client ID. Must be set together with OIDC_ISSUER and OIDC_CLIENT_SECRET. |
OIDC_CLIENT_SECRET | | OIDC client secret. |
OIDC_PROVIDER_NAME | SSO | Button label exposed by GET /v1/auth/providers (shown as Continue with <name>). |
OIDC_REDIRECT_URL | | Override callback URL (defaults to AUTH_BASE_URL + /v1/auth/oauth2/callback/oidc). |
OIDC_REQUIRE_EMAIL_VERIFIED | true | Require the IdP to return a verified email address before signing in. |
OIDC_DISABLE_PASSWORD_LOGIN | false | Disable /v1/auth/email-password/* when OIDC is enabled (fails closed with 404 if OIDC is down). |
OIDC_LINK_EXISTING_ACCOUNTS | false | Link an OIDC login to an existing user with the same email address. |
OIDC_AUTO_PROVISION | false | Automatically create a new user account on first OIDC login. |
| Variable | Default | Notes |
|---|
MIGRATE_ON_BOOT | false | Apply embedded migrations at startup; recommended in containers (single replica). |
SEED_ON_BOOT | false | Run the idempotent seeders (provider catalog + SUPER_USER) before serving; needs SUPER_USER. |
SENTRY_DSN | | Optional Sentry DSN for panic and error tracking (ENVIRONMENT tags the Sentry environment). |
TYPESAFE_API_KEY, TYPESAFE_API_URL | | Optional typed diagnosis of boot failures. |
- Generate a key:
openssl rand -base64 32.
- Put the new entry first, keep the old ones after it:
STORAGE_CREDENTIALS_KEYS=v2:<new>,v1:<old>.
- 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.