Some checks failed
Deploy to production / deploy (push) Failing after 49s
- Created OAuth credentials setup guide for Google, Microsoft, Keycloak, ORY, and ZITADEL. - Added migration for oauth_identity table to store OAuth identities linked to users. - Implemented OAuthIdentity model for managing OAuth identities in the database. - Developed oauthService to handle OAuth login, user creation, and identity linking. - Created OAuthCallbackView and OAuthUserCallbackView components for handling OAuth responses in the frontend. - Added error handling and user feedback during the OAuth process.
7.1 KiB
7.1 KiB
OAuth Credentials Setup Guide
Anleitung zum Sammeln der OAuth-Credentials für alle 5 Provider.
Redirect URIs
Für alle Provider benötigst du folgende Redirect URIs (ersetze www.your-part.de mit deiner echten Domain):
https://www.your-part.de/auth/oauth/callback
https://www.your-part.de/auth/oauth/user/callback
Lokal zum Testen:
http://localhost:3000/auth/oauth/callback
http://localhost:3000/auth/oauth/user/callback
1. Google
Credentials besorgen:
- Öffne Google Cloud Console
- Erstelle ein neues Projekt oder wähle ein bestehendes
- Navigiere zu APIs & Services → Credentials
- Klick + CREATE CREDENTIALS → OAuth 2.0 Client IDs
- Wähle Web application
- Füge unter Authorized redirect URIs hinzu:
https://www.your-part.de/auth/oauth/callbackhttps://www.your-part.de/auth/oauth/user/callback
- Speichern und die Client ID und Client Secret kopieren
.env:
OAUTH_GOOGLE_CLIENT_ID=your-client-id.apps.googleusercontent.com
OAUTH_GOOGLE_CLIENT_SECRET=your-client-secret
2. Microsoft Azure
Credentials besorgen:
- Öffne Azure Portal
- Navigiere zu Azure Active Directory → App registrations → + New registration
- Gib einen Namen ein (z.B. "YourPart OAuth")
- Wähle Accounts in any organizational directory (Any Azure AD directory - Multitenant)
- Bei Redirect URI wähle Web und füge ein:
https://www.your-part.de/auth/oauth/callback
- Klick Register
- Notiere die Application (client) ID
- Gehe zu Certificates & secrets → + New client secret
- Erstelle ein Secret und kopiere den Value (nicht die ID!)
- Gehe zu Token configuration und stelle sicher, dass die richtigen Claims enthalten sind
Zusätzliche URI hinzufügen:
- Gehe zu Authentication
- Unter Redirect URIs klick + Add URI
- Füge hinzu:
https://www.your-part.de/auth/oauth/user/callback
.env:
OAUTH_MICROSOFT_CLIENT_ID=your-application-id
OAUTH_MICROSOFT_CLIENT_SECRET=your-client-secret-value
3. Keycloak
Keycloak ist ein Open-Source OIDC Provider. Du kannst ihn selbst hosten oder eine gehostete Lösung nutzen.
Option A: Selbst gehostet mit Docker
docker run -d \
-p 8080:8080 \
-e KEYCLOAK_ADMIN=admin \
-e KEYCLOAK_ADMIN_PASSWORD=admin \
quay.io/keycloak/keycloak:latest \
start-dev
Dann:
- Öffne http://localhost:8080
- Login mit
admin/admin - Realm erstellen: Oben links Dropdown → Create realm
- Name:
yourpart(oder beliebig)
- Name:
- Im neuen Realm: Clients → Create client
- Client ID:
yourpart - Client Protocol:
openid-connect - Access Type:
confidential
- Client ID:
- Im Settings Tab:
- Valid Redirect URIs:
https://www.your-part.de/auth/oauth/callback https://www.your-part.de/auth/oauth/user/callback
- Valid Redirect URIs:
- Speichern
- Gehe zu Credentials Tab
- Client Secret kopieren
Option B: Gehosteter Service
.env:
OAUTH_KEYCLOAK_ISSUER=https://your-keycloak-domain/realms/yourpart
OAUTH_KEYCLOAK_CLIENT_ID=yourpart
OAUTH_KEYCLOAK_CLIENT_SECRET=your-client-secret
4. ORY Hydra / ORY Cloud
ORY ist ein moderner OIDC Provider. Am einfachsten ist ORY Cloud.
Option A: ORY Cloud (empfohlen)
- Öffne ORY Cloud Console
- Registriere dich oder logge dich ein
- Erstelle ein neues Project
- Gehe zu Applications
- Klick Create New Application
- Gib einen Namen ein (z.B. "YourPart")
- Unter Redirect URLs füge ein:
https://www.your-part.de/auth/oauth/callback https://www.your-part.de/auth/oauth/user/callback - Speichern
- Die Client ID und Client Secret werden angezeigt
- Finde deine Issuer URL in den Project Settings (meist
https://your-project-slug.eu.hydra.cloud)
Option B: Selbst gehostet (komplex)
Siehe ORY Hydra Dokumentation
.env:
OAUTH_ORY_ISSUER=https://your-project-slug.eu.hydra.cloud
OAUTH_ORY_CLIENT_ID=your-client-id
OAUTH_ORY_CLIENT_SECRET=your-client-secret
5. ZITADEL
ZITADEL ist ein Zero-Trust Identity Platform als SaaS.
Credentials besorgen:
- Öffne ZITADEL Console
- Registriere dich oder logge dich ein
- Erstelle eine neue Organization (oder verwende die existierende)
- Gehe zu Projects → + New Project
- Gib einen Namen ein (z.B. "YourPart")
- Gehe zum Projekt → Applications → + New Application
- Wähle Type: Web
- Gib einen Namen ein
- Bei Redirect URIs füge ein:
https://www.your-part.de/auth/oauth/callback https://www.your-part.de/auth/oauth/user/callback - Speichern
- Unter Client Information kopiere:
- Client ID
- Client Secret (falls sichtbar, sonst im "CREDENTIALS" Tab generieren)
- Finde deine Issuer URL in den Organization Settings (meist
https://your-instance.zitadel.cloud)
.env:
OAUTH_ZITADEL_ISSUER=https://your-instance.zitadel.cloud
OAUTH_ZITADEL_CLIENT_ID=your-client-id
OAUTH_ZITADEL_CLIENT_SECRET=your-client-secret
Komplette .env für alle 5 Provider
# Google
OAUTH_GOOGLE_CLIENT_ID=...
OAUTH_GOOGLE_CLIENT_SECRET=...
# Microsoft
OAUTH_MICROSOFT_CLIENT_ID=...
OAUTH_MICROSOFT_CLIENT_SECRET=...
# Keycloak
OAUTH_KEYCLOAK_ISSUER=...
OAUTH_KEYCLOAK_CLIENT_ID=...
OAUTH_KEYCLOAK_CLIENT_SECRET=...
# ORY
OAUTH_ORY_ISSUER=...
OAUTH_ORY_CLIENT_ID=...
OAUTH_ORY_CLIENT_SECRET=...
# ZITADEL
OAUTH_ZITADEL_ISSUER=...
OAUTH_ZITADEL_CLIENT_ID=...
OAUTH_ZITADEL_CLIENT_SECRET=...
Schnell-Checkliste
- Google: Client ID & Secret
- Microsoft: Application ID & Client Secret
- Keycloak: Issuer, Client ID, Secret
- ORY: Issuer, Client ID, Secret
- ZITADEL: Issuer, Client ID, Secret
- Alle Redirect URIs in den Providern konfiguriert
- .env datei aktualisiert
- Server neu gestartet (
npm restart)
Testing
Nach der Konfiguration:
- Frontend öffnen: http://www.your-part.de
- Auf "Login" oder Provider-Button klicken
- Jeder verfügbare Provider sollte als Button angezeigt werden
- Test: Mit jedem Provider einloggen
- Test: Existender Nutzer → Einstellungen → Authentifizierung hinzufügen
Troubleshooting
"Invalid redirect URI"
- Stelle sicher, dass die Redirect URIs exakt übereinstimmen (inkl.
https://vshttp://) - Beachte Trailing Slashes
"Invalid client secret"
- Kopiere das Secret neu (nicht die ID)
- Manche Provider verstecken das Secret nach einmaliger Anzeige
"Discovery endpoint not found"
- Überprüfe die Issuer URL (mit/ohne Trailing Slash)
- Für Keycloak: URL muss auf
/realms/xxxenden - Für ORY: URL darf nicht auf
/enden
Port-Konflikt lokal
- Keycloak benutzt
8080→ ändere auf:docker run -p 8081:8080 ... - Stelle sicher, dass 3000 (Frontend) und 5000 (Backend) frei sind