This guide describes how to configure OAuth 2.0 / OIDC Authentication for applications running behind a Datum gateway usingDocumentation Index
Fetch the complete documentation index at: https://datum-4926dda5-how-to-guides-gateway-auth.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
datumctl. The configuration uses Envoy Gateway SecurityPolicy resources and applies to Windows, macOS, and Linux.
Overview
OIDC authentication protects an application by requiring users to sign in with their Google account before requests are forwarded to the origin. Envoy Gateway handles the OAuth 2.0 flow transparently — users are redirected to Google, authenticate, and are redirected back without any changes to your application. At a high level, this setup:- Creates a Google OAuth 2.0 Client in Google Cloud Console
- Stores the client secret in a Kubernetes Secret
- Labels the Secret so it is synced to edge clusters
- Attaches a SecurityPolicy with OIDC config to an
HTTPRoute - Verifies authentication behavior
Prerequisites
datumctlinstalled and authenticated- A valid Project
- A Google Cloud account with a project
- Existing:
GatewayHTTPRoute
- Permission to create:
SecretSecurityPolicy
Critical Requirement: Secret Syncing
Secrets and ConfigMaps referenced by gateway configurations are not automatically synced to edge clusters. To make a Secret available to edge gateways, it must include the following label:Why This Matters
- Without this label, the gateway receives the policy but not the Secret
- Envoy fails to load the OAuth client credentials
- All requests return HTTP 500 instead of redirecting to Google
Configuration Steps
Step 1: Create Google OAuth 2.0 Credentials
- Go to Google Cloud Console → APIs & Services → Credentials
- Click Create Credentials → OAuth 2.0 Client ID
- Set Application type to Web application
- Under Authorized redirect URIs, add:
Replace
<your-app-hostname>with the public hostname of yourHTTPRoute. - Click Create and copy the Client ID and Client Secret
Note: The redirect URI must exactly match the value you will configure in the SecurityPolicy. Any mismatch causes Google to reject the OAuth flow.
Step 2: Set Variables
Windows (PowerShell)
macOS / Linux
Step 3: Create the Client Secret
The Secret must:- Use the key
client-secret - Exist in the same namespace as the
SecurityPolicy - Include the gateway-sync label
Windows (PowerShell)
macOS / Linux
Step 4: Attach OIDC Auth Using a SecurityPolicy
Attach the policy to the HTTPRoute. This is the most reliable attachment point.Windows (PowerShell)
macOS / Linux
Verification
Unauthenticated Request
Authenticated Session
After completing the Google sign-in flow, subsequent requests will be forwarded to your origin with a session cookie managed by Envoy.Cleanup / Disable OIDC Auth
Windows (PowerShell)
macOS / Linux
Troubleshooting
Common Failure Modes
| Symptom | Root Cause | Resolution |
|---|---|---|
| HTTP 500 on all requests | Secret not synced to edge | Add gateway-sync label |
| Redirect loop | Redirect URI mismatch | Ensure redirectURL matches Google Console exactly |
redirect_uri_mismatch from Google | URI not registered | Add URI to Google Cloud Credentials |
| HTTP 401 after login | Scopes insufficient | Verify openid scope is included |
| Works after deleting policy | Invalid Secret reference | Fix Secret name and gateway-sync label |
Useful Debug Commands
Best Practices
- Register separate OAuth clients for each environment (dev, staging, prod)
- Restrict authorized redirect URIs to known hostnames only
- Limit OAuth scopes to the minimum required (
openid,email) - Rotate the client secret periodically and re-apply the Secret
- Use OIDC for production — Basic Auth is suited for development and demos
Summary
- Google OAuth is configured using Envoy Gateway
SecurityPolicywith anoidcblock - The client secret is stored as a Kubernetes Secret with key
client-secret - Secrets must be explicitly synced to edge clusters using the
networking.datumapis.com/gateway-sync: "true"label - The
redirectURLin the policy must exactly match the URI registered in Google Cloud Console - Attaching policies to
HTTPRouteis the most reliable approach