- 6 docs racine (README, HANDOVER, ARCHITECTURE, DECISIONS, INSTALL, OPERATIONS) - 9 docs thématiques dans docs/ - 10 templates docker-compose dans configs/ - 7 scripts Python/Shell d'import Furious vers Zitadel - 2 matrices RBAC Etat infra au 5 juin 2026 : - 88 users Furious importes dans Zitadel - 8 roles RBAC crees et attribues - Intranet filtre les cartes selon role (Approche A) - 7 outils SSO operationnels
102 lines
2.9 KiB
Python
Executable File
102 lines
2.9 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""
|
|
generate-roles-mapping.py — Génère le fichier JSON mappant email → rôle.
|
|
|
|
Output : roles-mapping.json (utilisé par l'intranet pour le filtrage RBAC côté JS).
|
|
|
|
Mapping :
|
|
- status == "apprenti" → "alternant"
|
|
- sinon, lookup dans JOB_TITLE_TO_ROLE par job_title
|
|
|
|
Stagiaires : ceux avec status="stagiaire" devraient être mappés en "stagiaire" mais
|
|
attention, certains apparaissent comme "apprenti" dans Furious (à corriger source).
|
|
|
|
Auteur : Hedi Kalboussi
|
|
Date : 5 juin 2026
|
|
"""
|
|
|
|
import json
|
|
from collections import Counter
|
|
from pathlib import Path
|
|
|
|
SCRIPT_DIR = Path(__file__).parent
|
|
RAW_DATA_FILE = SCRIPT_DIR / "furious-users-raw.json"
|
|
OUTPUT_FILE = SCRIPT_DIR / "roles-mapping.json"
|
|
|
|
# Mapping job_title (Furious) → role (Zitadel)
|
|
JOB_TITLE_TO_ROLE = {
|
|
# DIRECTION
|
|
"président": "direction",
|
|
"directeur": "direction",
|
|
"directeur associé": "direction",
|
|
# MANAGER
|
|
"senior manager": "manager",
|
|
"sénior manager": "manager",
|
|
"manager": "manager",
|
|
"manager bi": "manager",
|
|
# EXPERT
|
|
"expert": "expert",
|
|
"expert n2": "expert",
|
|
"consultant expert niveau 1": "expert",
|
|
# CONSULTANT SENIOR
|
|
"consultant sénior": "consultant_senior",
|
|
"consultant expérimenté": "consultant_senior",
|
|
"consultant expérimentée": "consultant_senior",
|
|
# CONSULTANT JUNIOR
|
|
"consultant junior": "consultant_junior",
|
|
# STAGIAIRE
|
|
"stagiaire": "stagiaire",
|
|
# SUPPORT
|
|
"assistante": "support",
|
|
"assistante de direction": "support",
|
|
"chargé de recrutement": "support",
|
|
"marketing": "support",
|
|
}
|
|
|
|
|
|
def determine_role(user):
|
|
"""Détermine le rôle d'un user selon son status (apprenti) ou job_title."""
|
|
# Cas spécial : apprenti = alternant
|
|
if user.get("status") == "apprenti":
|
|
return "alternant"
|
|
|
|
job_title = (user.get("job_title") or "").strip().lower()
|
|
if not job_title:
|
|
return None
|
|
|
|
return JOB_TITLE_TO_ROLE.get(job_title)
|
|
|
|
|
|
def main():
|
|
with open(RAW_DATA_FILE) as f:
|
|
data = json.load(f)
|
|
|
|
actifs = [
|
|
u for u in data.get("data", {}).get("User", [])
|
|
if u.get("departure_date") == "0000-00-00"
|
|
]
|
|
|
|
mapping = {}
|
|
for u in actifs:
|
|
email = u.get("email", "").lower()
|
|
role = determine_role(u)
|
|
if email and role:
|
|
mapping[email] = role
|
|
|
|
# Sauvegarder
|
|
with open(OUTPUT_FILE, "w", encoding="utf-8") as f:
|
|
json.dump(mapping, f, indent=2, ensure_ascii=False)
|
|
|
|
# Statistiques
|
|
role_stats = Counter(mapping.values())
|
|
print(f"✅ Fichier généré : {OUTPUT_FILE}")
|
|
print(f" Total : {len(mapping)} users mappés")
|
|
print(f" Sans rôle : {len(actifs) - len(mapping)}")
|
|
print(f"\nRépartition par rôle :")
|
|
for role, count in role_stats.most_common():
|
|
print(f" {role:<20} : {count}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|