Authentication
NGFW.sh uses Clerk.com for authentication, providing secure authentication with multiple methods including email/password, phone, OAuth, MFA, and passkeys.
Supported Authentication Methods
Section titled “Supported Authentication Methods”- Email/Password
- Phone Number (SMS)
- OAuth (Google, GitHub)
- Multi-factor Authentication (MFA)
- Passkeys (WebAuthn)
Obtaining a Token
Section titled “Obtaining a Token”Via the Web Portal
Section titled “Via the Web Portal”- Sign in at ngfw.sh
- Navigate to Profile → API Tokens
- Click Generate Token
- Copy the token (it won’t be shown again)
Via OAuth Flow
Section titled “Via OAuth Flow”For applications that need to authenticate users:
// Using Clerk's JavaScript SDKimport Clerk from '@clerk/clerk-js';
const clerk = new Clerk('pk_test_dG91Z2gtdW5pY29ybi0yNS5jbGVyay5hY2NvdW50cy5kZXYk');await clerk.load();
// Sign in with redirectawait clerk.client.signIn.create({ identifier: 'user@example.com', password: 'password'});Using the Token
Section titled “Using the Token”Include the token in the Authorization header:
curl https://api.ngfw.sh/api/system/status \ -H "Authorization: Bearer eyJhbGciOiJSUzI1NiIs..."Token Claims
Section titled “Token Claims”JWT tokens include the following claims:
| Claim | Description |
|---|---|
sub | User ID |
org_id | Organization ID (business plans) |
plan | Subscription plan (starter, pro, business, business_plus) |
exp | Expiration timestamp |
Token Expiration
Section titled “Token Expiration”- Access tokens expire after 1 hour
- Use refresh tokens to obtain new access tokens
- API tokens (generated from dashboard) expire after 1 year
Router Agent Authentication
Section titled “Router Agent Authentication”Router agents use a separate authentication mechanism with device-specific API keys:
- Register a device in the dashboard
- Copy the generated API key
- Configure the agent with the key
ngfw-agent configure --api-key ngfw_dev_abc123...Agent API keys are stored in Cloudflare KV and can be revoked from the dashboard at any time.
Security Best Practices
Section titled “Security Best Practices”- Never expose tokens in client-side code - Use server-side API calls
- Rotate tokens regularly - Especially for automated systems
- Use environment variables - Don’t hardcode tokens
- Limit token scope - Request only necessary permissions
- Monitor API usage - Check for unusual patterns in the dashboard