# POST /v2/auth/saml/redirect/{providerId}/{accountId}

SAML-Anmeldung beim Identitätsanbieter starten

Prüft öffentliche Provider- und Konto-Pfad-ID sowie aktivierten Administrator-Loginbereich, erzeugt eine SAML-Anfrage und speichert deren serverseitige Korrelation. Setzt gegebenenfalls das _edsso-Cookie und liefert eine HTML-Weiterleitungsansicht zum IdP. Query-reply/state begleiten die App-Übergabe. Bereits GET erstellt damit einen Anmeldevorgang; dieser Browser-Schritt ist kein gewöhnlicher Datenabruf.

- Operation-ID: post_v2_auth_saml_redirect_providerId_accountId
- Dokumentation: /docs/api/v2/operations/post-v2-auth-saml-redirect-providerid-accountid-92bd5582652b/
- OpenAPI-Version: 3.2.1
- Vollständige Spezifikation: /docs/api/v2/openapi.json
- Dokumentationsstatus: reviewed
- Ändert Zustand: ja
- Für Automation freigegeben: nein

## Server

Serverwerte stammen unverändert aus der Datei. Eine lokale Entwicklungsadresse ist keine bestätigte Produktionsadresse. `API_ORIGIN` muss auf die passende Instanz gesetzt werden.

```json
[
  {
    "url": "https://app2.edoobox.com",
    "description": "edoobox API"
  }
]
```

## Authentifizierung

Für diesen Endpunkt deklariert die Spezifikation keine OpenAPI-Authentifizierung (`security: []`). Weitere Bedingungen stehen in der Beschreibung und den edoobox-Hinweisen.

### Wirksame Security Requirements und vollständige Verfahren

```json
{
  "security": [],
  "securitySchemes": {}
}
```

## Parameter

| Name | Ort | Pflicht | Beschreibung |
| --- | --- | --- | --- |
| providerId | path | ja | Öffentliche Provider-ID des Kontos. |
| accountId | path | ja | Öffentliche Konto-ID. |
| reply | query | nein | Gewünschter Login-Antwortmodus, etwa code für App-Übergabe. |
| state | query | nein | Geschützter Übergabe-State für die App. |

### Vollständige wirksame Parameterdefinitionen

```json
[
  {
    "name": "providerId",
    "in": "path",
    "required": true,
    "schema": {
      "type": "string",
      "pattern": "^saml_[a-f0-9]{12}_-?[0-9]+$",
      "description": "Öffentliche v2-ID aus dem gewählten Konto; keine rohe Datenbank-ID.",
      "examples": [
        "saml_012345abcdef_123456"
      ]
    },
    "description": "Öffentliche Provider-ID des Kontos."
  },
  {
    "name": "accountId",
    "in": "path",
    "required": true,
    "schema": {
      "type": "string",
      "pattern": "^account_[a-f0-9]{12}_-?[0-9]+$",
      "description": "Öffentliche v2-ID aus dem gewählten Konto; keine rohe Datenbank-ID.",
      "examples": [
        "account_012345abcdef_123456"
      ]
    },
    "description": "Öffentliche Konto-ID."
  },
  {
    "name": "reply",
    "in": "query",
    "required": false,
    "schema": {
      "type": "string"
    },
    "description": "Gewünschter Login-Antwortmodus, etwa code für App-Übergabe."
  },
  {
    "name": "state",
    "in": "query",
    "required": false,
    "schema": {
      "type": "string",
      "writeOnly": true,
      "x-edoobox-sensitive": true,
      "description": "Nur synthetisches Beispiel; tatsächlich zurückgegebenes geschütztes Material sicher übergeben."
    },
    "description": "Geschützter Übergabe-State für die App."
  }
]
```

## Anfrage

Kein Request Body deklariert.

## Antworten

HTTP-Status und Antwortinhalt gemeinsam auswerten. Die folgenden Beschreibungen und Schemata sind die Angaben der Quelldatei.

