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.
| Variable | Required | Description & 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.
| Variable | Required | Examples & 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. GitHub (Recommended, Easiest)
- Visit GitHub Developer Settings -> OAuth Apps -> New OAuth App.
- Homepage URL:
https://your-domain.com - Authorization callback URL:
https://your-domain.com/oauth/callback - Record the
Client IDandClient Secretafter registration. - 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 Mockup

2. Cloudflare Access (Zero Trust)
- Go to Cloudflare Zero Trust Dashboard -> Access -> Applications.
- Click Add an Application -> select SaaS.
- Application name:
nodeauth - Authentication protocol:
OIDC - Redirect URL:
https://your-domain.com/oauth/callback - Get the
Client IDandClient Secretfrom the configuration page. - 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/callbackOAUTH_CLOUDFLARE_ORG_DOMAIN: Your team domain (e.g.,example.cloudflareaccess.com)
Click to view: Cloudflare Access OAuth Configuration Mockup





3. Google
- Go to the Google Cloud Console and create a new project.
- Navigate to API & Services -> OAuth consent screen and complete the basic setup.
- Navigate to Credentials -> Create Credentials -> OAuth client ID.
- Choose application type: Web application.
- Authorized redirect URIs:
https://your-domain.com/oauth/callback - 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:
- Search for and add the official bot @BotFather on Telegram, send
/newbotto create a bot. - Record the generated Token (
OAUTH_TELEGRAM_BOT_TOKEN) and Username (OAUTH_TELEGRAM_BOT_NAME). - Send the
/setdomaincommand to @BotFather, select your bot, and enter your application domain (e.g.,nodeauth.pages.dev, without https). - 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> - 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
- Visit Gitee Third-party Application Settings -> Create Application.
- Application Callback Address:
https://your-domain.com/oauth/callback - Check permission:
user_info. - 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
- Visit NodeLoc OAuth Settings and create an application.
- Redirect URI:
https://your-domain.com/oauth/callback - 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)
- Register and create a new project at WalletConnect Cloud.
- Fill in Environment Variables:
OAUTH_WALLETCONNECT_PROJECT_ID(Corresponds to WalletConnect's Project ID)
- (Optional)
OAUTH_WALLETCONNECT_RPC_URLfor a custom RPC node, andOAUTH_WALLETCONNECT_SELF_PROXY=trueto enable the built-in proxy.
8. X (Twitter)
Provides the smoothest login experience specifically for Crypto / Web3 users:
- Visit and log into the Twitter Developer Portal.
- Create or select your app under Projects & Apps.
- Navigate to User authentication set up and click
Set up. - App permissions: Check
Read. - Type of App: Select
Web App, Automated App or Bot. - Callback URI / Redirect URL:
https://your-domain.com/oauth/callback - Website URL:
https://nodeauth.ioorhttps://your-domain.com - Save and record the generated Client ID and Client Secret (only shown once).
- 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.
Visit and log into the open platform: open.larksuite.com for Lark Global, or open.feishu.cn for Feishu China.
Enter the "Developer Console" and click Create Custom App.
In the left navigation bar, find Security Settings, and add to "Redirect URLs":
https://your-domain.com/oauth/callback.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.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.
In the left navigation bar, find Credentials & Basic Info, and obtain the App ID and App Secret.
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.
- Visit and log into the DingTalk Open Platform.
- Go to "App Development - Custom App", and click Create App.
- In the left navigation bar, find Share Settings, and add to "Redirect URI":
https://your-domain.com/oauth/callback. - 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)
- 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.
- In the left navigation bar, find Basic Info, and obtain the AppKey and AppSecret.
- 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/callbackOAUTH_DINGTALK_CORP_ID(Optional, skips organization selection during login if specified)
11. Microsoft (Azure AD)
Supports Microsoft Personal accounts and Work or School accounts.
- Visit and log into Azure Portal - App registrations.
- Click New registration.
- Name:
NodeAuth - Supported account types: Recommended to choose
Accounts in any organizational directory and personal Microsoft accounts (e.g. Skype, Xbox)(Multi-tenant mode). - Redirect URI: Select
Web, and fill inhttps://your-domain.com/oauth/callback. - After registration, record the
Application (client) IDon the Overview page. - In the left navigation bar, find Certificates & secrets, create a
New client secret, and record its Value. - 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 tocommon(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 Drive | Client ID Variable | Client Secret Variable | Backup Redirect URI Variable | Other Specific Variables |
|---|---|---|---|---|
OAUTH_GOOGLE_BACKUP_CLIENT_ID | OAUTH_GOOGLE_BACKUP_CLIENT_SECRET | OAUTH_GOOGLE_BACKUP_REDIRECT_URI | - | |
| OneDrive | OAUTH_MICROSOFT_BACKUP_CLIENT_ID | OAUTH_MICROSOFT_BACKUP_CLIENT_SECRET | OAUTH_MICROSOFT_BACKUP_REDIRECT_URI | OAUTH_MICROSOFT_BACKUP_TENANT_ID |
| Dropbox | OAUTH_DROPBOX_BACKUP_CLIENT_ID | OAUTH_DROPBOX_BACKUP_CLIENT_SECRET | OAUTH_DROPBOX_BACKUP_REDIRECT_URI | - |
| Baidu | OAUTH_BAIDU_BACKUP_CLIENT_ID | OAUTH_BAIDU_BACKUP_CLIENT_SECRET | OAUTH_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/datadirectory; 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 Variable | Required | Default | Description |
|---|---|---|---|
DB_ENGINE | ✅ | sqlite | Database Type: supports sqlite, mysql, postgresql, libsql, d1. |
Method 1: Full Connection String (⭐ Highly Recommended)
The simplest modern configuration method. Just one line of standard connection URL connects your database, ideal for Turso, Supabase, or external cloud databases.
| Variable | Required | Default | Description |
|---|---|---|---|
DB_URL | ✅ | - | Standard connection string. e.g., mysql://user:pass@host:3306/dbname or postgresql://.... |
DB_TOKEN | On-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 | ❌ | false | Whether 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).
| Variable | Required | Default | Description |
|---|---|---|---|
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 | ❌ | false | Whether 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:
| Variable | Default | Description |
|---|---|---|
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
| Variable | Default | Description |
|---|---|---|
LOG_LEVEL | info | Log level: debug, info, warn, error |
PORT | 3000 | (Docker only) Backend listening port |
SQLITE_DB_PATH | ./data/nodeauth.db | (Docker SQLite only) Custom SQLite file path |
SESSION_TTL_DAYS | 30 | Session & device token lifetime in days |
OAUTH_ALLOW_ALL | false | Public 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 Tier | Variables | Handling (Prefix) | Description |
|---|---|---|---|
| ⭐ Obfuscation | NODEAUTH_LICENSE, JWT_SECRET | base64:, hex: | Root anchor for session signing. Supports basic encoding and hex obfuscation. |
| 🛡️ Encryption | All other sensitive variables | base64:, 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)
- Open Tool: Visit the official NodeAuth Deploy Helper (tools.nodeauth.io).
- Generate & Encrypt:
- Generate a 64-bit random string for your
JWT_SECRET. - Obtain your
NODEAUTH_LICENSEfrom license.nextmatrix.app/byos. - Paste your secrets into the "AES Encryptor" box, provide your
Root Key (plaintext JWT_SECRET)andLicense (plaintext NODEAUTH_LICENSE), and execute encryption.
- Generate a 64-bit random string for your
- Apply to File: Copy the entire generated lines (including the
aes:orbase64:prefix) and replace the values in your config file.
Example:
# 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.