mirror of
https://github.com/tips-of-mine/gestion-certificats2.git
synced 2025-06-28 11:38:42 +02:00
198 lines
3.0 KiB
Markdown
198 lines
3.0 KiB
Markdown
# API Documentation
|
|
|
|
## Base URL
|
|
```
|
|
http://localhost:980/api/v1
|
|
```
|
|
|
|
## Authentication
|
|
|
|
La plupart des endpoints nécessitent une authentification. Après connexion, incluez le token dans l'en-tête Authorization :
|
|
|
|
```
|
|
Authorization: Bearer <token>
|
|
```
|
|
|
|
## Endpoints
|
|
|
|
### Authentication
|
|
|
|
#### POST /auth/login
|
|
Connexion utilisateur.
|
|
|
|
**Body:**
|
|
```json
|
|
{
|
|
"username": "admin",
|
|
"password": "password"
|
|
}
|
|
```
|
|
|
|
**Response:**
|
|
```json
|
|
{
|
|
"success": true,
|
|
"message": "Login successful",
|
|
"data": {
|
|
"id": 1,
|
|
"username": "admin",
|
|
"role": "admin",
|
|
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9..."
|
|
}
|
|
}
|
|
```
|
|
|
|
#### POST /auth/logout
|
|
Déconnexion utilisateur.
|
|
|
|
#### GET /auth/me
|
|
Informations de l'utilisateur connecté.
|
|
|
|
### Certificates
|
|
|
|
#### GET /certificates
|
|
Liste paginée des certificats.
|
|
|
|
**Query Parameters:**
|
|
- `page` (int): Page à récupérer (défaut: 1)
|
|
- `per_page` (int): Nombre d'éléments par page (défaut: 50, max: 100)
|
|
|
|
**Response:**
|
|
```json
|
|
{
|
|
"success": true,
|
|
"data": {
|
|
"data": [...],
|
|
"current_page": 1,
|
|
"per_page": 50,
|
|
"total": 42,
|
|
"last_page": 1
|
|
}
|
|
}
|
|
```
|
|
|
|
#### POST /certificates
|
|
Créer un nouveau certificat.
|
|
|
|
**Body:**
|
|
```json
|
|
{
|
|
"subdomain_name": "www",
|
|
"functional_perimeter_id": 1
|
|
}
|
|
```
|
|
|
|
#### POST /certificates/{id}/revoke
|
|
Révoquer un certificat.
|
|
|
|
#### GET /certificates/download
|
|
Télécharger un certificat.
|
|
|
|
**Query Parameters:**
|
|
- `type`: Type de certificat (`root`, `intermediate`, `simple`)
|
|
- `file`: Nom du fichier
|
|
- `perimeter`: Nom du périmètre (requis pour intermediate/simple)
|
|
|
|
#### GET /certificates/stats
|
|
Statistiques des certificats.
|
|
|
|
**Response:**
|
|
```json
|
|
{
|
|
"success": true,
|
|
"data": {
|
|
"total": 42,
|
|
"active": 38,
|
|
"revoked": 4,
|
|
"expiring_soon": [...]
|
|
}
|
|
}
|
|
```
|
|
|
|
### Functional Perimeters
|
|
|
|
#### GET /perimeters
|
|
Liste des périmètres fonctionnels.
|
|
|
|
#### POST /perimeters
|
|
Créer un nouveau périmètre.
|
|
|
|
**Body:**
|
|
```json
|
|
{
|
|
"name": "Finance",
|
|
"intermediate_passphrase": "optional_passphrase"
|
|
}
|
|
```
|
|
|
|
### Users
|
|
|
|
#### GET /users
|
|
Liste des utilisateurs (Admin uniquement).
|
|
|
|
#### POST /users
|
|
Créer un nouvel utilisateur (Admin uniquement).
|
|
|
|
**Body:**
|
|
```json
|
|
{
|
|
"username": "newuser",
|
|
"password": "securepassword",
|
|
"role": "user"
|
|
}
|
|
```
|
|
|
|
#### DELETE /users/{id}
|
|
Supprimer un utilisateur (Admin uniquement).
|
|
|
|
#### PUT /users/{id}/role
|
|
Modifier le rôle d'un utilisateur (Admin uniquement).
|
|
|
|
**Body:**
|
|
```json
|
|
{
|
|
"role": "admin"
|
|
}
|
|
```
|
|
|
|
#### PUT /users/{id}/password
|
|
Modifier le mot de passe d'un utilisateur (Admin uniquement).
|
|
|
|
**Body:**
|
|
```json
|
|
{
|
|
"new_password": "newpassword",
|
|
"confirm_password": "newpassword"
|
|
}
|
|
```
|
|
|
|
### Dashboard
|
|
|
|
#### GET /dashboard/stats
|
|
Statistiques générales du dashboard.
|
|
|
|
## Error Responses
|
|
|
|
Toutes les erreurs suivent ce format :
|
|
|
|
```json
|
|
{
|
|
"success": false,
|
|
"message": "Error description",
|
|
"errors": {
|
|
"field": ["Validation error message"]
|
|
}
|
|
}
|
|
```
|
|
|
|
### Status Codes
|
|
|
|
- `200`: OK
|
|
- `201`: Created
|
|
- `400`: Bad Request
|
|
- `401`: Unauthorized
|
|
- `403`: Forbidden
|
|
- `404`: Not Found
|
|
- `405`: Method Not Allowed
|
|
- `422`: Unprocessable Entity
|
|
- `500`: Internal Server Error |