Skip to content

Environment Variables Guide ​

Regardless of the deployment method you choose, you need to configure the following core environment variables. These variables directly determine the system's security and functional availability.

🔐 Core Security Keys (Must Configure) ​

These variables are the foundation of the system's operation and must be set to complex random strings of at least 32 characters.

VariableRequiredDescription & Recommendation
NODEAUTH_LICENSE✅License: System license code. Claim at license.nextmatrix.app/byos.
ENCRYPTION_KEY✅Core: Secret for database encryption. All 2FA seeds are encrypted before storage. Do not change once set. Minimum 32-bit random string required. Obtain at tools.nodeauth.io.
JWT_SECRET✅Login: Used for JWT token signing. High-strength 64-bit random string recommended. Obtain at tools.nodeauth.io.

CAUTION

Warning: Modifying ENCRYPTION_KEY will render all existing 2FA data unreadable. Ensure a full backup is completed before making any changes.


🛡️ Admission Allowlist (Must Configure) ​

IMPORTANT

🚀 Security Architecture Upgrade (Breaking Change) To prevent cross-platform numeric ID collision attacks (e.g., a Twitter ID spoofing a DingTalk mobile number), NodeAuth now enforces Strict Namespace Isolation. For platforms verified by id (Telegram and Twitter): Your whitelist entries must be prefixed with the platform name, such as telegram:12345678 or twitter:87654321. Raw numbers are no longer allowed and will be rejected! Logins based on email and mobile are unaffected.

NodeAuth refuses public registration; you must preset the users allowed to enter.

VariableRequiredExamples & Description
OAUTH_ALLOWED_USERS✅Emails, prefixed Telegram/X (Twitter) IDs, or Web3 wallet addresses allowed to login. Separate multiple users with commas ,. E.g.: admin@example.com,telegram:12345678,twitter:1729837492,0xe0a156ce36****6a98

☁️ Login Platform Configuration (At least one, multiple supported) ​

You must configure at least one third-party login method (12 providers supported).

NOTE

