A Next.js application that provides a customized frontend for Databricks with multiple authentication strategies and embedded Databricks apps.
- Prerequisites
- Environment Setup
- Database Setup
- Databricks OAuth Configuration
- Go Proxy Setup (VSCode Editor)
- Local Development
- Deployment to Vercel
- Architecture
- Node.js 18+ and pnpm
- PostgreSQL database (we recommend Neon)
- Databricks account with admin access
- Go 1.21+ (for the proxy server)
- Vercel account (for deployment)
cp .env.example .env.localEdit .env.local and fill in the required values:
DATABRICKS_U2M_CLIENT_ID=your_u2m_client_id_here
DATABRICKS_U2M_CLIENT_SECRET=your_u2m_client_secret_here
DATABRICKS_ACCOUNT_ID=your_account_id_hereDATABASE_URL=postgresql://user:password@host:port/database?sslmode=require# Generate with: openssl rand -base64 32
BETTER_AUTH_SECRET=your_better_auth_secret_here
BETTER_AUTH_URL=http://localhost:3000
NEXT_PUBLIC_BETTER_AUTH_URL=http://localhost:3000
# Generate with: openssl rand -hex 32
ENCRYPTION_KEY=your_64_character_hex_encoded_encryption_key_hereNEXT_PUBLIC_PROXY_URL=https://your-proxy-url.com
DATABRICKS_APP_URL=https://your-code-editor-app.databricksapps.compnpm installThe database schema is defined using Drizzle ORM. To push the schema to your database:
# Push schema to database
pnpm drizzle-kit push
# Or generate and run migrations
pnpm drizzle-kit generate
pnpm drizzle-kit migrateYou can open Drizzle Studio to verify your schema:
pnpm drizzle-kit studioThis will open a web interface at https://local.drizzle.studio where you can view and manage your database.
-
Log in to Databricks Account Console
- Navigate to your Databricks account console
- You must be a Databricks account administrator
-
Navigate to OAuth Settings
- Click the Settings icon in the sidebar
- Select the "App connections" tab
- Click "Add connection"
-
Configure OAuth App
- Name: Give your app a descriptive name (e.g., "FireFly Analytics")
- Redirect URLs: Add your callback URLs:
http://localhost:3000/api/oauth/databricks/callback https://your-domain.com/api/oauth/databricks/callback - Scopes: Select the following scopes:
all-apis(required for full Databricks API access)offline_access(required for refresh tokens)openidprofileemail
- Client Type: Select "Confidential" (generates a client secret)
- Token TTL: Set access token TTL (default: 60 minutes)
- Refresh Token TTL: Set refresh token TTL (default: 90 days)
-
Save Credentials
- Copy the Client ID to
DATABRICKS_U2M_CLIENT_ID - Copy the Client Secret to
DATABRICKS_U2M_CLIENT_SECRET - Copy your Account ID to
DATABRICKS_ACCOUNT_ID- Find this in your Databricks account console URL:
https://accounts.cloud.databricks.com/accounts/{ACCOUNT_ID}
- Find this in your Databricks account console URL:
- Copy the Client ID to
You can also create an OAuth app using the Databricks CLI:
databricks account custom-app-integration create \
--confidential \
--json '{
"name":"FireFly Analytics",
"redirect_urls":["http://localhost:3000/api/oauth/databricks/callback"],
"scopes":["all-apis", "offline_access", "openid", "profile", "email"]
}'The Go proxy enables embedding Databricks Lakehouse Apps (like the VSCode editor) without exposing Databricks SSO to end users. It handles OAuth token encryption/decryption and proxies HTTP/WebSocket requests.
cd gogo mod tidyCreate a .env file in the go directory:
ENCRYPTION_KEY=same_64_character_hex_key_from_main_env
APP_DOMAIN_SUFFIX=com
PORT=8090Important: The ENCRYPTION_KEY must be the same as in your main .env.local file.
make buildmake runThe proxy will start on http://localhost:8090.
- Token Encryption: Next.js encrypts OAuth tokens server-side using AES-256-GCM
- URL Embedding: Encrypted tokens are embedded in proxy URLs sent to the browser
- Token Decryption: The Go proxy decrypts tokens and injects them as Authorization headers
- Request Proxying: HTTP and WebSocket requests are proxied to Databricks apps
- No SSO Exposure: Users never see Databricks login screens
For production, deploy the Go proxy to:
- Docker: Build a container and deploy to ECS, Kubernetes, or Cloud Run
- VM: Run directly on a VM with systemd service
- Serverless: Deploy to AWS Lambda or Google Cloud Functions
Update NEXT_PUBLIC_PROXY_URL in your environment to point to the deployed proxy.
pnpm devcd go
make runNavigate to http://localhost:3000
# Run development server
pnpm dev
# Build for production
pnpm build
# Test build (uses .next-test directory)
pnpm testBuild
# Start production server
pnpm start
# Run linter
pnpm lint
# Format code
pnpm formatpnpm install -g vercelvercel login
vercel linkNavigate to your project in the Vercel dashboard:
- Go to Settings → Environment Variables
- Add all environment variables from
.env.example:- Set variables for Production, Preview, and Development environments
- Use
NEXT_PUBLIC_prefix for client-side variables
- Important variables to set:
DATABRICKS_U2M_CLIENT_ID DATABRICKS_U2M_CLIENT_SECRET DATABRICKS_ACCOUNT_ID DATABASE_URL BETTER_AUTH_SECRET BETTER_AUTH_URL (use your production URL) NEXT_PUBLIC_BETTER_AUTH_URL (use your production URL) ENCRYPTION_KEY NEXT_PUBLIC_PROXY_URL DATABRICKS_APP_URL
Important: For production deployment, you must use your actual domain name for certain URLs:
- BETTER_AUTH_URL: Use your production domain (e.g.,
https://www.firefly-analytics.com) - NEXT_PUBLIC_BETTER_AUTH_URL: Use your production domain (e.g.,
https://www.firefly-analytics.com) - NEXT_PUBLIC_PROXY_URL: Use your deployed Go proxy URL (e.g.,
https://proxy.firefly-analytics.com)
For our production deployment at FireFly Analytics:
BETTER_AUTH_URL=https://www.firefly-analytics.com
NEXT_PUBLIC_BETTER_AUTH_URL=https://www.firefly-analytics.com
NEXT_PUBLIC_PROXY_URL=https://app-proxy.firefly-analytics.comReplace www.firefly-analytics.com with your own domain name.
In your Databricks OAuth app configuration, add your production deployment URL:
If using a custom domain:
https://www.firefly-analytics.com/api/oauth/databricks/callback
If using Vercel's default domain:
https://your-app.vercel.app/api/oauth/databricks/callback
Replace with your actual production domain. For our deployment, we use:
https://www.firefly-analytics.com/api/oauth/databricks/callback
- Push your code to GitHub/GitLab/Bitbucket
- Import the repository in Vercel dashboard
- Vercel will automatically deploy on every push
# Deploy to production
vercel --prod
# Deploy to preview
vercelAfter deployment:
- Check that all environment variables are set correctly
- Test the OAuth flow
- Verify database connectivity
- Ensure the Go proxy is accessible
The Go proxy should be deployed separately (not on Vercel):
Recommended Options:
- Docker on Cloud Run/ECS: Containerize and deploy to managed container platforms
- VM with systemd: Deploy to a dedicated VM for maximum control
- AWS Lambda/Cloud Functions: Deploy as a serverless function
Update NEXT_PUBLIC_PROXY_URL in Vercel environment variables to point to your deployed proxy.
This application supports multiple authentication strategies:
- Login With Databricks: Per-workspace authentication using Databricks native OAuth
- Custom Federation: Multi-tenant authentication with custom identity providers
- Login With Okta: Tenant-based authentication with service principal identity mapping
- Login With Guest User: Coming Soon
- Organization Support: Multi-tenant architecture with organization management
- Embedded Databricks Apps: VSCode editor embedded without SSO exposure
- Notebooks: Interactive notebooks with full Databricks functionality
- SQL Editor: Advanced SQL editor with visual query builder
- Data Catalog: Browse Unity Catalog with a modern interface
- Frontend: Next.js 15 with App Router, React, TypeScript
- Styling: Tailwind CSS, shadcn/ui components
- Database: PostgreSQL with Drizzle ORM
- Authentication: Better Auth with OAuth integration
- Proxy: Go reverse proxy for secure token handling
- Deployment: Vercel (frontend), Cloud platform of choice (proxy)
For detailed architectural documentation, visit:
Please note that this project is provided for your exploration only and is not formally supported by Databricks with Service Level Agreements (SLAs). They are provided AS-IS, and we do not make any guarantees. Please do not submit a support ticket relating to any issues arising from the use of this project.
Any issues discovered through the use of this project should be filed as GitHub Issues on this repository. They will be reviewed as time permits, but no formal SLAs for support exist.
This project is licensed under the Databricks License. See the LICENSE file for details.