Skip to content

feat(auth): add OIDC/Keycloak authentication with Minecraft UUID support#78

Open
hbrombeer wants to merge 5 commits intomainfrom
feat/oidc-keycloak-auth
Open

feat(auth): add OIDC/Keycloak authentication with Minecraft UUID support#78
hbrombeer wants to merge 5 commits intomainfrom
feat/oidc-keycloak-auth

Conversation

@hbrombeer
Copy link
Member

Pull Request

Description

Add full OIDC authentication support via Keycloak, including Minecraft identity provider integration. This enables OIDC-only login mode where the traditional email/password form is hidden, and Minecraft UUIDs from Keycloak tokens are extracted and persisted in the user table.

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • 💥 Breaking change
  • ♻️ Refactoring
  • 📚 Documentation
  • 🔧 Chore

Related Issues

  • Relates to OIDC/Keycloak integration for grounds.gg platform

Testing

  • Manual testing completed
  • Deployed and tested in k3d dev cluster with Keycloak
  • Verified OIDC login flow end-to-end (Keycloak → Minecraft IDP → Cockpit)
  • Verified Minecraft UUID extraction from access token claims
  • Verified email/password form hidden in OIDC-only mode
  • Verified health endpoint responds correctly for K8s probes

Checklist

  • I have performed a self-review of my own code
  • Tests have been added/updated and pass (if needed)
  • Documentation has been updated (if needed)

Changes

lib/auth.ts

  • Support split OIDC endpoints (OIDC_AUTHORIZATION_URL + OIDC_TOKEN_URL) as alternative to OIDC_DISCOVERY_URL for split-horizon DNS setups
  • Make email/password login configurable via DISABLE_EMAIL_PASSWORD env var
  • Add preferred_username fallback for email/name (Minecraft accounts without email)
  • Extract minecraft_uuid from OIDC token claims and persist to DB
  • Consolidate duplicate mapProfileToUser update paths

prisma/schema.prisma

  • Add minecraftUuid String? @unique field to User model

app/[lang]/login/login-client.tsx

  • Conditionally hide email/password form when NEXT_PUBLIC_DISABLE_EMAIL_PASSWORD=true
  • Show only OIDC provider button in OIDC-only mode

Dockerfile

  • Add ARG/ENV for NEXT_PUBLIC_* vars (required at build time for Next.js inlining)
  • Run prisma generate before next build

app/api/health/route.ts

  • New /api/health endpoint for Kubernetes liveness/readiness probes

hbrombeer and others added 5 commits March 12, 2026 14:10
Add /api/health endpoint returning JSON status for Kubernetes
liveness and readiness probes in standalone deployment mode.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add ARG/ENV for NEXT_PUBLIC_DISABLE_EMAIL_PASSWORD,
  NEXT_PUBLIC_OIDC_PROVIDER_ID, and NEXT_PUBLIC_BETTER_AUTH_URL
  so Next.js can inline them during the build stage
- Run prisma generate before next build to ensure the Prisma client
  is up-to-date with the schema

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Support explicit OIDC_AUTHORIZATION_URL and OIDC_TOKEN_URL as
  alternative to OIDC_DISCOVERY_URL for split-horizon DNS setups
  (external auth URL for browser, internal token URL for server)
- Make email/password login configurable via DISABLE_EMAIL_PASSWORD
- Add preferred_username fallback for email/name fields to support
  Minecraft-linked accounts without a traditional email
- Extract and persist minecraft_uuid from OIDC token claims to the
  user table (new minecraftUuid field in Prisma schema)
- Simplify mapProfileToUser by consolidating duplicate update paths

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Conditionally render the email/password form and divider based on
NEXT_PUBLIC_DISABLE_EMAIL_PASSWORD. When set to "true", only the
OIDC provider button is shown on the login page.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Run prettier on login-client.tsx and auth.ts
- Cast createdUser to any for minecraftUuid access to fix type check
  until prisma generate runs in CI

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@hbrombeer hbrombeer requested a review from lusu007 March 12, 2026 17:36
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