Zum Inhalt springen

API Endpoints

Komplette Referenz aller verfügbaren API Endpoints.

Initiiert den OAuth-Flow.

Request:

POST /auth/login
Content-Type: application/json
{
"provider": "github"
}

Response:

HTTP/1.1 302 Found
Location: https://github.com/login/oauth/authorize?client_id=...

OAuth Callback Endpoint. Wird vom OAuth-Provider nach erfolgreicher Authentifizierung aufgerufen.

Query Parameters:

  • code: Authorization code vom Provider
  • state: State-Token für CSRF-Schutz

Response:

HTTP/1.1 302 Found
Location: https://deine-domain.de?token=eyJhbGc...
Set-Cookie: auth_token=eyJhbGc...; HttpOnly; Secure

Gibt Informationen über den aktuell angemeldeten Benutzer zurück.

Request:

GET /auth/user
Authorization: Bearer eyJhbGc...

Response:

{
"userId": "github:123456",
"name": "Max Mustermann",
"email": "max@example.com",
"avatar": "https://avatars.githubusercontent.com/u/123456",
"provider": "github"
}

Meldet den Benutzer ab und invalidiert das Token.

Request:

POST /auth/logout
Authorization: Bearer eyJhbGc...

Response:

HTTP/1.1 200 OK
Content-Type: application/json
{
"success": true
}

Erneuert ein abgelaufenes JWT Token.

Request:

POST /auth/refresh
Content-Type: application/json
{
"refreshToken": "old-token"
}

Response:

{
"token": "eyJhbGc...",
"expiresIn": 3600
}

Startet den Passkey-Registrierungsprozess.

Request:

POST /webauthn/register/begin
Content-Type: application/json
Authorization: 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": [...]
}

Schließt die Passkey-Registrierung ab.

Request:

POST /webauthn/register/complete
Content-Type: application/json
{
"credential": {
"id": "base64url...",
"rawId": "base64url...",
"response": {
"attestationObject": "base64url...",
"clientDataJSON": "base64url..."
}
}
}

Response:

{
"success": true,
"credentialId": "base64url..."
}

Startet den Passkey-Authentifizierungsprozess.

Request:

POST /webauthn/authenticate/begin
Content-Type: application/json
{
"userId": "github:123456"
}

Response:

{
"challenge": "base64url...",
"allowCredentials": [
{
"type": "public-key",
"id": "base64url..."
}
]
}

Schließt die Passkey-Authentifizierung ab.

Request:

POST /webauthn/authenticate/complete
Content-Type: application/json
{
"credential": {
"id": "base64url...",
"response": {
"authenticatorData": "base64url...",
"clientDataJSON": "base64url...",
"signature": "base64url..."
}
}
}

Response:

{
"token": "eyJhbGc...",
"user": {
"userId": "github:123456",
"name": "Max Mustermann"
}
}

Liefert die Auth Client JavaScript-Bibliothek.

Liefert das Simple Login Button Script.

Liefert die WebAuthn Client JavaScript-Bibliothek.

CodeBedeutung
200Success
302Redirect (bei OAuth-Flow)
400Bad Request - Ungültige Parameter
401Unauthorized - Fehlende oder ungültige Authentifizierung
403Forbidden - Keine Berechtigung
404Not Found
500Internal Server Error

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.de
Access-Control-Allow-Methods: GET, POST, OPTIONS
Access-Control-Allow-Headers: Content-Type, Authorization
Access-Control-Allow-Credentials: true