Commit Graph

148 Commits

Author SHA1 Message Date
Théophile Gervreau-Mercier
7fca85d1c1 refactor: rename database → storage
More semantically accurate: contains SQLite files, schema, fixtures, test data.
Updated all references in code, scripts, docs.
2026-02-12 12:12:58 +01:00
Théophile Gervreau-Mercier
0e4921583e refactor: reorganize to standard PHP structure
- Moved /lib → /src (PHP source code)
- Moved /includes → /public/includes (main site templates)
- Admin section remains self-contained in /public/admin with its own /inc
- Updated all require/include paths across codebase
- Updated config/bootstrap.php, justfile, tests, docs
- All tests passing 

Structure now follows PHP best practices:
  /config      - Configuration files
  /database    - SQLite database + schema
  /docs        - Documentation (intact)
  /nginx       - Server config (intact)
  /public      - Web-accessible files (entry point)
    /admin     - Self-contained admin interface
    /assets    - CSS, fonts, icons
    /includes  - Main site templates (header/footer)
  /scripts     - Deployment scripts (intact)
  /src         - PHP source classes (Database, AdminAuth, RateLimit)
  /tests       - Test suites
2026-02-12 12:11:16 +01:00
Théophile Gervreau-Mercier
0b650cd3e7 Work on the admin section styling 2026-02-12 12:07:50 +01:00
Théophile Gervreau-Mercier
8613f71112 security: add PHP session auth guard for admin panel (item #2, CRITICAL)
- lib/AdminAuth.php: new class with requireLogin(), login(), logout(),
  isAuthenticated(); starts session with hardened cookie params
  (HttpOnly, SameSite=Strict, Secure, Path=/admin) — also resolves
  item #8 (session cookie hardening)
- requireLogin() auto-authenticates from nginx Basic Auth credentials
  ($_SERVER['PHP_AUTH_PW']) so the user only sees one browser prompt;
  falls back to /admin/login.php if the proxy is absent/misconfigured
- config/admin_credentials.php: gitignored credential store; define
  ADMIN_PASSWORD_HASH with a bcrypt hash to enable PHP auth
- config/admin_credentials.example.php: template for the above
- config/bootstrap.php: auto-loads admin_credentials.php if present
- .gitignore: exclude config/admin_credentials.php
- public/admin/login.php: fallback login form (shown only when nginx
  Basic Auth is bypassed / proxy absent)
- public/admin/logout.php: session destruction + redirect to login
- All 7 admin PHP files: replace session_start() with
  AdminAuth::requireLogin() (defence-in-depth behind nginx Basic Auth)
- public/admin/inc/head.php: Déconnexion button when ADMIN_PASSWORD_HASH
  is defined
- nginx/PHP_AUTH_LAYER.md: documents dual-auth architecture, UX flow,
  and setup instructions
- docs/TODO.SECURITY.md: items #2 and #8 moved to Resolved; priority
  order updated (all CRITICAL done)
2026-02-08 14:22:45 +01:00
Théophile Gervreau-Mercier
a2b1ff5f41 security: fix all HIGH priority items from TODO.SECURITY.md
Items resolved:
- #3 (HIGH): Move file uploads outside webroot to STORAGE_ROOT (/var/www/posterg/storage).
  Uploads were previously stored in public/admin/actions/data/ which is web-accessible.
- #4 (HIGH): Align file paths and add media.php controller.
  DB paths are now storage-relative (theses/YEAR/ID/file, covers/file).
  New public/media.php serves files with path-traversal jail, MIME allow-list,
  and proper caching headers. memoire.php and search.php updated to use /media.php?path=.
  Also fixed: cover images were never recorded in thesis_files (broken INSERT).
- #5 (HIGH): RateLimit::getClientIdentifier() now uses REMOTE_ADDR only.
  HTTP_X_FORWARDED_FOR and HTTP_CLIENT_IP are attacker-controlled headers that
  allowed unlimited rate-limit bypass by rotating spoofed IPs.
- #6 (HIGH): Port public/admin/.htaccess security rules to nginx/posterg.conf.
  Apache .htaccess directives are silently ignored by nginx; none were active.
  CSP added to /admin/ location block, .log file denial added globally,
  autoindex off made explicit. Documented in nginx/HTACCESS_TO_NGINX.md.

Supporting changes:
- config/bootstrap.php: add STORAGE_ROOT constant
- nginx/SECURITY_HEADERS.md: updated to reflect admin CSP and pending public CSP
- docs/TODO.SECURITY.md: items #3-6 moved to resolved; priority order updated
2026-02-08 14:01:45 +01:00
Théophile Gervreau-Mercier
f5d3281c43 security: fix all LOW priority items from TODO.SECURITY.md
Item 13 — Remove deprecated X-XSS-Protection header
- nginx/posterg.conf: header removed (was '1; mode=block')
- nginx/SECURITY_HEADERS.md: new file documenting header decisions
  and explaining why X-XSS-Protection is counterproductive

Item 14 — Add rel="noreferrer" to external target="_blank" link
- public/admin/thanks.php: rel="noopener" → rel="noopener noreferrer"

Item 15 — Explicit (int) casts on all integer HTML outputs
- public/index.php: (int) on item id, page numbers
- public/search.php: (int) on totalItems, year options, item id, pagination

Item 16 — Remove unused DATABASE_PATH constant
- config/bootstrap.php: define('DATABASE_PATH', ...) removed

docs/TODO.SECURITY.md updated: items 13-16 marked resolved and
moved to the  Resolved section.
2026-02-08 13:54:02 +01:00
Théophile Gervreau-Mercier
94d110438f docs: rewrite admin panel README 2026-02-08 11:58:48 +01:00
Théophile Gervreau-Mercier
df611b0333 admin: unify templates, dynamic navigation, and PHP cleanup 2026-02-08 11:58:43 +01:00
Théophile Gervreau-Mercier
52decc3e5f admin css: expand stylesheet with reusable component classes 2026-02-08 11:58:38 +01:00
Théophile Gervreau-Mercier
87f0838b5d dev: add live-reload development server 2026-02-08 11:58:35 +01:00
Théophile Gervreau-Mercier
52f8e267e5 admin: restructure action scripts to actions/ subdirectory 2026-02-08 11:58:33 +01:00
Théophile Gervreau-Mercier
f7132ecb7d CSS fixup 2026-02-06 14:29:09 +01:00
Théophile Gervreau-Mercier
4bbbc58e24 Fix admin CSS not loading and quirks mode issues
Fixed multiple issues in admin panel:

1. CSS path: modern-normalize.css → modern-normalize.min.css
   (File is actually named .min.css)

2. Icon path: assets/icon.svg → /assets/admin_favicon.svg
   (Was relative, now absolute; correct filename)

3. Navigation: /admin/list.php → /admin/
   (list.php was renamed to index.php)

4. Short PHP tags: <? → <?php
   (Better compatibility, some servers don't enable short_open_tag)

5. Quirks mode warning was due to CSS not loading, not DOCTYPE
   (DOCTYPE was already present)

Files modified:
- public/admin/inc/head.php (main fixes)
- public/admin/index.php (short tags)
- public/admin/add.php (short tags)
- public/admin/import.php (short tags)

Need to redeploy for production: just deploy
2026-02-06 13:26:24 +01:00
Théophile Gervreau-Mercier
e789c286de Refactor admin panel and add migration documentation
- Add comprehensive migration guides (DEPLOYMENT_MIGRATION.md, DIRECTORY_STRUCTURE.md, MIGRATION_CHECKLIST.md)
- Refactor admin panel: split add.php, create reusable header/footer
- Update styles: admin.css, common.css, main.css
- Improve public pages: index.php, memoire.php
- Reorganize database documentation into database/docs/
- Update .gitignore and justfile

This prepares for migration to public/ directory structure
2026-02-06 12:14:21 +01:00
Théophile Gervreau-Mercier
d2b3c6ca67 Major refactor
- update the structure to have monolithic setup
- updated deployments
- added live-reloading for devops
2026-02-05 20:16:19 +01:00
Théophile Gervreau-Mercier
f23fbb481b Nginx config, working deploy, basic theme, repo cleanup 2026-02-05 17:37:07 +01:00
Théophile Gervreau-Mercier
2cb5436647 Added Claude assessements 2026-02-02 18:56:12 +01:00
Théophile Gervreau-Mercier
467aced734 Restructure repository and implement secure search feature
Phase 1: Consolidate shared infrastructure
- Create shared/ directory for common code
- Consolidate Database.php from front-backend and formulaire into unified shared/Database.php
  - Smart path detection for test.db vs posterg.db
  - Secure search with wildcard escaping and input validation
  - Support both singleton and direct instantiation patterns
  - Full CRUD methods for admin functionality
- Move RateLimit.php to shared/ (30 requests/min)
- Update all require paths across apps to use shared/

Phase 2: Reorganize directory structure
- Rename front-backend/ → apps/public/
- Rename formulaire/ → apps/admin/
- Rename db/ → database/
- Update all file paths for new structure
- Create root .gitignore excluding databases, cache, logs

Implement secure search feature
- Add apps/public/search.php with full-text search across theses
- Search filters: query, year, orientation, AP program, keywords
- Security features:
  - SQL injection prevention (prepared statements)
  - Wildcard injection prevention (escape % and _)
  - Input validation (max 200 chars, year range 1900-2100)
  - Rate limiting (30 req/min per IP)
  - Pagination limited to 100 results/page
  - XSS protection (htmlspecialchars on output)

Add comprehensive test suite
- Create apps/public/tests/ with proper structure
  - tests/Integration/SearchTest.php - 12 search scenarios
  - tests/Security/SecurityTest.php - vulnerability testing
  - tests/Unit/RateLimitTest.php - rate limit behavior
- Create database/fixtures/CreateTestDatabase.php
- Add apps/public/run-tests.php test runner
- All tests passing (4/4 suites)

Update deployment configuration
- Rename justfile 'sync' recipe to 'deploy'
- Create deploy group with separate deploy-public and deploy-admin
- Add test-deploy recipe for test database
- Exclude *.db, tests/, cache/, *.md from production deploy
- Deploy shared/ to both public and admin locations

Stats: +4482 insertions, -654 deletions across 72 files
2026-02-02 18:53:58 +01:00
Théophile Gervreau-Mercier
95f52d549e Add comprehensive thesis management system with database migration
This commit introduces a complete thesis management interface and migrates
the system from YAML-based storage to SQLite:

Core Changes:
- Add Database.php helper class with PDO connection and entity management
- Add list.php for viewing all theses with filtering and sorting
- Add edit.php for modifying existing thesis records
- Add import.php for migrating legacy YAML data to SQLite
- Add justfile with development tasks (serve, init-test-db, etc.)

Documentation:
- Add MIGRATION.md with complete migration guide and architecture docs
- Update README.md with database setup and Just recipe instructions
- Update .gitignore to exclude test databases and error logs

Modified Forms:
- Enhanced formulaire.php with transaction-based SQLite processing
- Updated index.php with database-driven form options
- Improved thanks.php to read from database views

The new architecture provides:
- Normalized database schema (19 tables, 2 views)
- Transaction safety and referential integrity
- CRUD operations for thesis management
- Filtering by year, orientation, AP program, publication status
- Secure file handling with metadata tracking

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-28 10:08:50 +01:00
Théophile Gervreau-Mercier
99ccd60f90 Add SQLite database schema and documentation
Added complete database schema for Post-ERG thesis archive:
- schema.sql with full relational database structure
- README.md with schema documentation and usage examples
- SETUP.md with comprehensive setup and maintenance guide
- posterg_fiche-technique.md with technical specifications
- Database_TFE_test.csv and .ods with example data

Database features:
- Normalized relational schema (3NF)
- Support for multiple authors, supervisors, languages, formats, keywords
- Publication workflow (submission → defense → jury review → publication)
- Access control (Libre/Interne/Interdit)
- File attachments tracking
- Predefined reference tables for orientations, AP programs, finalities
- Views for simplified querying
- Automatic timestamps and cascade deletes
2026-01-27 15:37:55 +01:00
Théophile Gervreau-Mercier
0d3fc3ab9a Added justfile recipe file and the .gitignore 2026-01-27 14:58:00 +01:00
Théophile Gervreau-Mercier
14c82cfeed Mise à jours et création de READMEs dédier. 2026-01-26 15:58:24 +01:00
Théophile Gervreau-Mercier
2d343eee06 Organize into monorepo structure with resolved conflicts 2026-01-26 15:45:03 +01:00
Théophile Gervreau-Mercier
37ec8aa5c1 Prepare formulaire branch for merge 2026-01-26 15:45:03 +01:00
Théophile Gervreau-Mercier
0697753dd3 Move formulaire files to formulaire/ 2026-01-26 15:24:01 +01:00
Pontoporeia
567f4aaafb cleanup 2024-04-18 18:18:56 +02:00
Pontoporeia
19e9dc805b ajustement .gitignore 2023-05-12 12:05:56 +02:00
Pontoporeia
787f62a9e2 suppression du contenus de vendor et le fichier compose.lock 2023-05-12 10:38:54 +02:00
Pontoporeia
aa5d3a1610 nettoyage .gitignore 2023-05-12 10:37:02 +02:00
Pontoporeia
d0fb81d9b2 update des codeblock en shell pour le syntax highlighting 2023-05-12 10:26:25 +02:00
Pontoporeia
b7109290e0 ajout d'un contenus du README.md 2023-05-12 10:25:13 +02:00
Pontoporeia
393fabb345 maj du .gitignore 2023-05-12 10:06:13 +02:00
Pontoporeia
6f63b2efa3 ajout du .gitignore 2023-05-12 09:39:54 +02:00
Pontoporeia
3ee32e17fa update du projet, xml collection enlevé et méthode fait maison ajouter 2023-05-12 09:38:08 +02:00
Pontoporeia
9414966b24 ajustement formulaire 2023-05-12 09:31:41 +02:00
Pontoporeia
4a1e4b696e rewrite v1.0 2023-05-02 20:17:58 +02:00
Pontoporeia
763ad7d722 rewrite v0.8 2023-05-02 12:15:28 +02:00
Pontoporeia
9bf4593ae5 rebuild v0.5 2023-05-02 11:59:29 +02:00
Pontoporeia
ead6bc6d8e rebuild v0.1 2023-05-02 11:36:50 +02:00
Pontoporeia
f3dcfbf6ff Initial commit 2023-05-02 09:26:29 +00:00
Olivia Marly
85a81079c1 Merge branch 'master' of codeberg.org:memoireERG/posterg 2022-12-14 18:47:45 +01:00
Olivia Marly
7e6872126c creation formulaire + typo + style.css 2022-12-14 18:47:03 +01:00
Pontoporeia
50d51d4d04 changement des pages dans custom en xml 2022-12-14 18:07:05 +01:00
Pontoporeia
63de7d525f changement des pages de base et test sur le css 2022-12-14 15:08:53 +01:00
Pontoporeia
76fc408a9a changment de nom 2022-12-14 14:55:44 +01:00
Pontoporeia
6cdc65a63b ajout de la description du projet 2022-12-10 16:09:05 +01:00
Pontoporeia
75885b2074 changed README 2022-12-10 14:34:09 +01:00
Pontoporeia
ba6ee35e31 push initial du projet par Stéphane 2022-12-10 14:32:31 +01:00