Startup Check Note: Startup health checks currently inspect the 6 primary providers (GitHub, Telegram, Google, NodeLoc, Gitee, Cloudflare Access). If you use another provider exclusively, keep one of those configured or verify your health check status.

  1. Visit GitHub Developer Settings -> OAuth Apps -> New OAuth App.
  2. Homepage URL: https://your-domain.com
  3. Authorization callback URL: https://your-domain.com/oauth/callback
  4. Record the Client ID and Client Secret after registration.
  5. Fill in Environment Variables:
    • OAUTH_GITHUB_CLIENT_ID (Corresponds to GitHub's Client ID)
    • OAUTH_GITHUB_CLIENT_SECRET (Corresponds to GitHub's Client Secret)
    • OAUTH_GITHUB_REDIRECT_URI: https://your-domain.com/oauth/callback
Click to view: GitHub OAuth Configuration MockupGitHub OAuth Configuration Mockup

2. Cloudflare Access (Zero Trust) ​

  1. Go to Cloudflare Zero Trust Dashboard -> Access -> Applications.
  2. Click Add an Application -> select SaaS.
  3. Application name: nodeauth
  4. Authentication protocol: OIDC
  5. Redirect URL: https://your-domain.com/oauth/callback
  6. Get the Client ID and Client Secret from the configuration page.
  7. Fill in Environment Variables:
    • OAUTH_CLOUDFLARE_CLIENT_ID (Corresponds to Cloudflare's Client ID)
    • OAUTH_CLOUDFLARE_CLIENT_SECRET (Corresponds to Cloudflare's Client Secret)
    • OAUTH_CLOUDFLARE_REDIRECT_URI: https://your-domain.com/oauth/callback
    • OAUTH_CLOUDFLARE_ORG_DOMAIN: Your team domain (e.g., example.cloudflareaccess.com)
Click to view: Cloudflare Access OAuth Configuration MockupOpen Cloudflare Zero Trust Access Applications
Add a SaaS application in Cloudflare Zero Trust
Configure OIDC protocol and callback URI for NodeAuth
Copy Cloudflare Access Client ID and Client Secret
Save Cloudflare Access OIDC configuration

3. Google ​

  1. Go to the Google Cloud Console and create a new project.
  2. Navigate to API & Services -> OAuth consent screen and complete the basic setup.
  3. Navigate to Credentials -> Create Credentials -> OAuth client ID.
  4. Choose application type: Web application.
  5. Authorized redirect URIs: https://your-domain.com/oauth/callback
  6. Fill in Environment Variables:
    • OAUTH_GOOGLE_CLIENT_ID (Corresponds to Google's Client ID)
    • OAUTH_GOOGLE_CLIENT_SECRET (Corresponds to Google's Client Secret)
    • OAUTH_GOOGLE_REDIRECT_URI: https://your-domain.com/oauth/callback

4. Telegram ​

While Telegram doesn't require a REDIRECT_URI variable, you need to bind the domain via BotFather:

  1. Search for and add the official bot @BotFather on Telegram, send /newbot to create a bot.
  2. Record the generated Token (OAUTH_TELEGRAM_BOT_TOKEN) and Username (OAUTH_TELEGRAM_BOT_NAME).
  3. Send the /setdomain command to @BotFather, select your bot, and enter your application domain (e.g., nodeauth.pages.dev, without https).
  4. Critical Step (Register Webhook): Replace <Token>, <domain>, and <Secret> (at least 32 characters) in the following link and visit it once in your browser: https://api.telegram.org/bot<Token>/setWebhook?url=https://<domain>/api/telegram/webhook&secret_token=<Secret>
  5. Fill in Environment Variables:
    • OAUTH_TELEGRAM_BOT_NAME (Corresponds to Telegram Bot's Username)
    • OAUTH_TELEGRAM_BOT_TOKEN (Corresponds to Telegram Bot's Token)
    • OAUTH_TELEGRAM_WEBHOOK_SECRET: The <Secret> string you set above. Get a high-strength random string
    • (Optional) OAUTH_TELEGRAM_BOT_DOMAIN: Explicitly override callback domain under custom reverse proxies if needed.

5. Gitee ​

  1. Visit Gitee Third-party Application Settings -> Create Application.
  2. Application Callback Address: https://your-domain.com/oauth/callback
  3. Check permission: user_info.
  4. Fill in Environment Variables:
    • OAUTH_GITEE_CLIENT_ID (Corresponds to Gitee's Client ID)
    • OAUTH_GITEE_CLIENT_SECRET (Corresponds to Gitee's Client Secret)
    • OAUTH_GITEE_REDIRECT_URI: https://your-domain.com/oauth/callback

6. NodeLoc Community ​

  1. Visit NodeLoc OAuth Settings and create an application.
  2. Redirect URI: https://your-domain.com/oauth/callback
  3. Fill in Environment Variables:
    • OAUTH_NODELOC_CLIENT_ID (Corresponds to NodeLoc's Client ID)
    • OAUTH_NODELOC_CLIENT_SECRET (Corresponds to NodeLoc's Client Secret)
    • OAUTH_NODELOC_REDIRECT_URI: https://your-domain.com/oauth/callback

7. Web3 Wallet Login (WalletConnect) ​

  1. Register and create a new project at WalletConnect Cloud.
  2. Fill in Environment Variables:
    • OAUTH_WALLETCONNECT_PROJECT_ID (Corresponds to WalletConnect's Project ID)
  3. (Optional) OAUTH_WALLETCONNECT_RPC_URL for a custom RPC node, and OAUTH_WALLETCONNECT_SELF_PROXY=true to enable the built-in proxy.

8. X (Twitter) ​

Provides the smoothest login experience specifically for Crypto / Web3 users:

  1. Visit and log into the Twitter Developer Portal.
  2. Create or select your app under Projects & Apps.
  3. Navigate to User authentication set up and click Set up.
  4. App permissions: Check Read.
  5. Type of App: Select Web App, Automated App or Bot.
  6. Callback URI / Redirect URL: https://your-domain.com/oauth/callback
  7. Website URL: https://nodeauth.io or https://your-domain.com
  8. Save and record the generated Client ID and Client Secret (only shown once).
  9. Fill in Environment Variables:
    • OAUTH_TWITTER_CLIENT_ID (Corresponds to Twitter's Client ID)
    • OAUTH_TWITTER_CLIENT_SECRET (Corresponds to Twitter's Client Secret)
    • OAUTH_TWITTER_REDIRECT_URI: https://your-domain.com/oauth/callback

How to get your X account's numeric ID (for whitelisting)?

X (Twitter) login does not support email whitelisting; you must use your unique numeric ID. After logging into the X Developer Console, you can find it directly in your browser's address bar.

For example, if the current URL is https://console.x.com/accounts/2085375101801844736, then 2085375101801844736 is your numeric ID.

Simply enter twitter:2085375101801844736 into your OAUTH_ALLOWED_USERS environment variable to allow access for this account.

9. Lark (Global) / Feishu (China) ​

The configuration process for both is identical, differing only in the portal domains and environment variable prefixes.

  1. Visit and log into the open platform: open.larksuite.com for Lark Global, or open.feishu.cn for Feishu China.

  2. Enter the "Developer Console" and click Create Custom App.

  3. In the left navigation bar, find Security Settings, and add to "Redirect URLs": https://your-domain.com/oauth/callback.

  4. In the left navigation bar, find Permissions & Scopes, search at the top and check Obtain user email information (Permission ID is contact:user.email:readonly). Be sure to check this to ensure NodeAuth can obtain the email for whitelist verification.

  5. In the left navigation bar, find Version Management & Release, create a new version, configure the availability (e.g., "Specific Members" or "All Members"), and then Submit for Release. Otherwise, the permission and availability changes will not take effect.

  6. In the left navigation bar, find Credentials & Basic Info, and obtain the App ID and App Secret.

  7. Fill in Environment Variables: Depending on the version you are integrating, fill in the corresponding variables (you can configure both sets if your team uses both; two buttons will appear):

    For Lark (Global):

    • OAUTH_LARK_CLIENT_ID (Corresponds to Lark's App ID)
    • OAUTH_LARK_CLIENT_SECRET (Corresponds to Lark's App Secret)
    • OAUTH_LARK_REDIRECT_URI: https://your-domain.com/oauth/callback

    For Feishu (China):

    • OAUTH_FEISHU_CLIENT_ID (Corresponds to Feishu's App ID)
    • OAUTH_FEISHU_CLIENT_SECRET (Corresponds to Feishu's App Secret)
    • OAUTH_FEISHU_REDIRECT_URI: https://your-domain.com/oauth/callback

10. DingTalk ​

Supports SSO via DingTalk QR code or password. Since enterprise emails are often not enforced, NodeAuth supports using email or mobile number for whitelist verification.

  1. Visit and log into the DingTalk Open Platform.
  2. Go to "App Development - Custom App", and click Create App.
  3. In the left navigation bar, find Share Settings, and add to "Redirect URI": https://your-domain.com/oauth/callback.
  4. In the left navigation bar, find Permissions, and apply for:
    • Personal mobile phone information (used for whitelist verification)
    • Contact personal information read permission (used to obtain email and basic info)
  5. In the left navigation bar, find Version Management & Release, create a new version, set the availability range (e.g., "Some Members" or "All Members"), and Submit for Release, otherwise permission changes will not take effect.
  6. In the left navigation bar, find Basic Info, and obtain the AppKey and AppSecret.
  7. Fill in Environment Variables:
    • OAUTH_DINGTALK_CLIENT_ID (corresponds to DingTalk AppKey)
    • OAUTH_DINGTALK_CLIENT_SECRET (corresponds to DingTalk AppSecret)
    • OAUTH_DINGTALK_REDIRECT_URI: https://your-domain.com/oauth/callback
    • OAUTH_DINGTALK_CORP_ID (Optional, skips organization selection during login if specified)

11. Microsoft (Azure AD) ​

Supports Microsoft Personal accounts and Work or School accounts.

  1. Visit and log into Azure Portal - App registrations.
  2. Click New registration.
  3. Name: NodeAuth
  4. Supported account types: Recommended to choose Accounts in any organizational directory and personal Microsoft accounts (e.g. Skype, Xbox) (Multi-tenant mode).
  5. Redirect URI: Select Web, and fill in https://your-domain.com/oauth/callback.
  6. After registration, record the Application (client) ID on the Overview page.
  7. In the left navigation bar, find Certificates & secrets, create a New client secret, and record its Value.
  8. Fill in Environment Variables:
    • OAUTH_MICROSOFT_CLIENT_ID (Corresponds to Microsoft's Application (client) ID)
    • OAUTH_MICROSOFT_CLIENT_SECRET (Corresponds to Microsoft's Client Secret Value)
    • OAUTH_MICROSOFT_REDIRECT_URI: https://your-domain.com/oauth/callback
    • (Optional) OAUTH_MICROSOFT_TENANT_ID: Defaults to common (Multi-tenant). If you chose single tenant in step 4, fill in your Tenant ID here for stricter isolation.

📦 Automatic Cloud Backup Configuration (Optional) ​

For detailed configuration steps, please refer to the Cloud Backup Guide.

WARNING

For security isolation and to avoid triggering the "Unverified App" warning, backup configurations are now completely decoupled from login configurations. Please create a dedicated OAuth application for the cloud drive you intend to use (do not share it with the login app).

Cloud DriveClient ID VariableClient Secret VariableBackup Redirect URI VariableOther Specific Variables
GoogleOAUTH_GOOGLE_BACKUP_CLIENT_IDOAUTH_GOOGLE_BACKUP_CLIENT_SECRETOAUTH_GOOGLE_BACKUP_REDIRECT_URI-
OneDriveOAUTH_MICROSOFT_BACKUP_CLIENT_IDOAUTH_MICROSOFT_BACKUP_CLIENT_SECRETOAUTH_MICROSOFT_BACKUP_REDIRECT_URIOAUTH_MICROSOFT_BACKUP_TENANT_ID
DropboxOAUTH_DROPBOX_BACKUP_CLIENT_IDOAUTH_DROPBOX_BACKUP_CLIENT_SECRETOAUTH_DROPBOX_BACKUP_REDIRECT_URI-
BaiduOAUTH_BAIDU_BACKUP_CLIENT_IDOAUTH_BAIDU_BACKUP_CLIENT_SECRETOAUTH_BAIDU_BACKUP_REDIRECT_URI-

Note: Backup Redirect URIs follow the format https://your-domain.com/api/backups/oauth/[platform]/callback


🗄️ Database Engine Configuration (Only for Docker Deployment) ​

If you use Cloudflare Workers deployment, the system will automatically use the D1 database, and no configuration of the following variables is necessary.

If you are deploying on Docker or your own server:

  • Default using SQLite: Simply mount the /app/data directory; no database connection configuration is needed.
  • Using MySQL / PostgreSQL / LibSQL / D1: Please configure DB_ENGINE, followed by either Method 1 or Method 2 below.
Basic VariableRequiredDefaultDescription
DB_ENGINE✅sqliteDatabase Type: supports sqlite, mysql, postgresql, libsql, d1.

The simplest modern configuration method. Just one line of standard connection URL connects your database, ideal for Turso, Supabase, or external cloud databases.

VariableRequiredDefaultDescription
DB_URL✅-Standard connection string. e.g., mysql://user:pass@host:3306/dbname or postgresql://....
DB_TOKENOn-demand-Cloud database auth token. Required only when connecting to libsql (e.g., Turso) or d1 (Cloudflare D1 Proxy) which require token authentication.
DB_SSL❌falseWhether to enable SSL connection (recommended as true when connecting to remote cloud databases).

Method 2: Traditional Separate Parameters (Alternative) ​

If you prefer traditional separate parameter configuration (e.g., connecting to a database within Docker internal networks), fill in the fields below (if DB_URL above is provided, all parameters in this section are automatically ignored).

VariableRequiredDefaultDescription
DB_HOST✅-Database server address. Supports local localhost, Docker service name (e.g., mysql-db), remote domain, or IP.
DB_PORT✅-Database port. MySQL default is 3306, PostgreSQL default is 5432.
DB_USER✅-Database username.
DB_PASSWORD✅-Database password.
DB_NAME✅-Specific database name.
DB_SSL❌falseWhether to enable SSL connection.

🌐 Tunnel Configuration (Optional) ​

When deploying via Docker and wishing to securely expose services via Cloudflare Tunnel without opening inbound ports, we recommend configuring this variable:

VariableDefaultDescription
CLOUDFLARE_TUNNEL_TOKEN-Official Cloudflare Tunnel Token. Once configured, the container will automatically launch the built-in cloudflared daemon upon startup without exposing any host inbound ports. We recommend encrypting it with aes:, base64:, or hex: prefixes.

⚙️ Other Optional Configurations ​

VariableDefaultDescription
LOG_LEVELinfoLog level: debug, info, warn, error
PORT3000(Docker only) Backend listening port
SQLITE_DB_PATH./data/nodeauth.db(Docker SQLite only) Custom SQLite file path
SESSION_TTL_DAYS30Session & device token lifetime in days
OAUTH_ALLOW_ALLfalsePublic demo switch (true/1 allows open login; 2 enables read-only demo mode—never enable in production)

🛡️ Config Hardening (Optional) ​

For ultimate security, NodeAuth supports Prefix Transformation, allowing sensitive information (such as API keys and database passwords) to be stored as encrypted ciphertext in configuration files.

Why use this? ​

Even if your docker-compose.yml or environment variable file is accidentally leaked, third parties cannot directly read the actual plaintext credentials, building a solid defense-in-depth line.

🔐 Security Tiers ​

Depending on the nature of the variables, the system provides two levels of security logic:

Security TierVariablesHandling (Prefix)Description
⭐ ObfuscationNODEAUTH_LICENSE, JWT_SECRETbase64:, hex:Root anchor for session signing. Supports basic encoding and hex obfuscation.
🛡️ EncryptionAll other sensitive variablesbase64:, hex:, aes:Includes database passwords (DB_PASSWORD, DB_TOKEN, DB_URL), access allowlists (OAUTH_ALLOWED_USERS), tunnel credentials (CLOUDFLARE_TUNNEL_TOKEN), and third-party OAuth credentials (OAUTH_*). Highly recommend using aes: for robust encryption.

🛠️ Quick Start (3 Steps) ​

  1. Open Tool: Visit the official NodeAuth Deploy Helper (tools.nodeauth.io).
  2. Generate & Encrypt:
    • Generate a 64-bit random string for your JWT_SECRET.
    • Obtain your NODEAUTH_LICENSE from license.nextmatrix.app/byos.
    • Paste your secrets into the "AES Encryptor" box, provide your Root Key (plaintext JWT_SECRET) and License (plaintext NODEAUTH_LICENSE), and execute encryption.
  3. Apply to File: Copy the entire generated lines (including the aes: or base64: prefix) and replace the values in your config file.

Example:

yaml
# Example snippet
JWT_SECRET=base64:MjAyNjA0MDJfTm9kZUF1dGhfUm9...
OAUTH_GOOGLE_CLIENT_ID=aes:iv:tag:cipher_text_here...
ENCRYPTION_KEY=aes:iv:tag:cipher_text_here...

CAUTION

Warning: Modifying ENCRYPTION_KEY will cause verification code calculation errors or decryption failures for all stored accounts. Do not change it arbitrarily until backups are completed.