Skip to content

Add Cloudflare Zero Trust SSO authentication#1

Open
sachin-anyteam wants to merge 4 commits intomasterfrom
feature/cloudflare-zero-trust-auth
Open

Add Cloudflare Zero Trust SSO authentication#1
sachin-anyteam wants to merge 4 commits intomasterfrom
feature/cloudflare-zero-trust-auth

Conversation

@sachin-anyteam
Copy link
Copy Markdown

Summary

  • Implement Cloudflare Zero Trust (Access) as an SSO authentication provider
  • Enable users authenticated via Cloudflare to access Metabase without a second login step
  • Add comprehensive security measures including RS256-only algorithm validation and SSRF protection
  • Support JIT user provisioning with optional require-auth mode

Key Changes

New Files

File Purpose
src/metabase/sso/cloudflare_zero_trust/settings.clj Configuration settings
src/metabase/sso/cloudflare_zero_trust/jwt.clj JWT validation with JWKS
src/metabase/sso/providers/cloudflare_zero_trust.clj Auth provider
src/metabase/server/middleware/cloudflare_access.clj Request middleware

Modified Files

  • src/metabase/server/handler.clj - Added middleware to chain
  • src/metabase/sso/init.clj - Added provider require
  • src/metabase/sso/settings.clj - Added to sso-enabled? check

Security Features

  • RS256-only - Prevents algorithm confusion attacks (alg=none)
  • SSRF protection - Validates JWKS URL format strictly
  • JWKS caching - With automatic refresh on key rotation
  • Deactivated user handling - Rejects login for deactivated accounts
  • Audit logging - Events for auth success/failure/provisioning

Configuration

MB_CLOUDFLARE_ZERO_TRUST_ENABLED=true
MB_CLOUDFLARE_ZERO_TRUST_TEAM_NAME=your-team
MB_CLOUDFLARE_ZERO_TRUST_AUDIENCE_TAG=your-audience-tag
MB_CLOUDFLARE_ZERO_TRUST_USER_PROVISIONING_ENABLED=true
MB_CLOUDFLARE_ZERO_TRUST_REQUIRE_AUTH=false

Test plan

  • Unit tests for JWT validation (alg=none attacks, signature tampering, claim validation)
  • Middleware tests for various auth modes
  • Integration test with actual Cloudflare Zero Trust setup
  • Verify existing auth methods continue to work when CF auth is optional
  • Verify require-auth mode blocks direct access

🤖 Generated with Claude Code

sachin-anyteam and others added 4 commits February 6, 2026 17:02
Implement Cloudflare Zero Trust (Access) as an authentication provider,
enabling users authenticated via Cloudflare to access Metabase without
a second login step.

Features:
- JWT validation using RS256 with Cloudflare's JWKS endpoint
- JIT user provisioning (auto-create users on first login)
- Optional require-auth mode to enforce Cloudflare-only access
- Allowlisted paths for health checks and setup endpoints

Security measures:
- RS256-only algorithm allowlist (prevents alg=none attacks)
- SSRF protection for JWKS URL validation
- JWKS caching with automatic refresh on key rotation
- Deactivated user rejection
- Email normalization before user lookup
- Audit event logging

Configuration via environment variables:
- MB_CLOUDFLARE_ZERO_TRUST_ENABLED
- MB_CLOUDFLARE_ZERO_TRUST_TEAM_NAME
- MB_CLOUDFLARE_ZERO_TRUST_AUDIENCE_TAG
- MB_CLOUDFLARE_ZERO_TRUST_USER_PROVISIONING_ENABLED
- MB_CLOUDFLARE_ZERO_TRUST_REQUIRE_AUTH
- MB_CLOUDFLARE_ZERO_TRUST_ALLOWED_PATHS

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Fix Base64 URL decoder usage in JWT header decoding
- Use with-redefs instead of with-temporary-setting-values in middleware tests
- Use correct metabase.test namespace in test files

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add derive statements to register Cloudflare Zero Trust events
with the Metabase event system. Events must derive from :metabase/event
for publish-event! to work.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Allow disabling password login without requiring a premium license.
This enables the MB_ENABLE_PASSWORD_LOGIN=false environment variable
to work in the open source build.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant