Commit Graph

79 Commits

Author SHA1 Message Date
Benjamin
77018a975d feat: improve build stage 2025-10-26 22:44:30 +01:00
Benjamin
714f122cfa fix: missing database integration test 2025-10-26 21:52:32 +01:00
Benjamin
c5e41e9e93 fix: split unit and integration coverage 2025-10-26 18:47:54 +01:00
Benjamin
ee02df0287 fix: use random hex for test database names to prevent collisions
- Replace nanosecond+pid with crypto/rand generated hex (16 chars)
- Fixes race condition where parallel tests starting at same nanosecond
  would share the same database name
- Ensures true isolation even with hundreds of concurrent tests
- Resolves duplicate key constraint violations in CI (perf-doc, test-doc, etc.)
2025-10-26 16:21:43 +01:00
Benjamin
8ca23ce736 fix: ensure migrations directory is found in CI tests
- Fix migration path lookup to check both './migrations' and './backend/migrations'
- Remove hardcoded test schema in admin handler tests
- Use database.SetupTestDB which applies all migrations automatically
- Ensures test schema matches production schema with all columns (deleted_at, doc_checksum, etc.)
- Fixes test failures in CI where admin handler tests returned empty responses
2025-10-26 13:57:06 +01:00
Benjamin
2410653f63 fix: integrations tests concurency + missing column due a hardcoded database struct (removed) 2025-10-26 13:37:40 +01:00
Benjamin
c738763ac3 fix: integrations tests concurency 2025-10-26 11:37:41 +01:00
Benjamin
7291c1083b fix: makefile to make coverage-all on 2 stage unit and then integration 2025-10-26 02:45:53 +02:00
Benjamin
68426bc882 feat: add PKCE support to OAuth2 flow for enhanced security
- Implement PKCE (Proof Key for Code Exchange) with S256 method
- Add crypto/pkce module with code verifier and challenge generation
- Modify OAuth flow to include code_challenge in authorization requests
- Update HandleCallback to validate code_verifier during token exchange
- Extend session lifetime from 7 to 30 days
- Add comprehensive unit tests for PKCE functions
- Maintain backward compatibility with fallback for non-PKCE sessions
- Add detailed logging for OAuth flow with PKCE tracking

PKCE enhances security by preventing authorization code interception
attacks, as recommended by OAuth 2.1 and OIDC standards.

feat: add encrypted refresh token storage with automatic cleanup

- Add oauth_sessions table for storing encrypted refresh tokens
- Implement AES-256-GCM encryption for refresh tokens using cookie secret
- Create OAuth session repository with full CRUD operations
- Add SessionWorker for automatic cleanup of expired sessions
- Configure cleanup to run every 24h for sessions older than 37 days
- Modify OAuth flow to store refresh tokens after successful authentication
- Track client IP and user agent for session security validation
- Link OAuth sessions to user sessions via session ID
- Add comprehensive encryption tests with security validations
- Integrate SessionWorker into server lifecycle with graceful shutdown

This enables persistent OAuth sessions with secure token storage,
reducing the need for frequent re-authentication from 7 to 30 days.
2025-10-26 02:32:10 +02:00
Benjamin
e95185f9c7 feat: migrate to Vue.js SPA with API-first architecture
Major refactoring to modernize the application architecture:

Backend changes:
- Restructure API with v1 versioning and modular handlers
- Add comprehensive OpenAPI specification
- Implement RESTful endpoints for documents, signatures, admin
- Add checksum verification system for document integrity
- Add server-side runtime injection of ACKIFY_BASE_URL and meta tags
- Generate dynamic Open Graph/Twitter Card meta tags for unfurling
- Remove legacy HTML template handlers
- Isolate backend source on dedicated folder
- Improve tests suite

Frontend changes:
- Migrate from Go templates to Vue.js 3 SPA with TypeScript
- Add Tailwind CSS with shadcn/vue components
- Implement i18n support (fr, en, es, de, it)
- Add admin dashboard for document and signer management
- Add signature tracking with file checksum verification
- Add embed page with sign button linking to main app
- Implement dark mode and accessibility features
- Auto load file to compute checksum