```json
{
  "200": {
    "description": "HTML-Weiterleitungsseite mit Refresh-Header zum IdP; Fehler können zur lokalen Loginansicht führen.",
    "content": {
      "text/html": {
        "schema": {
          "type": "string"
        }
      }
    }
  },
  "302": {
    "description": "Browser-Weiterleitung zum Folgeschritt oder zur Fehleransicht.",
    "headers": {
      "Location": {
        "schema": {
          "type": "string",
          "format": "uri"
        },
        "description": "Vom Server ermittelte Zieladresse."
      }
    }
  },
  "400": {
    "description": "Invalid request.",
    "content": {
      "application/json": {
        "example": {
          "success": false,
          "error": "ED40006"
        }
      }
    }
  },
  "401": {
    "description": "Missing/expired token, missing account context, account paused or model-specific authorization failure.",
    "content": {
      "application/json": {
        "example": {
          "success": false,
          "error": "ED40103"
        }
      }
    }
  },
  "402": {
    "description": "Missing/invalid action data or subscription/operation restriction.",
    "content": {
      "application/json": {
        "example": {
          "success": false,
          "error": "ED80100"
        }
      }
    }
  },
  "403": {
    "description": "Permission denied. Browser CORS rejection may have an empty body.",
    "content": {
      "application/json": {
        "example": {
          "success": false,
          "error": "ED40340"
        }
      }
    }
  },
  "404": {
    "description": "Unknown resource/action or unsupported method.",
    "content": {
      "application/json": {
        "example": {
          "success": false,
          "error": "ED80019"
        }
      }
    }
  },
  "422": {
    "description": "Validation failed.",
    "content": {
      "application/json": {
        "example": {
          "success": false,
          "error": "ED80020"
        }
      }
    }
  },
  "429": {
    "description": "Request/login rate limit exceeded. Honor Retry-After when supplied; legacy rate-limit paths may omit it. Retry only proven reads within a bounded deadline; a mutation is never automatically replayed after an ambiguous response.",
    "content": {
      "application/json": {
        "example": {
          "success": false,
          "error": "ED42902"
        }
      }
    },
    "headers": {
      "Retry-After": {
        "description": "Optional server delay in whole seconds or an HTTP date. Absence is not permission for an immediate retry.",
        "schema": {
          "type": "string",
          "examples": [
            "30"
          ]
        }
      }
    }
  },
  "502": {
    "description": "Server-side operation failed.",
    "content": {
      "application/json": {
        "example": {
          "success": false,
          "error": "ED50201"
        }
      }
    }
  }
}
```

## Aufrufbeispiele

Anpassen vor dem Ausführen. Platzhalter und veröffentlichte Beispiele sind synthetisch. Die Beispiele senden hier keine Anfrage; sie ergänzen keine unbekannten Pflichtfelder.

### cURL

```sh
# cURL: PATH_* bereits URL-kodiert setzen. JavaScript/Python kodieren die unveränderten Pfadwerte selbst.
: "${API_ORIGIN:?API_ORIGIN setzen}"
: "${PATH_PROVIDERID:?PATH_PROVIDERID setzen}"
: "${PATH_ACCOUNTID:?PATH_ACCOUNTID setzen}"
curl --request 'POST' \
  --url "${API_ORIGIN%/}"'/v2/auth/saml/redirect/'"${PATH_PROVIDERID}"'/'"${PATH_ACCOUNTID}"''
```

### JavaScript (Node.js)

```javascript
const required = (name) => {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
};
let path = "/v2/auth/saml/redirect/{providerId}/{accountId}";
path = path.replaceAll("{providerId}", encodeURIComponent(required("PATH_PROVIDERID")));
path = path.replaceAll("{accountId}", encodeURIComponent(required("PATH_ACCOUNTID")));
const origin = required('API_ORIGIN');
const url = new URL((origin.endsWith('/') ? origin.slice(0, -1) : origin) + path);
const headers = {};
const response = await fetch(url, { method: "POST", headers, redirect: 'manual' });
const text = await response.text();
console.log(response.status, text);
// HTTP-Status und dokumentierte error/success-Felder gemeinsam prüfen.
```

### Python

```python
import os
import urllib.parse
import urllib.request
import urllib.error

path = "/v2/auth/saml/redirect/{providerId}/{accountId}"
path = path.replace("{providerId}", urllib.parse.quote(os.environ["PATH_PROVIDERID"], safe=""))
path = path.replace("{accountId}", urllib.parse.quote(os.environ["PATH_ACCOUNTID"], safe=""))
url = os.environ["API_ORIGIN"].rstrip("/") + path
headers = {}

# Redirects nicht automatisch verfolgen.
class NoRedirect(urllib.request.HTTPRedirectHandler):
    def redirect_request(self, req, fp, code, msg, headers, newurl):
        return None
request = urllib.request.Request(url, headers=headers, method="POST")
try:
    response = urllib.request.build_opener(NoRedirect).open(request, timeout=30)
except urllib.error.HTTPError as error:
    response = error
print(response.status, response.read().decode("utf-8", errors="replace"))
# HTTP-Status und dokumentierte error/success-Felder gemeinsam prüfen.
```

## Vollständige Operationsdefinition und edoobox-Hinweise

Alle Originalfelder einschliesslich `x-edoobox-*`, requestBody und responses bleiben erhalten. Teilweise dokumentierte Schemata sind kein vollständiger Validierungsvertrag.

