feat(admin): fondation auth de l'application d'administration #7
Closed
kyuno
wants to merge 1 commit from
feat/admin-auth into main
pull from: feat/admin-auth
merge into: kyuno:main
kyuno:main
kyuno:feat/temperature-metadata
kyuno:feat/merge-admin-into-web
kyuno:fix/mocha-db-suites-first-run
kyuno:feat/admin-tech-steps
kyuno:feat/off-catalog-ingredients
kyuno:feat/cooking-session-ui
kyuno:feat/admin-monitoring
kyuno:feat/admin-metrics
kyuno:feat/admin-web-scaffold
kyuno:feat/cooking-session-api
kyuno:feat/cooking-optimizer-engine
kyuno:feat/tech-step-correction-merged-editor
kyuno:fix/tech-step-correction-metadata-discoverability
kyuno:feat/tech-step-correction-metadata
kyuno:feat/tech-step-metadata
kyuno:feat/tech-step-intent-service
kyuno:feat/shopping-list
kyuno:feat/fr-ingredient-unit-matching
kyuno:feat/sources-infinite-scroll
kyuno:fix/750g-browse-empty-query
kyuno:feat/marmiton-recipe-source
kyuno:feat/tech-step-detection-reliability
kyuno:experiment/llm-tech-step-poc
kyuno:feat/nlp-tech-step-detection
kyuno:chore/biome-style-rules
kyuno:feat/unify-source-detail-view
kyuno:fix/isolate-test-database
kyuno:fix/json-ld-not-a-browsable-source
kyuno:feat/browse-sources-backend
kyuno:feat/browse-sources-ui
kyuno:feat/import-recipe-review
kyuno:feat/plan-import-flow
kyuno:feat/highlight-tech-steps
kyuno:fix/runtime-seed-source-sync
kyuno:feat/english-matching
kyuno:feat/jsonld-source-adapter
kyuno:feat/recipe-step-translation
kyuno:feat/themealdb-source-icon
kyuno:feat/house-source-preferences
kyuno:feat/tech-steps-catalog
kyuno:feat/recipe-source-adapter
kyuno:feat/recipe-source-linking
kyuno:feat/ingredient-unit-catalog
kyuno:feat/ingredient-reproducible-flag
kyuno:refactor/catalog-camel-case-uids
kyuno:experiment/cucumber-cypress
kyuno:feat/recipe-catalog-v2
kyuno:feat/planning-page-design
kyuno:feat/settings-household-account
kyuno:feat/user-preferences-sidebar-nav
1 commit
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
| cf8ef26f63 |
feat(admin): fondation auth de l'application d'administration
Premiere brique de l'app d'admin independante : une surface /admin/*
ajoutee a apps/api, avec une authentification totalement distincte de
celle des utilisateurs.
- Table AdminUser isolee (aucune relation vers UserProfile), migration
20260828120000_admin_user.
- lib/admin-jwt.ts : sign/verify d'un JWT admin, secret ADMIN_JWT_SECRET
propre (jamais interchangeable avec JWT_SECRET).
- middlewares/require-admin.ts : cookie admin_session dedie, re-check
tokenVersion, echoue ferme si ADMIN_JWT_SECRET absent (posture
requireInternalWorker). res.locals.adminUser type via AdminLocals.
- modules/admin/ : admin-auth.{routes,service}.ts (POST /login, POST
/logout, GET /me), admin.routes.ts agregateur monte /admin. Pas de
signup expose.
- lib/safe-admin.ts : mapping AdminUser -> AdminUserView (drop passwordHash
+ tokenVersion, dates ISO).
- scripts/create-admin.ts : creation du 1er admin hors-bande (flags ou
ADMIN_INITIAL_*).
- CORS : setupCore accepte string[] ; app.ts autorise CORS_ORIGIN +
ADMIN_CORS_ORIGIN.
- Shared : schemas/admin.ts (adminLoginSchema), types/admin.ts
(AdminUserView).
- Env : ADMIN_JWT_SECRET (optionnel), ADMIN_COOKIE_NAME, ADMIN_CORS_ORIGIN,
ADMIN_INITIAL_* ; .env.example, .env.test.example, docker-compose.yml,
ci.yml mis a jour.
- reset-db.ts truncate admin_users.
- Tests Mocha admin-auth.test.ts : 400 sans body, 401 email inconnu /
mauvais mdp, login OK (cookie pose, lastLoginAt, pas de hash/tokenVersion
dans la reponse), /me derriere requireAdmin, logout, et un cookie
`session` d'utilisateur normal ne donne pas acces a /admin/*.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|