Infrastructure:
- Update Dockerfile for SPA build process
- Simplify deployment with embedded frontend assets
- Add migration for checksum_verifications table

This enables better UX, proper link previews on social platforms,
and provides a foundation for future enhancements.
2025-10-26 02:32:10 +02:00
Benjamin Touchard
e22fe5d9ea Create FUNDING.yml
Add Patreon username
2025-10-15 14:05:50 +02:00
Benjamin
4ac19a7fde docs: update README(_FR).md and CHANGELOG.md v1.1.3 2025-10-08 15:28:55 +02:00
Benjamin
58382309bb fix: Add missing files 2025-10-08 15:08:18 +02:00
Benjamin
d18f401797 feat: add document metadata management system
- Add documents with metadata (title, URL, checksum, description)
- Add metadata UI section in document details
- Replace JavaScript alerts/confirms with modern modal dialogs
- Make email language dynamic based on user's interface language
2025-10-08 14:57:57 +02:00
Benjamin
6e12fb69ed feat: add email reminder system for pending signers
Enable admins to send reminder emails to expected signers who haven't signed yet.
This addresses the need to follow up with pending signers without manual tracking.

- Add reminder_logs table to track all email sends (success and failures)
- Implement ReminderService with SMTP integration
- Extend admin dashboard with reminder stats and send interface
- Support bulk send (all pending) or selective send (manual selection)
- Track reminder count and last sent date per signer
- Change terminology from "signature" to "lecture/confirmation de lecture" across all templates and emails
2025-10-08 00:57:04 +02:00
Benjamin
af3ab1f54a feat: improved UX navigation and admin dashboard
- Added a unified horizontal navigation menu in the header
- Redesigned the user/logout button into a single element
- Reversed priority for extracting OIDC names (name > preferred_username)
- Admin: display documents with/without expected signatures
- Admin: detailed badges “X signatures (+Y) out of Z”
- Admin: modal for adding expected signers
- Admin: display additional signatures in stats
- Simplification of expected signers table display
- Validation pattern for document creation
- Removal of redundant links in templates
2025-10-06 23:38:23 +02:00
Benjamin
5e74921ee7 feat: admin dashboard document request signatures
- New, clearer dashboard showing the status of each document
- The administrator can create a list of expected signatures for a given document.
- The administrator can manage the list of users who must confirm that they have read the document
2025-10-06 23:34:01 +02:00
Benjamin
54d6de8090 docs: update README with SMTP email service configuration
Add SMTP configuration section to both English and French README files:
- Optional email notifications setup with ACKIFY_MAIL_* variables
- SMTP configuration examples for development and production
- Architecture diagram updated with email/ infrastructure component
- Technology stack updated to include SMTP service
2025-10-06 14:48:03 +02:00
Benjamin
2c24c3f2f6 feat: add SMTP email service with signature reminders
Add configurable SMTP service for sending signature reminder emails.

Features:
- Configurable via ACKIFY_MAIL_* environment variables
- Multilingual templates (en/fr) with HTML + text versions
- Template rendering with automatic variable injection
- Graceful degradation when SMTP not configured
- TLS/STARTTLS support with configurable timeout
- MailHog integration for local testing
2025-10-06 14:07:09 +02:00
Benjamin
0015af12e1 feat: add silent OAuth login with auto-authentication
- Add ACKIFY_OAUTH_AUTO_LOGIN config flag (default: false)
- Implement /api/auth/check endpoint for session validation
- Add silent login flow with prompt=none OAuth parameter
- Implement localStorage-based retry prevention (5min cooldown)
- Add comprehensive OAuth flow debugging logs
- Handle OAuth errors gracefully (login_required, interaction_required)
- Update templates with silent login JavaScript
- Add login button in header when not authenticated
- Fix /health endpoint documentation (remove /healthz alias)
- Extend tests to include autoLogin parameter
2025-10-06 13:13:17 +02:00
Benjamin
b5b6ddaaf7 set changelog for tracking 2025-10-06 13:02:13 +02:00
Benjamin
296010c0aa feat: add SSO provider logout support
When users click logout, they are now redirected to the SSO provider's
logout endpoint to ensure complete session termination. This prevents
users from remaining logged in at the provider level after logging out
of the application.

