Commit Graph
826 Commits
Author SHA1 Message Date
Jeppe Bundgaard 817fcb974c Add Redis caching for object properties
- Added a private `getCacheKey()` method for consistent Redis key generation.
- Integrated Redis caching in `get`, `set`, and `delete` methods to improve performance.
- Ensured JSON values are correctly serialized/deserialized with caching.
- Implemented cache expiration and invalidation logic for updates and deletions.
2026-02-24 12:51:56 +01:00
Jeppe Bundgaard 79d0b2f270 Add Redis caching methods for customer-user mappings
- Introduced methods `cache_customer_number_from_user_id`, `get_customer_number_from_user_id`, and `clear_customer_number_from_user_id` to the `Redis` class.
- Updated the `Redis_i` interface to define these new methods.
- Enhances customer-user mapping logic by integrating Redis for efficient caching and retrieval.
2026-02-24 12:44:57 +01:00
Jeppe Bundgaard e143f084e4 Remove language pack logic and introduce Redis caching for customer-user mapping.
- Removed all language pack-related files, traits, and classes.
- Enhanced `users_o.php` with Redis caching for mapping `customer_number` to `user_id` and vice versa.
- Added Redis checks and caching for improved performance in user retrieval methods.
2026-02-24 12:44:43 +01:00
Jeppe Bundgaard f1c0ea2228 Remove language pack management and associated logic; add detailed logging for backups and cron processes. 2026-02-24 12:36:41 +01:00
Jeppe Bundgaard 84020bd051 Simplify customer authentication by removing default password logic and enforcing stricter checks for missing passwords. 2026-02-24 12:36:22 +01:00
Jeppe Bundgaard 9920f1dd27 Refactor token generation to use create_token_by_user_id in customer authentication flow 2026-02-24 11:57:44 +01:00
Jeppe Bundgaard 1368bfc7b5 Update .gitignore to exclude PHP logs directory 2026-02-24 11:46:26 +01:00
Jeppe Bundgaard a49b3a2d01 Add unit tests for authentication and WebAuthn functionality
- Introduced `CreateTokenUserNotFoundTest.php` to validate `create_token` behavior when users are missing.
- Added `WebAuthnLogicCheck.php` to test deserialization handling in `webauthn.php`.
- Created `WebAuthnReproLogic.php` for verifying credential ID and user handle matching.
- These tests aim to enhance coverage and ensure robust handling of edge cases in authentication processes.
2026-02-24 11:46:12 +01:00
Jeppe Bundgaard 76496fc403 Add Nginx test configurations, HTTP scripts for self-serve APIs, and .env example; update .gitignore for IntelliJ files and logs.
- Introduced `PemToCoseConversionTest` for WebAuthn key testing.
- Added example Nginx config (`nginx-example.conf`) with CORS and PHP handling.
- Created HTTP test scripts for self-serve API endpoints.
- Provided `.env` example for Elastic Stack credentials.
- Updated `.gitignore` to include IntelliJ and Nginx logs.
2026-02-24 11:44:09 +01:00
Jeppe Bundgaard ba9f6b7d01 Update .gitignore to exclude IntelliJ IDEA config files, Let's Encrypt files, and log archives 2026-02-24 11:40:12 +01:00
Jeppe Bundgaard b45a990273 Add composer.phar to the repository 2026-02-24 11:40:00 +01:00
Jeppe Bundgaard 50789aca33 Enhance WebAuthn handling and error management
- Improve user verification in `authentication.php` by adding a check for user existence and throwing meaningful exceptions for missing users.
- Refactor `webauthn.php` to handle Base64URL decoding and COSE key normalization for consistent WebAuthn library compatibility.
- Extend error logging with additional context for debugging (e.g., public key hex representation).
- Add utility functions for Base64URL decoding and checking PEM/DER format.
- Update `passkeysRoute.php` to normalize public keys and handle errors gracefully during WebAuthn workflows.
2026-02-24 11:39:15 +01:00
Jeppe Bundgaard 8bccd45fc8 Update README.md with comprehensive project documentation
- Replace outdated TLS certificate setup with a detailed overview of the Copenhagen Truck Wash API.
- Add sections on architecture, stack components, local development, configuration, testing, monitoring, and API documentation.
- Include instructions for running tests, logs inspection, and utilizing tools like Traefik, Jaeger, and Portainer.
2026-02-24 11:38:55 +01:00
Jeppe Bundgaard 860b5ac6e3 Add OpenAPI v1 documentation for Bookings API
- Introduced Writerside topics for multiple endpoints in the Bookings module, including user, admin, and public time booking routes.
- Added `Bookings_OpenAPIv1.json` specification defining API paths, schemas, and security configurations.
- Included endpoint details for operations like booking retrieval, updates, deletion, syncing, and timebookings.
2026-02-24 11:38:41 +01:00
Jeppe Bundgaard d4007bd495 Merge remote-tracking branch 'origin/master' 2026-02-24 10:55:43 +01:00
Jeppe Bundgaard df3db24c49 Add Qodana configuration for PHP code analysis
- Introduce `qodana.yaml` to configure Qodana analysis in PHP projects.
- Set up basic configuration including inspection profile and linter specification.
- Prepare for future CI/CD pipeline integration with commented bootstrap and plugin sections.
2026-02-24 10:55:23 +01:00
Jeppe B 48b625a8a0 Add Qodana code quality workflow 2026-02-24 10:24:21 +01:00
Jeppe Bundgaard 81bcc4f78d Add docker-compose config for host-based Fleet Server and new /ping route
- Introduce `docker-compose.fleet-host.yml` allowing Elastic Agent to connect to a host-installed Fleet Server.
- Add `pingRoute` to provide a simple `/ping` endpoint returning "pong" with a timestamp.
2026-02-24 09:28:41 +01:00
Jeppe Bundgaard b291e959e0 Add WebAuthn integration, reCAPTCHA support, and new tests
- Integrate WebAuthn library for passkey authentication workflows, including assertion verification and improved error handling.
- Add support for reCAPTCHA token validation across multiple endpoints for enhanced security.
- Extend OpenAPI schema to document new fields and restructured payloads.
- Add unit tests for WebAuthn flows, permission initialization, and route validation to ensure robustness and accuracy.
2026-02-24 09:27:51 +01:00
Jeppe Bundgaard 2e88ed7bbd Add binding for acme-io.json in Traefik config 2026-02-24 00:28:17 +01:00
Jeppe Bundgaard 629c13499d Add CORS rule for api.truckwash.io and new preflight route
- Introduce preflight handling for `OPTIONS` method on `api.truckwash.io` with high priority routing and secure headers middleware.
- Extend CORS configuration to include `https://api.truckwash.io`.
2026-02-23 23:45:22 +01:00
Jeppe Bundgaard 356e59bd10 Improve dynamic URL generation and add localhost support for passkey challenges
- Refactor direct download URL generation to dynamically use `HTTP_HOST` and protocol.
- Add support for localhost `rpId` during WebAuthn passkey challenges.
- Extend test cases to validate `localhost` and `truckwash.io` scenarios.
- Update OpenAPI specifications to reflect new `rpId` logic and additional server configurations.
2026-02-23 23:37:15 +01:00
Jeppe Bundgaard 61db62212c Add WebAuthn passkey challenge and verification endpoints
- Introduced endpoints for WebAuthn-based authentication flow (`/auth/passkey/challenge` and `/auth/passkey/verify`).
- Added support for generating and verifying WebAuthn PublicKeyCredentialRequestOptions and challenge tokens.
- Extended routing logic to expose matched route templates for improved parameter handling.
- Updated OpenAPI specifications to document passkey challenge and verification workflows.
- Included unit tests for validating both existing and non-existing user scenarios during passkey challenges.
2026-02-23 23:03:28 +01:00
Jeppe Bundgaard 63c88a463d Refactor passkey and token processing for improved consistency and validation
- Update passkey data mapping to use associative arrays and handle JSON decoding for `transports`.
- Refactor token caching logic to validate database existence and clear stale entries.
- Improve 2FA handling by centralizing `token->type` and `user_id` processing for reuse.
2026-02-23 22:44:06 +01:00
Jeppe Bundgaard 8ae0e28162 Add sign_count and backup_state properties to passkey object initialization 2026-02-23 22:01:09 +01:00
Jeppe Bundgaard eb0f4ca38b Enhance 2FA handling and subuser session management
- Add `two_factor_enabled` property for subuser responses in routes and OpenAPI specs.
- Improve subuser session resolution by checking token `id` for validity.
- Adjust authentication flow to prevent operations on nonexistent users in 2FA logic.
- Update OpenAPI request/response schema to better represent token/session objects.
2026-02-23 21:44:11 +01:00
Jeppe Bundgaard ce889053a6 Improve subuser session handling and 2FA logic
- Add fallback logic to resolve subuser sessions via the tokens table when cache is missing or expired, with re-caching for future use.
- Refactor 2FA flow to prioritize subuser over user objects for better clarity and ensure compatibility with TOTP logic.
- Add safeguards to avoid operations on nonexistent users or subusers in 2FA and authentication flows.
2026-02-23 18:57:20 +01:00
Jeppe Bundgaard f6b526f4ef Add two-factor authentication support for users and subusers
- Extend `users_o` and `subusers_o` with `two_factor_enabled` and `two_factor_secret` properties.
- Implement methods for managing 2FA (`isTwoFactorEnabled`, `setTwoFactorSecret`, `verify_2fa_code`) in authentication logic.
- Add 2FA handling in login flows for both users and subusers, including token generation and validation.
- Introduce `totp` class for TOTP-based authentication, including QR code generation and code verification.
- Add test cases for 2FA functionality (`TwoFactorAuthTest.php`) and coverage for login scenarios with 2FA.
- Update OpenAPI specifications to include 2FA flows (`auth/2fa/setup`, `auth/2fa/enable`, `auth/2fa/verify`, `auth/2fa/disable`).
2026-02-23 17:00:18 +01:00
Jeppe Bundgaard 827fafd46b Add validation to prevent duplicate company phone numbers during customer registration 2026-02-23 16:30:51 +01:00
Jeppe Bundgaard 5a59562e35 Add Bird API integration with voice call and flash call support
- Implement Bird API client (`bird.php`) for handling HTTP requests to Bird services.
- Add routes for voice and flash call management (`birdVoiceFlashCallsRoute.php`, `birdNumbersRoute.php`).
- Introduce test cases for voice calls, flash calls, and numbers (`VoiceCallsApiTest.php`, `NumbersAndFlashCallsApiTest.php`).
- Include configuration management classes and APIs for enabling the Bird module and managing API keys (`bird_c.php`).
- Provide OpenAPI specifications for flash call endpoints (`bird-flash-calls.md`).
2026-02-19 12:19:36 +01:00
Jeppe Bundgaard 6d09e5449e Enhance MACHINE relay control logic and add emergency override functionality
- Add `forceTurnOffMachineRelay` method for superuser/emergency operations to bypass gating restrictions.
- Enforce `toggle_after = 0` to prevent auto-toggle behavior.
- Update routes to explicitly reflect relay state when modifying MACHINE relay.
- Extend Shelly device switch handling with optional `skip_toggle_after` parameter.
2026-02-19 11:37:16 +01:00
Jeppe Bundgaard aaaaedc70c Add tests for forced MACHINE relay control endpoints
- Introduce HTTP tests for `/modules/self-serve/lane/force/machine/enable` and `/disable`.
- Add `ForceMachineRelayBypassTest` to validate bypass behavior of manual gating restrictions.
2026-02-19 11:07:44 +01:00
Jeppe Bundgaard 4bdbe40329 Add superuser endpoints for forced MACHINE relay control
- Implement emergency operations to forcibly enable or disable MACHINE relays (`forceTurnOnMachineRelay`).
- Add OpenAPI specifications for `/modules/self-serve/lane/force/machine/enable` and `/modules/self-serve/lane/force/machine/disable`.
- Update route definitions and introduce validation for input parameters.
2026-02-19 10:39:43 +01:00
Jeppe Bundgaard 54160659fc Add dynamic image generation for department lanes
- Implement `/department/lanes/dynamic-image` endpoint for machine UI dynamic image rendering.
- Add OpenAPI specification for the new endpoint with query parameters for buttons, current step, and vehicle type.
- Include `DepartmentLanesImageTest` for lightweight testing of image behavior and input normalization.
- Update `departmentLanesRoute.php` with logic for parameter handling and image composition based on lane configuration.
2026-02-18 16:44:18 +01:00
Jeppe Bundgaard 73ac77a2f5 Add support for dynamic image buttons and vehicle type selection in self-serve tasks
- Extend `department_selfserve_tasks_o` with `buttons` and `dynamic_images_vehicle_type` properties.
- Add normalization/validation methods for `buttons` and `dynamic_images_vehicle_type` parameters.
- Update `departmentSelfserveTasksRoute` to handle new fields in task creation and update.
- Add OpenAPI specifications for `buttons` and `dynamic_images_vehicle_type`.
- Include comprehensive tests for button normalization and vehicle type selection.
2026-02-18 16:34:58 +01:00
Jeppe Bundgaard 28a4a9d8e6 Add StopTurnsOffRelayTest to verify machine relay behavior during STOP with self-serve enabled
- Introduce a minimal, self-contained test to ensure the relay turns off when STOP is executed.
- Enhance `selfserve_lane_command_t` to handle relay shutdown based on department configuration.
- Include `isDepartmentSelfServeEnabled` method for testing override and I/O avoidance.
2026-02-18 16:14:33 +01:00
Jeppe Bundgaard 9881e57698 Ensure proper initialization of lane status via getter methods, refactor email template structure for better MSO compatibility, and add machine_available field to guest API response. 2026-02-18 16:06:14 +01:00
Jeppe Bundgaard f292152135 Improve email templates with MSO compatibility and enhanced styling
- Refactor header and footer to support Outlook Classic (MSO) rendering.
- Adjust logo sizing, alignment, and styles for improved consistency.
- Update inline styles for better cross-platform email rendering.
2026-02-18 15:43:19 +01:00
Jeppe Bundgaard 3f512a4fa6 Refine new customer welcome email template with inline styles, improved accessibility, and MSO-specific adjustments 2026-02-18 15:42:14 +01:00
Jeppe Bundgaard c5840c0f3e Add self-serve module loading, enum test, and update email styles/text
- Add `SelfserveLaneServicesEnumTest` to validate `selfserve_lane_services` cases.
- Update `index.php` to load self-serve module interfaces, traits, classes, helpers, and configs.
- Center Truck Wash logo in email header and adjust styling.
- Localize password reset error message in `authRoute.php` with Danish text.
2026-02-18 15:35:41 +01:00
Jeppe Bundgaard 51014bf774 Add development guidelines, testing rules, and secure routes documentation
- Add `.junie/guidelines.md` with comprehensive development instructions.
- Include `.aiassistant/rules/Creating and maintaining tests.md` and `.aiassistant/rules/Creating and securing routes.md`.
- Introduce `CACHE_SELFSERVE_LANE_KEY_ALLOWED_SERVICES` for lane service validation.
- Update `selfserve_lane_relay_controller_t` to enforce service-specific permissions for machine relay.
2026-02-18 14:13:05 +01:00
Jeppe Bundgaard 008e2af09a Add support for self-serve task services and validation logic
- Introduce `services` property to `department_selfserve_tasks_o` for task-specific functionalities.
- Add service validation and normalization via `selfserve_lane_services` enum.
- Extend `departmentSelfserveTasksRoute` to handle `services` input for add/edit operations.
- Create `selfserve_lane_services` enum to define and validate service types.
2026-02-18 12:47:00 +01:00
Jeppe Bundgaard efaed8c6cc Refactor new customer email template and attachments handling
- Update welcome email template to conditionally include corporate ID.
- Remove unused base64 signature utility and clean up the email class.
- Comment out attachments array for potential future updates.
2026-02-17 12:07:03 +01:00
Jeppe Bundgaard b7648ccc2c Update new customer email template with dynamic company data and revised signature assets
- Dynamically insert company name and corporate ID in welcome message.
- Replace signature image URLs with updated assets and ensure proper loading.
- Add utility for retrieving base64-encoded signatures to enhance flexibility.
2026-02-17 12:01:10 +01:00
Jeppe Bundgaard a31187879b Refine new customer welcome email template with enhanced styles and improved HTML structure 2026-02-17 11:46:33 +01:00
Jeppe Bundgaard 3e76bdccc2 Add HTML email template for new customer welcome email and integrate into email class 2026-02-17 11:43:14 +01:00
Jeppe Bundgaard 0a582951a0 Add new HTML email template and assets for welcoming new Truckwash customers 2026-02-17 11:37:49 +01:00
Jeppe Bundgaard fc054d6226 Expand CORS allowlist in Traefik to include http://localhost:5173 for development purposes 2026-02-17 11:37:35 +01:00
Jeppe Bundgaard 4d2264e51e Expand CORS allowlist in Traefik to include additional Truckwash domains and localhost 2026-02-17 09:23:33 +01:00
Jeppe Bundgaard 241a05e498 Send additional welcome emails to info@truckwash.dk and jm@truckwash.dk when creating new customers 2026-02-16 15:44:53 +01:00