Commit Graph
639 Commits
Author SHA1 Message Date
Jeppe Bundgaard 2e88ed7bbd Add binding for acme-io.json in Traefik config 2026-02-24 00:28:17 +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 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
Jeppe Bundgaard e6358d09fc Ensure isWashCertificate check is case-insensitive in attachment.php 2026-02-16 15:32:37 +01:00
Jeppe Bundgaard 1791a62992 Remove port from file download URLs in attachment_store.php and upload_store.php 2026-02-16 15:10:38 +01:00
Jeppe Bundgaard 0c411fa3b8 Add deprecated /tmp-send-email route with welcome email functionality
- Introduce a temporary route to send deprecated responses for email testing.
- Use `sendWelcomeEmailToCustomer` from the `email` class to implement email-sending logic.
2026-02-16 14:57:47 +01:00
Jeppe Bundgaard 4248de1d7d Add password reset link generation and welcome email functionality
- Introduce `generatePasswordResetLink` method in `users_o` for creating secure password reset links.
- Add `sendWelcomeEmailToCustomer` method to `email` class with support for attachments.
- Update `authRoute.php` to send welcome emails when creating new customers.
- Extend `sendEmail` to handle optional attachments and references.
- Disable PHP entrypoint in Dockerfile for improved flexibility.
2026-02-16 14:55:01 +01:00
Jeppe Bundgaard 8c8de541be - Update Nginx logging with structured JSON and standard combined format for Elastic integration.
- Add new upstream PHP-FPM servers to Nginx configuration for enhanced load balancing.
- Introduce Elastic APM PHP agent in `php.ini` and update Dockerfile for better dependency management.
- Secure Kibana and Elasticsearch connections in Metricbeat/Filebeat configurations with credentials.
- Remove unused PHP dependencies from `composer.json` and `composer.lock`.
2026-02-16 10:58:50 +01:00
Jeppe Bundgaard 8d8137852f Adjust Monday message time check and add deprecated route with CSV export functionality
- Update the Monday message check to start at 07:00 instead of 06:00.
- Add `/tmp-washes-in-time` route to generate and download a CSV file of washes within a specific time range.
- Mark `/tmp-washes-in-time` route as deprecated.
2026-02-16 09:25:11 +01:00
Jeppe Bundgaard 081d8ad284 Add Dockerfile and entrypoint optimizations, Composer auto-install, and dependency updates
- Use `__DIR__` for `vendor/autoload.php` in PHP autoload path.
- Add Composer dependency auto-installation at container startup with `docker-entrypoint.sh`.
- Extend Docker image to include `libssl-dev` and `ca-certificates` for TLS support.
- Enable dynamic installation of application dependencies during runtime via entrypoint.
- Update Composer dependencies, including AWS SDK, Guzzle, and OpenTelemetry libraries.
2026-02-13 22:21:46 +01:00
Jeppe Bundgaard aae244887f Extend CORS headers to include X-Customer-Number and add customer context in subuser grants. 2026-02-12 18:12:29 +01:00
Jeppe Bundgaard 05a4943162 Add /subusers/me route for public registration and extend OpenAPI schema
- Add `/subusers/me` as a public registration endpoint, including CVR validation, phone lookup, and optional SMS setup link generation.
- Extend OpenAPI specification with `SubuserSelf` and `SubuserGrantSummary` schemas for returning authenticated subuser profiles and grants.
2026-02-12 16:58:41 +01:00
Jeppe Bundgaard 17701cae69 Refactor subusersRoute to implement dynamic permission handling and effective customer context
- Add `allowOwnOrDepartmentAccess` for scoped permission checks across subuser routes.
- Introduce effective customer resolution using `resolveEffectiveCustomerNumber`.
- Enforce subuser-specific permissions with dynamic grants (`list_own_subuser_grants`, `add_own_subusers`, etc.).
- Update error handling to validate customer context and ensure node-based permission checks.
- Add localized descriptions for new and existing permission nodes.
2026-02-12 16:52:40 +01:00
Jeppe Bundgaard 78a0e9869e Refactor ordersRoute to include targetCustomerNumber in permission checks
- Use `resolveEffectiveCustomerNumber` for determining customer context.
- Adjust own/department access logic and remove unnecessary casting for `customer_id`.
2026-02-12 16:39:49 +01:00
Jeppe Bundgaard 6302fd25df Extend subuser permission system and refactor route permission handling
- Update `subusersRoute` to support subuser authentication and permission checks dynamically.
- Add new permission nodes (`SELFSERVE_LIST`, `SELFSERVE_EDIT`, `SELFSERVE_DELETE`) in `subusers_permission_node_key`.
- Fix typos in vehicle permission constants and ensure proper resolution.
- Enhance `vehiclesRoute` with effective customer context and scoped permission checks.
- Localize new permission nodes with descriptions in Danish.
2026-02-12 16:26:29 +01:00
Jeppe Bundgaard 19139b08cb Extend authentication to handle subuser tokens with customer number resolution 2026-02-12 16:17:32 +01:00
Jeppe Bundgaard 16094575a7 Refactor ordersRoute, vehiclesRoute, and related routes for subuser permission handling
- Integrate `subusers_permission_node_key` for dynamic subuser-specific permission checks.
- Refactor authentication and permission logic to streamline checks for own vs. department-level access.
- Simplify error handling and enforce scoped permissions for vehicles, orders, and their attachments.
- Localize permission labels and descriptions to Danish for relevant modules.
2026-02-12 15:52:37 +01:00
Jeppe Bundgaard f265a83034 Refactor route_t and orderBookingRoute to simplify permission handling
- Add reusable helpers: `isOwnCustomerContext`, `resolveEffectiveCustomerNumber`, and `allowOwnOrDepartmentAccess` in `route_t` for streamlined permission checks.
- Replace inlined permission logic in `orderBookingRoute` with common helpers for creating, viewing, editing, and deleting bookings.
- Localize permission names, descriptions, and labels to Danish across relevant modules.
- Improve error handling and simplify context resolution for subuser and department-level permissions.
2026-02-12 15:43:02 +01:00
Jeppe Bundgaard cd894b4e3b Refactor orderBookingRoute to integrate subuser-specific permission checks
- Add dynamic authentication and subuser permission handling using `subusers_permission_node_key`.
- Refactor route-level permission logic for creating, viewing, editing, and deleting bookings to respect subuser context.
- Ensure proper error handling for unauthorized access and enforce departmental scope for admin-level actions.
2026-02-12 15:37:03 +01:00
Jeppe Bundgaard 497ef1496b Add subuser permission evaluation system and extend subuser-related route handling
- Introduce `hasPermission` method in `subusers_o` for permission checks tied to customer context.
- Update `/subusers/me` route to return subuser grants with normalized permissions and metadata.
- Add `get_subuser_customer_number_target` in `authentication` to resolve customer context from request headers.
- Refactor route-level permission checks to handle subuser grants dynamically.
- Introduce CLI test scripts for subuser grants and permission node mappings.
- Add test coverage for subuser grants and permission nodes in new test classes.
2026-02-12 15:29:43 +01:00
Jeppe Bundgaard 6375bc7f12 Add explicit fail condition for subuser node key in route permissions
- Ensure permissions pass only if an explicit subuser node key is granted.
- Prevent fallback to classic user permissions in this authentication branch.
2026-02-12 14:28:36 +01:00
Jeppe Bundgaard f2244f5d0d Initialize permission node containers and handle uninitialized properties in subuser_user_grant to ensure proper grant resolution logic. 2026-02-12 14:08:01 +01:00
Jeppe Bundgaard 953067cba5 Extend subuser session handling and refactor permissions in order booking routes
- Add token creation for subusers in `subusers_o` during session generation.
- Refactor `orderBookingRoute` to use dynamic subuser permission definitions with `subusers_permission_node_key`.
2026-02-12 14:01:05 +01:00
Jeppe Bundgaard d26b94de3b Integrate subuser permission node system and refactor route-level permissions
- Add `permission_node` DTO to link classic permissions with subuser-specific nodes.
- Extend `authentication` to support subuser resolution via tokens.
- Introduce route traits for permission evaluation with subuser context.
- Update `requirePermission` and `hasPermission` to handle subuser grants dynamically.
- Implement fallback mechanisms for customer number context in subuser permissions.
2026-02-12 13:54:28 +01:00
Jeppe Bundgaard 2159cd293c Extend type property in tokens_o to support AUTH_TOKEN_SUBUSER 2026-02-12 13:40:19 +01:00