Changes:
- Add LogoutURL configuration for OAuth providers (Google, GitHub, GitLab)
- Implement GetLogoutURL method with post-logout redirect parameter
- Update HandleLogout to redirect to SSO logout when configured
- Add ACKIFY_OAUTH_LOGOUT_URL environment variable for custom providers
- Add tests for both local and SSO logout scenarios
v1.1.2
2025-10-03 15:47:19 +02:00
Benjamin
2583482198 fix: isolate blockchain chains per document
Each document now maintains its own independent blockchain chain
with its own genesis signature. GetLastSignature now filters by
doc_id to prevent cross-document chain corruption.

Changes:
- Add docID parameter to GetLastSignature interface and implementation
- Update SQL query to filter by document ID
- Add comprehensive test for multi-document blockchain isolation
- Update all test mocks and integration tests
2025-10-03 15:47:09 +02:00
Benjamin
0ce076bd3a refactor: separate template variables from locale strings
Move all template variables out of locale JSON files into separate keys.
Update templates to concatenate locale strings with dynamic values.
Replace inline conditionals with proper locale key lookups for pluralization.
v1.1.1
2025-10-02 22:34:36 +02:00
Benjamin
06e4b33167 fix: properly handle NULL UserName in database operations
Add scanSignature helper to convert sql.NullString to string type.
Update Create method to insert NULL for empty UserName values.
Fix integration tests to work with string type instead of pointer.
2025-10-02 21:03:00 +02:00
Benjamin
d6dd3625a9 fix: ensure blockchain hash determinism by refactoring UserName to string
Changed UserName field from *string to string to fix blockchain integrity
validation issues. The pointer was causing non-deterministic hash computation
due to memory address comparison instead of value comparison.

This change:
- Fixes blockchain validation for signatures with UserName
- Simplifies code by removing pointer dereferencing logic
- Maintains backward compatibility (NULL DB values map to empty string)
- Updates i18n templates to display values directly
2025-10-02 18:22:40 +02:00
Benjamin
6a292f7617 docs: use correct syntax to generate private key ED25519 2025-10-01 18:19:27 +02:00
Benjamin
378afc43a2 docs: update docker-compose.yml example file to reflect needed custom oidc provider configuration 2025-10-01 14:05:08 +02:00
Benjamin
48a06f8aa2 fix: download tailwind cli corresponding to arch v1.1.0 2025-10-01 00:58:11 +02:00
Benjamin
00250e5f0b fix: format lang.go 2025-10-01 00:38:18 +02:00
Benjamin
9c53a8bf2b feat: implement complete i18n support with French and English
Add comprehensive internationalization support:
- Browser language detection via Accept-Language header
- Cookie-based language preference persistence (1 year)
- Language switcher with flag emojis (🇫🇷 🇬🇧)
- 71 translation keys covering all UI elements
- Context-based translation injection via middleware

Replace Tailwind CDN with production build:
- Tailwind CLI v3.4.16 for CSS compilation
- Minified CSS output (5.9KB from several MB)
- Docker build integration
- Custom color palette configuration

Update all templates with i18n support:
- Main pages: home, sign, signatures, error
- Admin dashboard and document details
- Embed iframe widget (English only for international use)
- Language switcher preserves current page URL

Technical implementation:
- golang.org/x/text for language matching
- Middleware pattern for consistent i18n injection
- Fallback chain: Cookie → Accept-Language → English
- Separate translation files (locales/fr.json, locales/en.json)
2025-10-01 00:13:40 +02:00
Benjamin
6ff6966193 refactor: implement config injection pattern and enhance admin access control
- Load configuration once in main.go and inject through dependencies
- Remove duplicate config.Load() calls in admin routes and server init
- Add AdminEmails field to AppConfig with lowercase normalization
- Implement HTML error pages for 403 Forbidden responses
- Add comprehensive debug logging for admin access verification
- Improve template conditional formatting for readability
- Add test coverage for admin email parsing (6 test cases)
2025-09-30 22:37:51 +02:00
Benjamin
8d3b7ba927 feat: improved the logging system to enable troubleshooting of OAuth2 errors:
- Added structured logs in HandleError() for each error type in middleware
 - Explicit log of the OAuth callback error before handling

