Authentication
Setup and configure authentication for Pixelflare CDN deployments, using a provider of your choice.
Pixelflare supports the following authentication methods:
- Cloudflare Zero Trust - Cloudflare's built-in enterprise identity + access management
- OAuth - Direct OAuth integration using Auth.js
- No Authentication - Disable authentication entirely
- Mock Authentication - For local development only
Supported Identity Providers
| Provider | OAuth | Cloudflare Zero |
|---|---|---|
| Apple | ✅ | ❌ |
| Atlassian | ✅ | ❌ |
| Auth0 | ✅ | *️⃣ |
| Authentik | ✅ | *️⃣ |
| Azure Active Directory (incl. B2C) | ✅ | ✅ |
| Amazon Cognito | ✅ | *️⃣ |
| Discord | ✅ | ❌ |
| ✅ | ✅ | |
| GitHub | ✅ | ✅ |
| GitLab | ✅ | *️⃣ |
| ✅ | ✅ | |
| ✅ | ❌ | |
| Keycloak | ✅ | *️⃣ |
| ✅ | ✅ | |
| Okta | ✅ | ✅ |
| OneLogin | ✅ | ✅ |
| Patreon | ✅ | ❌ |
| PingOne / Ping Identity | ❌ | ✅ |
| ✅ | ❌ | |
| Salesforce | ❌ | *️⃣ |
| Slack | ✅ | ❌ |
| Twitter (v2 OAuth) | ✅ | ❌ |
| Yandex | ✅ | ✅ |
| Zoom | ✅ | *️⃣ |
Legend: ✅ Supported | ❌ Not Supported | *️⃣ Supported Indirectly
Note:
- GitLab, Salesforce, Zoom, Keycloak, Authentik, WorkOS and BoxyHQ SAML are supports on indirectly Cloudflare via SAML
- Auth0, Amazon Cognito, Keycloak, Authentik, WorkOS as well as other providers are supported on Cloudflare via OIDC
- Some auth providers are untested, and may/probably will require additional configuration, within the app and Cloudflare
Security Best Practices
General
- Always use HTTPS in production - Required for secure cookies (
__Secure-and__Host-prefixes) - Keep secrets secure - Use Cloudflare Workers secrets or environment variables, never commit to git
- Rotate secrets regularly - Change
AUTH_SECRETandAPI_HASH_SECRETperiodically - Use minimum required scopes - Grant API keys only the permissions they need
- Monitor authentication logs - Enable audit logging to track authentication events
Cloudflare Zero Trust
- Use Zero Trust Policies - Implement granular access policies based on user identity
- Enable session recording (optional) - Track user activities for security auditing
- Configure session duration - Balance security and user experience
- Use email verification - Require verified email addresses for access
- Enable MFA - Require multi-factor authentication for sensitive operations
Auth.js
- Use strong AUTH_SECRET - Minimum 32 bytes of entropy (use
openssl rand -base64 32) - Protect OAuth secrets - Store
GITHUB_OAUTH_CLIENT_SECRETas Workers secret - Configure OAuth scopes - Request only required GitHub scopes
- Set appropriate session maxAge - Default is 7 days, adjust based on security requirements
- Use production cookie prefixes -
__Secure-prefix requires HTTPS
API Keys
- Set expiration dates - API keys should have limited lifetimes
- Use IP whitelisting - Restrict API key usage to known IP addresses
- Rotate keys regularly - Replace API keys periodically, especially after team changes
- Delete unused keys - Remove API keys that are no longer needed
- Monitor key usage - Track
last_used_attimestamps to identify inactive keys