feat(admin): add option to restrict document creation to admins only

Add new configuration option ACKIFY_ONLY_ADMIN_CAN_CREATE (default: false) to control who can create documents.

Backend changes:
- Add OnlyAdminCanCreate config field to AppConfig
- Implement authorization checks in document handlers
- Protect POST /documents and GET /documents/find-or-create endpoints
- Add unit tests for admin-only document creation (4 tests)

Frontend changes:
- Inject ACKIFY_ONLY_ADMIN_CAN_CREATE to window object
- Hide DocumentForm component for non-admin users when enabled
- Add i18n translations (en, fr, es, de, it)
- Display warning message for non-admin users

Documentation:
- Update .env.example files with new variable
- Update configuration docs (en/fr)
- Update install script to prompt for restriction option
- Update install/README.md

When enabled, only users listed in ACKIFY_ADMIN_EMAILS can create new documents. Both direct creation and find-or-create endpoints are protected.
This commit is contained in:
Benjamin
2025-11-06 16:08:03 +01:00
parent a5c376bae5
commit aa5fee90f6
19 changed files with 297 additions and 16 deletions
+3
View File
@@ -65,5 +65,8 @@ ACKIFY_ED25519_PRIVATE_KEY=your_base64_encoded_ed25519_private_key
# Admin Configuration
# ACKIFY_ADMIN_EMAILS=admin@your-domain.com,admin2@your-domain.com
# Document Creation Restriction
# ACKIFY_ONLY_ADMIN_CAN_CREATE=false
# Server Configuration
ACKIFY_LISTEN_ADDR=:8080