feat: add configurable log level via ACKIFY_LOG_LEVEL
 - Add ParseLevel function to logger package
 - Extend config structure with LoggerConfig
 - Apply log level during server initialization
 - Update documentation and .env.example
2025-09-30 15:38:07 +02:00
Benjamin
dbe43a4ff8 doc: update readme 2025-09-28 21:47:27 +02:00
Benjamin
1ae8287ca5 fix: memory leak or deferrer errors on tests files 2025-09-28 21:12:09 +02:00
Benjamin
273c8adb7c doc: add ackify.eu website links 2025-09-27 23:07:56 +02:00
Benjamin
3aaf1b25f8 docs: migrate to AGPL-3.0-or-later and add COPYRIGHT
- Replace SSPL with GNU AGPLv3 (LICENSE)
- Add COPYRIGHT with attribution
- Update Dockerfile label, README(s), BUILD.md
- Add SPDX headers across repo

refacto: remove redundant descriptive comments; keep only meaningful rationales
- Convert doc-comments to GoDoc style without colons
- Keep only security/algorithm rationales (CSRF state, CSP, chain hash, Bresenham)

tests: harden OAuth handlers tests (state missing/invalid) and fix fakes
- Add VerifyState token checks; ensure CreateAuthURL used
- Clean noisy comments in tests

docs: align docker-compose and scripts headers
2025-09-27 17:39:17 +02:00
Benjamin
4b11f5f638 tests: add Docker smoke test script for local e2e validation 2025-09-27 17:37:56 +02:00
Benjamin
06fb2d5b89 docs: standardize health endpoint; document admin ACL and routes; add staticcheck guidance and target 2025-09-26 23:32:20 +02:00
Benjamin
5e41f14f94 refactor: reuse server DB; add request logging; tighten CSP with frame-ancestors and embed override 2025-09-26 23:32:20 +02:00
Benjamin
cf2a943ea6 feat: oauth persist and verify state token via session to prevent CSRF 2025-09-26 23:32:20 +02:00
Benjamin
da64683431 feat: validation enforce strict patterns for doc and user query parameters 2025-09-26 23:32:20 +02:00
Benjamin
ff657e6d0d ci: fix docker-test service; skip outdated generate-mocks target 2025-09-26 23:32:20 +02:00
Benjamin
8bda0ae1b9 ci: use -tags=integration to match build tags 2025-09-26 23:32:20 +02:00
Benjamin
8d6f71d69d fix: chain update prev_hash via UPDATE during chain rebuild (no INSERT) 2025-09-26 23:32:20 +02:00
Benjamin
84bce9af0b logging: remove private key print; downgrade OAuth PII logs to debug 2025-09-26 23:32:20 +02:00
Benjamin
ef49dca8cd feat: http add /healthz alias; ignore local .gocache 2025-09-26 23:32:19 +02:00
Benjamin
76c2e8de4e feat: enhance admin dashboard with chain integrity verification
- Add chain integrity verification system for document signatures
- Implement VerifyDocumentChainIntegrity method in AdminRepository
- Add ChainIntegrityResult struct to track validation status
- Display chain integrity status in admin document details page
- Add API endpoint for programmatic chain integrity checks
- Add admin access link in main interface for authorized users
- Update templates to show integrity verification results
- Add admin configuration to docker-compose environment
2025-09-26 21:27:17 +02:00
Benjamin
53aa233f66 feat: add admin dashboard with document and signature management
- Admin middleware with ACKIFY_ADMIN_EMAILS environment variable authentication
- Dashboard view listing all documents with signature counts (/admin)
- Document details view showing signataires and metadata (/admin/docs/{docID})
- Read-only admin repository with dedicated database connection
- Responsive UI templates consistent with existing design
- Secure route protection and proper error handling

Configuration: Set ACKIFY_ADMIN_EMAILS="email1@domain.com,email2@domain.com"
2025-09-23 23:03:08 +02:00
Benjamin
dd9834792f build: clean docker file 2025-09-23 22:46:21 +02:00