{"openapi":"3.1.0","info":{"title":"gatekeeper","version":"0.1.0"},"paths":{"/healthz":{"get":{"tags":["infra"],"summary":"Healthz","description":"Liveness probe — always returns 200 if the process is running.","operationId":"healthz_healthz_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/readyz":{"get":{"tags":["infra"],"summary":"Readyz","description":"Readiness probe — returns 200 when the service is ready to serve.","operationId":"readyz_readyz_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/auth/login":{"get":{"tags":["auth"],"summary":"Login","description":"Hydra login callback — orchestrates session verification and login acceptance.\n\nThis endpoint is hit in two scenarios during the OAuth2 authorization flow:\n\nFirst hit (no Kratos session):\n    Hydra redirects the browser here after a product initiates an OAuth2\n    flow. Gatekeeper checks for a valid Kratos session, finds none, and\n    redirects the browser to the SPA login page with the ``login_challenge``\n    preserved in the URL. The SPA handles credential collection via Kratos.\n\nSecond hit (with Kratos session):\n    After the user authenticates through the SPA and Kratos sets a session\n    cookie, the browser is redirected back here. Gatekeeper verifies the\n    Kratos session, extracts the identity ID, and tells Hydra to accept the\n    login. Hydra responds with a redirect URL containing a\n    ``login_verifier`` that continues the OAuth2 flow into the consent step.\n\nThe Kratos session check is always performed — even when Hydra reports\n``skip=true`` (SSO) — to protect against revoked or deleted identities\nwhose Hydra session outlived their Kratos session.\n\nArgs:\n    request: The incoming HTTP request, used to extract browser cookies\n        for the Kratos session check.\n    login_challenge: One-time token from Hydra that ties this callback\n        back to the original OAuth2 authorization request.\n    auth_service: Injected service for Hydra admin and Kratos API calls.\n    settings: Injected application settings for the frontend URL.\n\nReturns:\n    A 302 redirect to either:\n    - Hydra's ``redirect_to`` URL (if Kratos session is valid), which\n      continues the OAuth2 flow into the consent step.\n    - The SPA login page at ``{FRONTEND}/login?login_challenge=...``\n      (if no valid session), where the user enters credentials.","operationId":"login_auth_login_get","parameters":[{"name":"login_challenge","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Login Challenge"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/auth/consent":{"get":{"tags":["auth"],"summary":"Consent","description":"Hydra consent callback — auto-accepts all requested scopes.\n\nCalled after Hydra validates the login and redirects the browser here for\nthe consent step. In a standard OAuth2 setup, this is where the user would\nbe asked \"Do you allow Product A to access your email and profile?\".\n\nSince gatekeeper is a first-party identity provider (it owns both the\nOAuth2 server and the identity store), all requested scopes are granted\nautomatically without showing a consent UI. The authenticated user's\nKratos identity ID is embedded in the ``id_token`` session as the ``sub``\nclaim.\n\nHydra responds with the final redirect URL — the product's\n``redirect_uri`` with an authorization code appended. The browser follows\nthis redirect back to the product, completing the OAuth2 flow.\n\nIf third-party clients are added later, this endpoint can be extended to\nredirect to a consent UI in the SPA instead of auto-accepting.\n\nArgs:\n    consent_challenge: One-time token from Hydra for the consent step,\n        received as a query parameter when Hydra redirects the browser\n        here after login verification.\n    auth_service: Injected service for Hydra admin API calls.\n\nReturns:\n    A 302 redirect to the product's callback URL with an authorization\n    code (e.g., ``https://app-a.com/callback?code=xyz&state=...``).","operationId":"consent_auth_consent_get","parameters":[{"name":"consent_challenge","in":"query","required":true,"schema":{"type":"string","title":"Consent Challenge"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/auth/logout":{"get":{"tags":["auth"],"summary":"Logout","description":"Hydra logout callback — revokes both Hydra and Kratos sessions.\n\nCalled when a product initiates logout by redirecting the browser to\nHydra's OIDC logout endpoint (``/oauth2/sessions/logout``). Hydra creates\na logout challenge and redirects the browser here.\n\nGatekeeper performs a two-phase revocation:\n\n1. Revoke Kratos sessions: Calls the Kratos admin API to delete all\n   sessions for the user. Without this, the ``ory_kratos_session`` cookie\n   would remain valid and the user would be silently re-authenticated on\n   the next OAuth2 flow (the ``/auth/login`` endpoint would find the\n   Kratos session and accept the login without showing a login page).\n\n2. Accept Hydra logout: Tells Hydra to revoke its own session and\n   invalidate all tokens (access, refresh, id) for this user. Hydra\n   responds with the ``post_logout_redirect_uri`` that the product\n   provided when initiating the logout.\n\nAfter both revocations, the browser is redirected back to the product.\nThe user is fully logged out across all products — both the Hydra SSO\nsession and the Kratos identity session are destroyed.\n\nArgs:\n    logout_challenge: One-time token from Hydra for the logout step,\n        received as a query parameter when Hydra redirects the browser\n        here.\n    auth_service: Injected service for Hydra admin and Kratos admin\n        API calls.\n\nReturns:\n    A 302 redirect to the product's post-logout URL (e.g.,\n    ``https://app-a.com``).","operationId":"logout_auth_logout_get","parameters":[{"name":"logout_challenge","in":"query","required":true,"schema":{"type":"string","title":"Logout Challenge"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/auth/security-logout":{"post":{"tags":["auth"],"summary":"Security Logout","description":"Global sign-out after a password change.\n\nCalled by the SPA after a Kratos settings-flow password change (or a\nrecovery-initiated reset, which terminates in the same settings flow)\nsucceeds. Revokes all remaining Kratos sessions (the Kratos hook already\nkilled the others) and all Hydra SSO + consent state for the subject.\n\nAuth model: cookie-based. A valid Kratos session is proof that the\ncaller is the subject whose password just changed — no additional auth\nrequired. Missing session returns 204 so replays and double-fires are\nsafe.\n\nResponse is JSON, not a redirect, so the SPA can clear in-memory state\n(Zustand/Redux/IndexedDB) before navigating itself to the login page.\n\nResidual JWT window: access tokens issued before this call remain valid\nuntil their natural expiry (``ttl.access_token``, 1h). Refresh tokens\nand Hydra SSO are revoked immediately.\n\nArgs:\n    request: Incoming request; the ``Cookie`` header carries the Kratos\n        session that identifies the subject.\n    auth_service: Injected service for Kratos/Hydra admin calls.\n\nReturns:\n    204 if there was no session to act on (idempotent replay), or 200\n    with ``{\"redirect_to\": \"/login?message=password_changed\"}`` on\n    success. Errors from downstream revocation propagate as 5xx so the\n    SPA can surface \"partial failure, log out manually\".","operationId":"security_logout_auth_security_logout_post","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/auth/management-return-context":{"get":{"tags":["auth"],"summary":"Management Return Context","description":"Return trusted button metadata for SPA management-return actions.","operationId":"management_return_context_auth_management_return_context_get","parameters":[{"name":"client_id","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Client Id"}},{"name":"return_path","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Return Path"}},{"name":"platform","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Platform"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ManagementReturnContextResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/auth/registration":{"get":{"tags":["auth"],"summary":"Registration","description":"Kratos registration UI redirector — forwards browser to the SPA.\n\nKratos is configured with ``SELFSERVICE_FLOWS_REGISTRATION_UI_URL``\npointing to ``{GK}/auth/registration``. When Kratos needs to display\na registration form (e.g., the user navigates to the registration page\nor a registration flow encounters a validation error), it redirects the\nbrowser here.\n\nGatekeeper does not render any UI. It simply forwards the browser to the\nSPA frontend at ``{FRONTEND}/registration`` with all query parameters\npreserved (typically ``flow=...`` which the SPA uses to fetch the\nregistration flow data from Kratos).\n\nThe ``login_challenge`` parameter may also be present in the query string\nif the registration was initiated from an OAuth2 flow. The SPA preserves\nthis parameter and threads it through the Kratos registration flow via\n``return_to``, so that after successful registration the user is\nredirected back to ``/auth/login`` to complete the OAuth2 flow.\n\nArgs:\n    request: The incoming HTTP request, used to extract and forward\n        query parameters to the SPA.\n    settings: Injected application settings for the frontend URL.\n\nReturns:\n    A 302 redirect to ``{FRONTEND}/registration?{original_query_params}``.","operationId":"registration_auth_registration_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/auth/verification":{"get":{"tags":["auth"],"summary":"Verification","description":"Kratos verification UI redirector — forwards browser to the SPA.\n\nKratos is configured with ``SELFSERVICE_FLOWS_VERIFICATION_UI_URL``\npointing to ``{GK}/auth/verification``. After a user clicks the\nverification link in their email and Kratos validates the code, Kratos\nredirects the browser here with a ``flow`` query parameter.\n\nGatekeeper forwards the browser to the SPA at\n``{FRONTEND}/verification?flow=...``. The SPA then fetches the flow\nstatus from Kratos (``GET /self-service/verification/flows?id=...``)\nand renders a success message (\"Your email has been verified\") or an\nerror message if the code was invalid or expired.\n\nGatekeeper's role is minimal — just proxying the redirect. Kratos\nhandles all verification logic (code validation, marking the email\nas verified on the identity).\n\nArgs:\n    request: The incoming HTTP request, used to extract and forward\n        query parameters (``flow``) to the SPA.\n    settings: Injected application settings for the frontend URL.\n\nReturns:\n    A 302 redirect to ``{FRONTEND}/verification?{original_query_params}``.","operationId":"verification_auth_verification_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/auth/settings":{"get":{"tags":["auth"],"summary":"Settings Redirect","description":"Kratos settings UI redirector — forwards browser to the SPA.\n\nKratos is configured with ``SELFSERVICE_FLOWS_SETTINGS_UI_URL`` pointing\nto ``{GK}/auth/settings``. Kratos redirects the browser here when:\n\n- The user navigates to account settings (change password, setup TOTP,\n  update profile).\n- The recovery flow completes and Kratos creates a privileged session,\n  then redirects to settings so the user can set a new password.\n\nThis endpoint is essential for TOTP setup (Flow 8) — the SPA fetches\nthe settings flow from Kratos which includes a QR code for the TOTP\nsecret. After the user scans it and submits the 6-digit code, Kratos\nenables TOTP on the identity. Subsequent logins will require a second\nfactor (Flow 9).\n\nArgs:\n    request: The incoming HTTP request, used to extract and forward\n        query parameters (``flow``) to the SPA.\n    settings: Injected application settings for the frontend URL.\n\nReturns:\n    A 302 redirect to ``{FRONTEND}/settings?{original_query_params}``.","operationId":"settings_redirect_auth_settings_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/auth/settings/password":{"get":{"tags":["auth"],"summary":"Password Settings Redirect","description":"Password settings continuation redirector.\n\nUsed when Gatekeeper needs a password-specific settings continuation\ntarget, such as recovery handoff or AAL2 step-up during password reset.\n\nArgs:\n    request: The incoming HTTP request, used to extract and forward\n        query parameters (``flow``) to the SPA.\n    settings: Injected application settings for the frontend URL.\n\nReturns:\n    A 302 redirect to ``{FRONTEND}/settings/password?{query_params}``.","operationId":"password_settings_redirect_auth_settings_password_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/auth/recovery":{"get":{"tags":["auth"],"summary":"Recovery Redirect","description":"Kratos recovery UI redirector — forwards browser to the SPA.\n\nKratos is configured with ``SELFSERVICE_FLOWS_RECOVERY_UI_URL`` pointing\nto ``{GK}/auth/recovery``. Kratos redirects the browser here when the\nuser initiates a password recovery flow or when a recovery flow\nencounters a validation error and the UI needs to be re-rendered.\n\nThe SPA fetches the recovery flow from Kratos using the ``flow`` query\nparameter and renders the appropriate form (email input to request a\nrecovery code, or code input to submit the received code).\n\nArgs:\n    request: The incoming HTTP request, used to extract and forward\n        query parameters (``flow``) to the SPA.\n    settings: Injected application settings for the frontend URL.\n\nReturns:\n    A 302 redirect to ``{FRONTEND}/recovery?{original_query_params}``.","operationId":"recovery_redirect_auth_recovery_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/auth/error":{"get":{"tags":["auth"],"summary":"Error Redirect","description":"Hydra/Kratos error UI redirector — forwards browser to the SPA.\n\nHydra is configured with ``URLS_ERROR`` pointing to ``{GK}/auth/error``.\nWhen Hydra or Kratos encounters an error (invalid client, expired\nchallenge, etc.), the browser is redirected here with an ``id`` query\nparameter referencing the error details.\n\nThe SPA fetches the error from Kratos (``GET /self-service/errors?id=...``)\nand displays a user-friendly error message.\n\nArgs:\n    request: The incoming HTTP request, used to extract and forward\n        query parameters (``id``) to the SPA.\n    settings: Injected application settings for the frontend URL.\n\nReturns:\n    A 302 redirect to ``{FRONTEND}/error?{original_query_params}``.","operationId":"error_redirect_auth_error_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/.well-known/openid-configuration":{"get":{"tags":["oauth2"],"summary":"Openid Configuration","operationId":"openid_configuration__well_known_openid_configuration_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/.well-known/oauth-authorization-server":{"get":{"tags":["oauth2"],"summary":"Oauth Authorization Server Metadata","operationId":"oauth_authorization_server_metadata__well_known_oauth_authorization_server_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/.well-known/jwks.json":{"get":{"tags":["oauth2"],"summary":"Jwks","operationId":"jwks__well_known_jwks_json_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/oauth2/introspect":{"post":{"tags":["oauth2"],"summary":"Oauth2 Introspect Proxy","operationId":"oauth2_introspect_proxy_oauth2_introspect_post","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/oauth2/register":{"post":{"tags":["oauth2"],"summary":"Oauth2 Register Mcp Client","description":"Register a constrained public MCP OAuth client.\n\nThis endpoint intentionally is not a general-purpose OIDC registration\nservice yet. It exists so MCP clients can register only PKCE-compatible,\nMCP-scoped clients. If Gatekeeper needs open-ended DCR later, add a\nseparate implementation instead of widening this MCP wrapper in place.","operationId":"oauth2_register_mcp_client_oauth2_register_post","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/oauth2/auth":{"get":{"tags":["oauth2"],"summary":"Oauth2 Auth Proxy","operationId":"oauth2_auth_proxy_oauth2_auth_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/oauth2/token":{"post":{"tags":["oauth2"],"summary":"Oauth2 Token Proxy","operationId":"oauth2_token_proxy_oauth2_token_post","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/oauth2/{path}":{"post":{"tags":["oauth2"],"summary":"Oauth2 Proxy","operationId":"oauth2_proxy_oauth2__path__post","parameters":[{"name":"path","in":"path","required":true,"schema":{"type":"string","title":"Path"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"get":{"tags":["oauth2"],"summary":"Oauth2 Proxy","operationId":"oauth2_proxy_oauth2__path__post","parameters":[{"name":"path","in":"path","required":true,"schema":{"type":"string","title":"Path"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/profile/me":{"get":{"tags":["profile"],"summary":"Current Profile","description":"Return the current user's profile in a client-facing shape.\n\nSupports browser requests authenticated with a Kratos session cookie and\nservice/API requests authenticated with a Hydra bearer access token.","operationId":"current_profile_profile_me_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CurrentProfileResponse"}}}}}}},"/profile/picture":{"put":{"tags":["profile"],"summary":"Upload Profile Picture","description":"Upload and attach a profile picture to the current Kratos identity.","operationId":"upload_profile_picture_profile_picture_put","requestBody":{"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/Body_upload_profile_picture_profile_picture_put"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProfilePictureResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"delete":{"tags":["profile"],"summary":"Delete Profile Picture","description":"Remove the current user's profile picture trait.","operationId":"delete_profile_picture_profile_picture_delete","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProfilePictureResponse"}}}}}}},"/self-service/{path}":{"post":{"tags":["selfservice"],"summary":"Selfservice Proxy","operationId":"selfservice_proxy_self_service__path__post","parameters":[{"name":"path","in":"path","required":true,"schema":{"type":"string","title":"Path"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"get":{"tags":["selfservice"],"summary":"Selfservice Proxy","operationId":"selfservice_proxy_self_service__path__post","parameters":[{"name":"path","in":"path","required":true,"schema":{"type":"string","title":"Path"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/sessions/{path}":{"delete":{"tags":["selfservice"],"summary":"Sessions Proxy","operationId":"sessions_proxy_sessions__path__delete","parameters":[{"name":"path","in":"path","required":true,"schema":{"type":"string","title":"Path"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"get":{"tags":["selfservice"],"summary":"Sessions Proxy","operationId":"sessions_proxy_sessions__path__delete","parameters":[{"name":"path","in":"path","required":true,"schema":{"type":"string","title":"Path"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}},"components":{"schemas":{"Body_upload_profile_picture_profile_picture_put":{"properties":{"file":{"type":"string","contentMediaType":"application/octet-stream","title":"File"}},"type":"object","required":["file"],"title":"Body_upload_profile_picture_profile_picture_put"},"CurrentProfileResponse":{"properties":{"id":{"type":"string","title":"Id"},"email":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Email"},"email_verified":{"type":"boolean","title":"Email Verified","default":false},"name":{"anyOf":[{"$ref":"#/components/schemas/ProfileNameResponse"},{"type":"null"}]},"picture":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Picture"},"password_updated_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Password Updated At"},"totp_enabled":{"type":"boolean","title":"Totp Enabled","default":false}},"type":"object","required":["id"],"title":"CurrentProfileResponse","description":"Formatted current-user profile response."},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"ManagementReturnContextResponse":{"properties":{"client_id":{"type":"string","title":"Client Id"},"client_name":{"type":"string","title":"Client Name"},"return_url":{"type":"string","title":"Return Url"}},"type":"object","required":["client_id","client_name","return_url"],"title":"ManagementReturnContextResponse","description":"Trusted button metadata returned to the SPA."},"ProfileNameResponse":{"properties":{"first":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"First"},"last":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Last"}},"type":"object","title":"ProfileNameResponse","description":"Current user's display name."},"ProfilePictureResponse":{"properties":{"picture":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Picture"}},"type":"object","required":["picture"],"title":"ProfilePictureResponse","description":"Profile picture URL response."},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"},"input":{"title":"Input"},"ctx":{"type":"object","title":"Context"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}}}}