Fondation
This commit is contained in:
parent
bb5ff67250
commit
a0b11c7b5f
1217
AUDIT_COMPLET.md
1217
AUDIT_COMPLET.md
File diff suppressed because it is too large
Load Diff
@ -1,36 +0,0 @@
|
|||||||
# Fichiers supprimés - Nettoyage du projet ✅
|
|
||||||
|
|
||||||
## ✅ Fichiers Electron (abandonnés) - SUPPRIMÉS
|
|
||||||
|
|
||||||
1. ✅ **`electron/`** - Dossier vide supprimé
|
|
||||||
2. ✅ **`index.js`** - Point d'entrée Electron supprimé
|
|
||||||
3. ✅ **`package.json`** - Ligne `"main": "index.js"` supprimée
|
|
||||||
|
|
||||||
## ✅ Fichiers de test (scripts de développement) - SUPPRIMÉS
|
|
||||||
|
|
||||||
4. ✅ **`test-upload.js`** - Script de test avec credentials hardcodés (sécurité)
|
|
||||||
5. ✅ **`scripts/test-user-deletion.js`** - Script de test pour la suppression d'utilisateurs
|
|
||||||
6. ✅ **`scripts/test-redis.js`** - Script de test Redis
|
|
||||||
7. ✅ **`scripts/test-redis-env.js`** - Script de test Redis avec variables d'environnement
|
|
||||||
|
|
||||||
## ✅ Fichiers SQL de test/exploration - SUPPRIMÉS
|
|
||||||
|
|
||||||
8. ✅ **`db_query.sql`** - Requête SQL de test simple
|
|
||||||
|
|
||||||
## 📝 Résumé
|
|
||||||
|
|
||||||
**Total supprimé : 8 fichiers + 1 modification dans package.json**
|
|
||||||
|
|
||||||
### Fichiers restants à vérifier manuellement
|
|
||||||
|
|
||||||
Si vous avez d'autres fichiers de test shell (`.sh`) ou Python (`.py`) dans le répertoire racine qui commencent par `test-`, vous pouvez les supprimer également. Ils ne sont pas utilisés par l'application en production.
|
|
||||||
|
|
||||||
### Scripts conservés (utiles pour la production)
|
|
||||||
|
|
||||||
Les scripts suivants dans `scripts/` sont **conservés** car ils sont utiles :
|
|
||||||
- `validate-env.ts` - Validation des variables d'environnement
|
|
||||||
- `migrate-prod.sh` - Migration de production
|
|
||||||
- `verify-vercel-config.sh` - Vérification de configuration Vercel
|
|
||||||
- `update-database-url.sh` - Mise à jour de DATABASE_URL
|
|
||||||
- `sync-users.js` / `sync-calendars.js` - Scripts de synchronisation
|
|
||||||
- Scripts de nettoyage et migration SQL
|
|
||||||
@ -350,15 +350,16 @@ export async function DELETE(request: Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function PATCH(request: Request) {
|
export async function PATCH(request: Request) {
|
||||||
|
// Authenticate user (declare outside try to access in catch)
|
||||||
|
const session = await getServerSession(authOptions);
|
||||||
|
if (!session?.user?.id) {
|
||||||
|
return NextResponse.json(
|
||||||
|
{ error: 'Unauthorized' },
|
||||||
|
{ status: 401 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Authenticate user
|
|
||||||
const session = await getServerSession(authOptions);
|
|
||||||
if (!session?.user?.id) {
|
|
||||||
return NextResponse.json(
|
|
||||||
{ error: 'Unauthorized' },
|
|
||||||
{ status: 401 }
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parse request body
|
// Parse request body
|
||||||
const body = await request.json();
|
const body = await request.json();
|
||||||
|
|||||||
@ -1,338 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "Keycloak User Creation",
|
|
||||||
"nodes": [
|
|
||||||
{
|
|
||||||
"parameters": {
|
|
||||||
"path": "create-user",
|
|
||||||
"options": {
|
|
||||||
"responseMode": "lastNode",
|
|
||||||
"responseData": "allEntries"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"name": "Webhook",
|
|
||||||
"type": "n8n-nodes-base.webhook",
|
|
||||||
"typeVersion": 1,
|
|
||||||
"position": [
|
|
||||||
100,
|
|
||||||
300
|
|
||||||
],
|
|
||||||
"webhookId": "create-user-webhook"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"parameters": {
|
|
||||||
"url": "https://connect.slm-lab.net/admin/realms/cercle/users",
|
|
||||||
"options": {},
|
|
||||||
"authentication": "genericCredentialType",
|
|
||||||
"genericAuthType": "httpHeaderAuth",
|
|
||||||
"nodeCredentialType": "httpHeaderAuth",
|
|
||||||
"headerParameters": {
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"name": "Authorization",
|
|
||||||
"value": "={{$node[\"Get Admin Token\"].json[\"access_token\"]}}"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"name": "HTTP Request",
|
|
||||||
"type": "n8n-nodes-base.httpRequest",
|
|
||||||
"typeVersion": 3,
|
|
||||||
"position": [
|
|
||||||
500,
|
|
||||||
300
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"parameters": {
|
|
||||||
"url": "https://connect.slm-lab.net/realms/cercle/protocol/openid-connect/token",
|
|
||||||
"options": {},
|
|
||||||
"authentication": "genericCredentialType",
|
|
||||||
"genericAuthType": "httpHeaderAuth",
|
|
||||||
"nodeCredentialType": "httpHeaderAuth",
|
|
||||||
"headerParameters": {
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"name": "Content-Type",
|
|
||||||
"value": "application/x-www-form-urlencoded"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"bodyParameters": {
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"name": "grant_type",
|
|
||||||
"value": "client_credentials"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "client_id",
|
|
||||||
"value": "lab"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "client_secret",
|
|
||||||
"value": "LwgeE1ntADD20OuWC88S3pR0EaO7FtO4"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"name": "Get Admin Token",
|
|
||||||
"type": "n8n-nodes-base.httpRequest",
|
|
||||||
"typeVersion": 3,
|
|
||||||
"position": [
|
|
||||||
300,
|
|
||||||
300
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"parameters": {
|
|
||||||
"conditions": {
|
|
||||||
"string": [
|
|
||||||
{
|
|
||||||
"value1": "={{$json[\"isValid\"]}}",
|
|
||||||
"value2": "false"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"name": "IF",
|
|
||||||
"type": "n8n-nodes-base.if",
|
|
||||||
"typeVersion": 1,
|
|
||||||
"position": [
|
|
||||||
300,
|
|
||||||
500
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"parameters": {
|
|
||||||
"functionCode": "// Validate username according to Keycloak requirements\nconst username = $input.item.json.username;\n\n// Keycloak username requirements:\n// - Only alphanumeric characters, dots (.), hyphens (-), and underscores (_)\n// - Must start with a letter or number\n// - Must be between 3 and 255 characters\nconst usernameRegex = /^[a-zA-Z0-9][a-zA-Z0-9._-]{2,254}$/;\n\nif (!usernameRegex.test(username)) {\n return {\n isValid: false,\n error: \"Le nom d'utilisateur doit commencer par une lettre ou un chiffre, ne contenir que des lettres, chiffres, points, tirets et underscores, et faire entre 3 et 255 caractères\"\n };\n}\n\nreturn { isValid: true };"
|
|
||||||
},
|
|
||||||
"name": "Validate Username",
|
|
||||||
"type": "n8n-nodes-base.function",
|
|
||||||
"typeVersion": 1,
|
|
||||||
"position": [
|
|
||||||
300,
|
|
||||||
400
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"parameters": {
|
|
||||||
"url": "https://connect.slm-lab.net/admin/realms/cercle/roles",
|
|
||||||
"options": {}
|
|
||||||
},
|
|
||||||
"name": "Get Available Roles",
|
|
||||||
"type": "n8n-nodes-base.httpRequest",
|
|
||||||
"typeVersion": 3,
|
|
||||||
"position": [
|
|
||||||
500,
|
|
||||||
400
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"parameters": {
|
|
||||||
"functionCode": "// Filter valid roles\nconst requestedRoles = $input.item.json.roles || [];\nconst availableRoles = $input.item.json.roles;\n\nconst validRoles = requestedRoles.filter(roleName => \n availableRoles.some(r => r.name === roleName)\n);\n\nif (validRoles.length === 0) {\n return {\n isValid: false,\n error: \"Aucun rôle valide n'a été spécifié\"\n };\n}\n\nreturn {\n isValid: true,\n validRoles: validRoles,\n roleObjects: validRoles.map(roleName => \n availableRoles.find(r => r.name === roleName)\n )\n};"
|
|
||||||
},
|
|
||||||
"name": "Validate Roles",
|
|
||||||
"type": "n8n-nodes-base.function",
|
|
||||||
"typeVersion": 1,
|
|
||||||
"position": [
|
|
||||||
700,
|
|
||||||
400
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"parameters": {
|
|
||||||
"url": "https://connect.slm-lab.net/admin/realms/cercle/users",
|
|
||||||
"options": {},
|
|
||||||
"body": {
|
|
||||||
"username": "={{$input.item.json.username}}",
|
|
||||||
"enabled": true,
|
|
||||||
"emailVerified": true,
|
|
||||||
"firstName": "={{$input.item.json.firstName}}",
|
|
||||||
"lastName": "={{$input.item.json.lastName}}",
|
|
||||||
"email": "={{$input.item.json.email}}",
|
|
||||||
"credentials": [
|
|
||||||
{
|
|
||||||
"type": "password",
|
|
||||||
"value": "={{$input.item.json.password}}",
|
|
||||||
"temporary": false
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"name": "Create User",
|
|
||||||
"type": "n8n-nodes-base.httpRequest",
|
|
||||||
"typeVersion": 3,
|
|
||||||
"position": [
|
|
||||||
900,
|
|
||||||
400
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"parameters": {
|
|
||||||
"url": "https://connect.slm-lab.net/admin/realms/cercle/users?username={{$input.item.json.username}}",
|
|
||||||
"options": {}
|
|
||||||
},
|
|
||||||
"name": "Get Created User",
|
|
||||||
"type": "n8n-nodes-base.httpRequest",
|
|
||||||
"typeVersion": 3,
|
|
||||||
"position": [
|
|
||||||
1100,
|
|
||||||
400
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"parameters": {
|
|
||||||
"url": "https://connect.slm-lab.net/admin/realms/cercle/users/{{$input.item.json[0].id}}/role-mappings/realm",
|
|
||||||
"options": {},
|
|
||||||
"body": "={{$input.item.json.roleObjects}}"
|
|
||||||
},
|
|
||||||
"name": "Assign Roles",
|
|
||||||
"type": "n8n-nodes-base.httpRequest",
|
|
||||||
"typeVersion": 3,
|
|
||||||
"position": [
|
|
||||||
1300,
|
|
||||||
400
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"parameters": {
|
|
||||||
"functionCode": "// Format success response\nreturn {\n success: true,\n user: {\n ...$input.item.json[0],\n roles: $input.item.json.validRoles\n }\n};"
|
|
||||||
},
|
|
||||||
"name": "Format Response",
|
|
||||||
"type": "n8n-nodes-base.function",
|
|
||||||
"typeVersion": 1,
|
|
||||||
"position": [
|
|
||||||
1500,
|
|
||||||
400
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"parameters": {
|
|
||||||
"functionCode": "// Format error response\nreturn {\n success: false,\n error: $input.item.json.error\n};"
|
|
||||||
},
|
|
||||||
"name": "Format Error",
|
|
||||||
"type": "n8n-nodes-base.function",
|
|
||||||
"typeVersion": 1,
|
|
||||||
"position": [
|
|
||||||
500,
|
|
||||||
600
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"connections": {
|
|
||||||
"Webhook": {
|
|
||||||
"main": [
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"node": "Get Admin Token",
|
|
||||||
"type": "main",
|
|
||||||
"index": 0
|
|
||||||
}
|
|
||||||
]
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"Get Admin Token": {
|
|
||||||
"main": [
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"node": "HTTP Request",
|
|
||||||
"type": "main",
|
|
||||||
"index": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"node": "Validate Username",
|
|
||||||
"type": "main",
|
|
||||||
"index": 0
|
|
||||||
}
|
|
||||||
]
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"Validate Username": {
|
|
||||||
"main": [
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"node": "IF",
|
|
||||||
"type": "main",
|
|
||||||
"index": 0
|
|
||||||
}
|
|
||||||
]
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"IF": {
|
|
||||||
"main": [
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"node": "Format Error",
|
|
||||||
"type": "main",
|
|
||||||
"index": 0
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"node": "Get Available Roles",
|
|
||||||
"type": "main",
|
|
||||||
"index": 0
|
|
||||||
}
|
|
||||||
]
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"Get Available Roles": {
|
|
||||||
"main": [
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"node": "Validate Roles",
|
|
||||||
"type": "main",
|
|
||||||
"index": 0
|
|
||||||
}
|
|
||||||
]
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"Validate Roles": {
|
|
||||||
"main": [
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"node": "Create User",
|
|
||||||
"type": "main",
|
|
||||||
"index": 0
|
|
||||||
}
|
|
||||||
]
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"Create User": {
|
|
||||||
"main": [
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"node": "Get Created User",
|
|
||||||
"type": "main",
|
|
||||||
"index": 0
|
|
||||||
}
|
|
||||||
]
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"Get Created User": {
|
|
||||||
"main": [
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"node": "Assign Roles",
|
|
||||||
"type": "main",
|
|
||||||
"index": 0
|
|
||||||
}
|
|
||||||
]
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"Assign Roles": {
|
|
||||||
"main": [
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"node": "Format Response",
|
|
||||||
"type": "main",
|
|
||||||
"index": 0
|
|
||||||
}
|
|
||||||
]
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"settings": {
|
|
||||||
"executionOrder": "v1"
|
|
||||||
},
|
|
||||||
"version": 1
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue
Block a user