API Endpoints
API Endpoints
Abschnitt betitelt „API Endpoints“Komplette Referenz aller verfügbaren API Endpoints.
OAuth Endpoints
Abschnitt betitelt „OAuth Endpoints“POST /auth/login
Abschnitt betitelt „POST /auth/login“Initiiert den OAuth-Flow.
Request:
POST /auth/loginContent-Type: application/json
{ "provider": "github"}Response:
HTTP/1.1 302 FoundLocation: https://github.com/login/oauth/authorize?client_id=...GET /auth/callback
Abschnitt betitelt „GET /auth/callback“OAuth Callback Endpoint. Wird vom OAuth-Provider nach erfolgreicher Authentifizierung aufgerufen.
Query Parameters:
code: Authorization code vom Providerstate: State-Token für CSRF-Schutz
Response:
HTTP/1.1 302 FoundLocation: https://deine-domain.de?token=eyJhbGc...Set-Cookie: auth_token=eyJhbGc...; HttpOnly; SecureGET /auth/user
Abschnitt betitelt „GET /auth/user“Gibt Informationen über den aktuell angemeldeten Benutzer zurück.
Request:
GET /auth/userAuthorization: Bearer eyJhbGc...Response:
{ "userId": "github:123456", "name": "Max Mustermann", "email": "max@example.com", "avatar": "https://avatars.githubusercontent.com/u/123456", "provider": "github"}POST /auth/logout
Abschnitt betitelt „POST /auth/logout“Meldet den Benutzer ab und invalidiert das Token.
Request:
POST /auth/logoutAuthorization: Bearer eyJhbGc...Response:
HTTP/1.1 200 OKContent-Type: application/json
{ "success": true}POST /auth/refresh
Abschnitt betitelt „POST /auth/refresh“Erneuert ein abgelaufenes JWT Token.
Request:
POST /auth/refreshContent-Type: application/json
{ "refreshToken": "old-token"}Response:
{ "token": "eyJhbGc...", "expiresIn": 3600}WebAuthn Endpoints
Abschnitt betitelt „WebAuthn Endpoints“POST /webauthn/register/begin
Abschnitt betitelt „POST /webauthn/register/begin“Startet den Passkey-Registrierungsprozess.
Request:
POST /webauthn/register/beginContent-Type: application/jsonAuthorization: Bearer eyJhbGc...
{ "userId": "github:123456", "userName": "max@example.com"}Response:
{ "challenge": "base64url...", "rp": { "name": "OAuth Auth", "id": "auth.deine-domain.de" }, "user": { "id": "base64url...", "name": "max@example.com", "displayName": "Max Mustermann" }, "pubKeyCredParams": [...]}POST /webauthn/register/complete
Abschnitt betitelt „POST /webauthn/register/complete“Schließt die Passkey-Registrierung ab.
Request:
POST /webauthn/register/completeContent-Type: application/json
{ "credential": { "id": "base64url...", "rawId": "base64url...", "response": { "attestationObject": "base64url...", "clientDataJSON": "base64url..." } }}Response:
{ "success": true, "credentialId": "base64url..."}POST /webauthn/authenticate/begin
Abschnitt betitelt „POST /webauthn/authenticate/begin“Startet den Passkey-Authentifizierungsprozess.
Request:
POST /webauthn/authenticate/beginContent-Type: application/json
{ "userId": "github:123456"}Response:
{ "challenge": "base64url...", "allowCredentials": [ { "type": "public-key", "id": "base64url..." } ]}POST /webauthn/authenticate/complete
Abschnitt betitelt „POST /webauthn/authenticate/complete“Schließt die Passkey-Authentifizierung ab.
Request:
POST /webauthn/authenticate/completeContent-Type: application/json
{ "credential": { "id": "base64url...", "response": { "authenticatorData": "base64url...", "clientDataJSON": "base64url...", "signature": "base64url..." } }}Response:
{ "token": "eyJhbGc...", "user": { "userId": "github:123456", "name": "Max Mustermann" }}Client Library Endpoints
Abschnitt betitelt „Client Library Endpoints“GET /client/auth-client.js
Abschnitt betitelt „GET /client/auth-client.js“Liefert die Auth Client JavaScript-Bibliothek.
GET /client/simple-login-button.js
Abschnitt betitelt „GET /client/simple-login-button.js“Liefert das Simple Login Button Script.
GET /client/webauthn-client.js
Abschnitt betitelt „GET /client/webauthn-client.js“Liefert die WebAuthn Client JavaScript-Bibliothek.
Status Codes
Abschnitt betitelt „Status Codes“| Code | Bedeutung |
|---|---|
| 200 | Success |
| 302 | Redirect (bei OAuth-Flow) |
| 400 | Bad Request - Ungültige Parameter |
| 401 | Unauthorized - Fehlende oder ungültige Authentifizierung |
| 403 | Forbidden - Keine Berechtigung |
| 404 | Not Found |
| 500 | Internal Server Error |
Rate Limiting
Abschnitt betitelt „Rate Limiting“Aktuell gibt es kein Rate Limiting. Für Production solltest du Cloudflare’s Rate Limiting verwenden.
Alle Endpoints unterstützen CORS mit konfigurierten Origins über FRONTEND_URL.
CORS Headers:
Access-Control-Allow-Origin: https://deine-domain.deAccess-Control-Allow-Methods: GET, POST, OPTIONSAccess-Control-Allow-Headers: Content-Type, AuthorizationAccess-Control-Allow-Credentials: trueNächste Schritte
Abschnitt betitelt „Nächste Schritte“- JWT Tokens - Mehr über JWT-Tokens
- CORS Konfiguration - CORS-Details
- Client Library - Client-Bibliotheken verwenden