```json
{
  "operationId": "post_v2_auth_saml_redirect_providerId_accountId",
  "summary": "SAML-Anmeldung beim Identitätsanbieter starten",
  "description": "Prüft öffentliche Provider- und Konto-Pfad-ID sowie aktivierten Administrator-Loginbereich, erzeugt eine SAML-Anfrage und speichert deren serverseitige Korrelation. Setzt gegebenenfalls das _edsso-Cookie und liefert eine HTML-Weiterleitungsansicht zum IdP. Query-reply/state begleiten die App-Übergabe. Bereits GET erstellt damit einen Anmeldevorgang; dieser Browser-Schritt ist kein gewöhnlicher Datenabruf.",
  "tags": [
    "auth"
  ],
  "security": [],
  "parameters": [
    {
      "name": "providerId",
      "in": "path",
      "required": true,
      "schema": {
        "type": "string",
        "pattern": "^saml_[a-f0-9]{12}_-?[0-9]+$",
        "description": "Öffentliche v2-ID aus dem gewählten Konto; keine rohe Datenbank-ID.",
        "examples": [
          "saml_012345abcdef_123456"
        ]
      },
      "description": "Öffentliche Provider-ID des Kontos."
    },
    {
      "name": "accountId",
      "in": "path",
      "required": true,
      "schema": {
        "type": "string",
        "pattern": "^account_[a-f0-9]{12}_-?[0-9]+$",
        "description": "Öffentliche v2-ID aus dem gewählten Konto; keine rohe Datenbank-ID.",
        "examples": [
          "account_012345abcdef_123456"
        ]
      },
      "description": "Öffentliche Konto-ID."
    },
    {
      "name": "reply",
      "in": "query",
      "required": false,
      "schema": {
        "type": "string"
      },
      "description": "Gewünschter Login-Antwortmodus, etwa code für App-Übergabe."
    },
    {
      "name": "state",
      "in": "query",
      "required": false,
      "schema": {
        "type": "string",
        "writeOnly": true,
        "x-edoobox-sensitive": true,
        "description": "Nur synthetisches Beispiel; tatsächlich zurückgegebenes geschütztes Material sicher übergeben."
      },
      "description": "Geschützter Übergabe-State für die App."
    }
  ],
  "responses": {
    "200": {
      "description": "HTML-Weiterleitungsseite mit Refresh-Header zum IdP; Fehler können zur lokalen Loginansicht führen.",
      "content": {
        "text/html": {
          "schema": {
            "type": "string"
          }
        }
      }
    },
    "302": {
      "description": "Browser-Weiterleitung zum Folgeschritt oder zur Fehleransicht.",
      "headers": {
        "Location": {
          "schema": {
            "type": "string",
            "format": "uri"
          },
          "description": "Vom Server ermittelte Zieladresse."
        }
      }
    },
    "400": {
      "description": "Invalid request.",
      "content": {
        "application/json": {
          "example": {
            "success": false,
            "error": "ED40006"
          }
        }
      }
    },
    "401": {
      "description": "Missing/expired token, missing account context, account paused or model-specific authorization failure.",
      "content": {
        "application/json": {
          "example": {
            "success": false,
            "error": "ED40103"
          }
        }
      }
    },
    "402": {
      "description": "Missing/invalid action data or subscription/operation restriction.",
      "content": {
        "application/json": {
          "example": {
            "success": false,
            "error": "ED80100"
          }
        }
      }
    },
    "403": {
      "description": "Permission denied. Browser CORS rejection may have an empty body.",
      "content": {
        "application/json": {
          "example": {
            "success": false,
            "error": "ED40340"
          }
        }
      }
    },
    "404": {
      "description": "Unknown resource/action or unsupported method.",
      "content": {
        "application/json": {
          "example": {
            "success": false,
            "error": "ED80019"
          }
        }
      }
    },
    "422": {
      "description": "Validation failed.",
      "content": {
        "application/json": {
          "example": {
            "success": false,
            "error": "ED80020"
          }
        }
      }
    },
    "429": {
      "description": "Request/login rate limit exceeded. Honor Retry-After when supplied; legacy rate-limit paths may omit it. Retry only proven reads within a bounded deadline; a mutation is never automatically replayed after an ambiguous response.",
      "content": {
        "application/json": {
          "example": {
            "success": false,
            "error": "ED42902"
          }
        }
      },
      "headers": {
        "Retry-After": {
          "description": "Optional server delay in whole seconds or an HTTP date. Absence is not permission for an immediate retry.",
          "schema": {
            "type": "string",
            "examples": [
              "30"
            ]
          }
        }
      }
    },
    "502": {
      "description": "Server-side operation failed.",
      "content": {
        "application/json": {
          "example": {
            "success": false,
            "error": "ED50201"
          }
        }
      }
    }
  },
  "x-edoobox-mutates-state": true,
  "x-edoobox-bodylessSource": {
    "file": "application/models/v2/Samlfunc.php",
    "method": "loginRedirectIDP",
    "line": 1618
  },
  "x-edoobox-runtimeMutationGuard": false,
  "x-edoobox-documentationReview": {
    "file": "docs/openapi/operation-contracts/05-auth.json",
    "notes": []
  },
  "x-edoobox-source": {
    "file": "application/models/v2/Samlfunc.php",
    "method": "loginRedirectIDP",
    "line": 1618
  },
  "x-edoobox-documentationStatus": "reviewed",
  "x-edoobox-readOnly": false,
  "x-edoobox-safeForAutomation": false,
  "x-edoobox-permission": {
    "description": "No account-JWT resource permission levels are applied. Authentication requirements, if any, are defined by this route source-specific boundary and dedicated security scheme.",
    "checkedByDispatcher": false,
    "levels": []
  }
}
```
