cognee_http_server/dto/auth.rs
1//! DTOs for the auth router (login / logout / me).
2
3use serde::{Deserialize, Serialize};
4use utoipa::ToSchema;
5
6/// Request body for `POST /api/v1/auth/login`.
7/// Wire format: `application/x-www-form-urlencoded` (OAuth2 password grant).
8/// Pydantic source: `fastapi.security.OAuth2PasswordRequestForm`.
9#[derive(Debug, Deserialize, ToSchema)]
10pub struct LoginPayloadDTO {
11 /// Email address of the user. fastapi-users keeps the OAuth2 spelling.
12 pub username: String,
13 pub password: String,
14 /// Always ignored; accepted for OAuth2 compliance.
15 #[serde(default)]
16 pub grant_type: Option<String>,
17 #[serde(default)]
18 pub scope: Option<String>,
19 #[serde(default)]
20 pub client_id: Option<String>,
21 #[serde(default)]
22 pub client_secret: Option<String>,
23}
24
25/// Successful login response body.
26#[derive(Debug, Serialize, ToSchema)]
27pub struct LoginResponseDTO {
28 /// JWT (HS256, audience `fastapi-users:auth`). Same value as the cookie.
29 pub access_token: String,
30 /// Always the literal string `"bearer"`.
31 pub token_type: &'static str,
32}
33
34/// Response body for `GET /api/v1/auth/me` — cognee's narrow shape (NOT fastapi-users `UserRead`).
35/// Pydantic source: ad-hoc dict in `get_auth_router.py:52-54`.
36#[derive(Debug, Serialize, ToSchema)]
37pub struct MeShortResponseDTO {
38 pub email: String,
39}
40
41/// Response body for `POST /api/v1/auth/logout`. Always `{}`.
42#[derive(Debug, Default, Serialize, ToSchema)]
43pub struct LogoutResponseDTO {}