Commit Graph

68 Commits

Author SHA1 Message Date
Andras Bacsai ae33447994 feat(storage): add storage endpoints and UUID support for databases and services
- Add storage endpoints (list, create, update, delete) to DatabasesController
- Add storage endpoints (list, create, update, delete) to ServicesController
- Add UUID field and migration for local_persistent_volumes table
- Update LocalPersistentVolume model to extend BaseModel
- Support UUID-based storage identification in ApplicationsController
- Update OpenAPI documentation with new storage endpoints and schemas
- Fix application name generation to extract repo name from full git path
- Add comprehensive tests for storage API operations
2026-03-23 15:15:02 +01:00
Andras Bacsai fb76b68c08 feat(api): support comments in bulk environment variable endpoints
Add support for optional comment field on environment variables created or
updated through the bulk API endpoints. Comments are validated to a maximum
of 256 characters and are nullable. Updates preserve existing comments when
not provided in the request.
2026-03-19 22:17:55 +01:00
Andras Bacsai 8a164735cb fix(api): extract resource UUIDs from route parameters
Extract resource UUIDs from route parameters instead of request body
in ApplicationsController and ServicesController environment variable
endpoints. This prevents UUID parameters from being spoofed in the
request body.

- Replace $request->uuid with $request->route('uuid')
- Replace $request->env_uuid with $request->route('env_uuid')
- Add tests verifying route parameters are used and body UUIDs ignored
2026-03-19 21:56:58 +01:00
Andras Bacsai b9cae51c5d feat(service): add container label escape control to services API
Add `is_container_label_escape_enabled` boolean field to services API,
allowing users to control whether special characters in container labels
are escaped. Defaults to true (escaping enabled).

When disabled, users can use environment variables within labels.
Includes validation rules and comprehensive test coverage.
2026-03-13 13:32:58 +01:00
Andras Bacsai eb96c9550b fix(api): add docker_cleanup parameter to stop endpoints (#8899) 2026-03-11 10:18:22 +01:00
Andras Bacsai 11007771f0 Fix/wrong destinations api (#8646) 2026-03-05 16:32:09 +01:00
Andras Bacsai d9e39ba211 Merge remote-tracking branch 'origin/next' into env-var-descriptions 2026-02-28 00:09:54 +01:00
W8jonas 7c5a6bc96c Fix wrong destination issue on create_service 2026-02-26 23:15:18 -03:00
Andras Bacsai 95e93ad899 chore: prepare for PR 2026-02-09 14:48:16 +01:00
🏔️ Peak b87d54f9e4 feat(api): add url update support to services api (#7929) 2026-01-14 14:51:50 +01:00
peaklabs-dev ae9d0ec817 docs(api): change domains to urls 2026-01-14 14:50:48 +01:00
peaklabs-dev 33d3f196cc chore(api): improve current request error message 2026-01-14 14:42:35 +01:00
peaklabs-dev c5196e12d2 fix(api): show an error if the same 2 urls are provided 2026-01-13 20:04:44 +01:00
peaklabs-dev 0628268875 feat(api): improve service urls update
- add force_domain_override functionality and docs
- delete service on creation if there is URL conflicts as otherwise we will have stale services (we need to create the service because we need to parse it and more)
2026-01-13 19:25:58 +01:00
peaklabs-dev aed11b4d67 fix(api): one click service name and description cannot be set during creation 2026-01-13 17:26:51 +01:00
🏔️ Peak 3ff2743e01 fix(api): encoding checks (#7944) 2026-01-13 16:53:11 +01:00
peaklabs-dev 764d8861f6 feat(api): add update urls support to services api
- added update urls support to services api
- remove old stale domains update code
2026-01-12 22:39:30 +01:00
peaklabs-dev 9c0e308dd3 refactor(api): make docker_compose_raw description more clear 2026-01-11 18:27:54 +01:00
peaklabs-dev 7c7c09aa3d fix(api): create service validation and docs
- if service type and docker_compose_raw is filled show an error
- if service type is not valid show an error with all valid service types
- remove enum from service type docs as it always gets outdated
2026-01-10 22:29:11 +01:00
Muhammed Mustafa AKŞAM 9b6d1613ed fix(docs): remove incorrect uuid format in openapi spec (#7419)
Co-authored-by: 🏔️ Peak <122374094+peaklabs-dev@users.noreply.github.com>
2026-01-04 16:16:19 +01:00
claude[bot] 21a7f2f581 fix(api): add docker_cleanup parameter to stop endpoints
Add optional docker_cleanup query parameter to the stop endpoints for
Services, Applications, and Databases. This allows API users to control
whether docker cleanup (pruning networks, volumes, etc.) is performed
when stopping resources.

The parameter defaults to true for backward compatibility.

API Usage:
- Stop without docker cleanup: GET /api/v1/{resource}/{uuid}/stop?docker_cleanup=false
- Stop with docker cleanup (default): GET /api/v1/{resource}/{uuid}/stop

Fixes #7758

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

Co-authored-by: Andras Bacsai <andrasbacsai@users.noreply.github.com>
2026-01-01 12:03:13 +00:00
Andras Bacsai 87f9ce0674 Add comment field support to environment variable API endpoints
API consumers can now create and update environment variables with
an optional comment field for documentation purposes. Changes include:
- Added comment validation (string, nullable, max 256 chars) to all env endpoints
- Updated ApplicationsController create_env and update_env_by_uuid
- Updated ServicesController create_env and update_env_by_uuid
- Updated openapi.json request schemas to document the comment field

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-27 15:24:53 +01:00
Andras Bacsai 4706bc23aa Refactor: Centralize service application prerequisites
Refactors the Appwrite and Beszel service-specific application settings
to use a centralized constant-based approach, following the same pattern
as NEEDS_TO_CONNECT_TO_PREDEFINED_NETWORK.

Changes:
- Added NEEDS_TO_DISABLE_GZIP constant for services requiring gzip disabled
- Added NEEDS_TO_DISABLE_STRIPPREFIX constant for services requiring stripprefix disabled
- Created applyServiceApplicationPrerequisites() helper function in bootstrap/helpers/services.php
- Updated all service creation flows to use the centralized helper:
  * app/Livewire/Project/Resource/Create.php (web handler)
  * app/Http/Controllers/Api/ServicesController.php (API handler - BUG FIX)
  * app/Livewire/Project/New/DockerCompose.php (custom compose handler)
  * app/Http/Controllers/Api/ApplicationsController.php (API custom compose handler)
- Added comprehensive unit tests for the new helper function

Benefits:
- Single source of truth for service prerequisites
- DRY - eliminates code duplication between web and API handlers
- Fixes bug where API-created services didn't get prerequisites applied
- Easy to extend for future services (just edit the constant)
- More maintainable and testable

Related commits: 3a94f1ea1 (Beszel), 02b18c86e (Appwrite)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 16:47:09 +01:00
Andras Bacsai e5280fd3ad feat: add predefined network connection for pgAdmin and postgresus services 2025-11-28 10:29:13 +01:00
Andras Bacsai a4e4cc2c17 fix: update service creation logic to only connect pgAdmin to Docker network 2025-11-28 10:17:27 +01:00
Zach Silveira b72f93faab fix api call booleans not being used 2025-10-26 11:25:44 -04:00
Andras Bacsai fa8393184f refactor: improve validation error handling and coding standards
Changes:
1. Add explicit try-catch blocks around validateDockerComposeForInjection()
   in API endpoints to return proper 422 JSON responses with validation errors
2. Rename $service_payload to $servicePayload for PSR-12 compliance (camelCase)

API endpoints now properly handle validation failures:
- One-click service creation (line 334)
- Custom compose service creation (line 480)
- Service update endpoint (line 808)

All return consistent error format:
{
  "message": "Validation failed.",
  "errors": {
    "docker_compose_raw": "Invalid Docker Compose service name: ..."
  }
}

Livewire components already have proper exception handling via handleError().

All 60 security tests pass (176 assertions).

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-16 09:51:37 +02:00
Andras Bacsai cb1f571eb4 fix: prevent command injection in Docker Compose parsing - add pre-save validation
This commit addresses a critical security issue where malicious Docker Compose
data was being saved to the database before validation occurred.

Problem:
- Service models were saved to database first
- Validation ran afterwards during parse()
- Malicious data persisted even when validation failed
- User saw error but damage was already done

Solution:
1. Created validateDockerComposeForInjection() to validate YAML before save
2. Added pre-save validation to all Service creation/update points:
   - Livewire: DockerCompose.php, StackForm.php
   - API: ServicesController.php (create, update, one-click)
3. Validates service names and volume paths (string + array formats)
4. Blocks shell metacharacters: backticks, $(), |, ;, &, >, <, newlines

Security fixes:
- Volume source paths (string format) - validated before save
- Volume source paths (array format) - validated before save
- Service names - validated before save
- Environment variable patterns - safe ${VAR} allowed, ${VAR:-$(cmd)} blocked

Testing:
- 60 security tests pass (176 assertions)
- PreSaveValidationTest.php: 15 tests for pre-save validation
- ValidateShellSafePathTest.php: 15 tests for core validation
- VolumeSecurityTest.php: 15 tests for volume parsing
- ServiceNameSecurityTest.php: 15 tests for service names

Related commits:
- Previous: Added validation during parse() phase
- This commit: Moves validation before database save

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-16 09:51:37 +02:00
elmariss 737ec521b6 fix: missing 422 error code in openapi spec 2025-10-12 14:20:45 +02:00
Andras Bacsai 5b3b4bbc43 refactor(environment): remove 'is_build_time' attribute from environment variable handling across the application to simplify configuration 2025-09-11 16:51:56 +02:00
Andras Bacsai b1334a1bc6 feat(auth): implement comprehensive authorization checks across API controllers 2025-08-23 18:51:10 +02:00
Andras Bacsai 0e014ce213 fix(service api): separate create and update service functionalities 2025-08-17 19:45:12 +02:00
Yanluis Fermin 9b0fd2073a fix(api): update service upsert to retain name and description values if not set 2025-08-11 12:31:12 -04:00
Yanluis Fermin 4ff7ab7895 Merge branch 'next' into fix/service-update-required-params 2025-08-11 10:23:30 -04:00
🏔️ Peak 2a526c54d5 fix(docker): volumes get delete when stopping a service if Delete Unused Volumes is activated (#6317) 2025-08-04 21:15:56 +02:00
Yanluis Fermin ad8f442318 refactor(services): update validation rules to be optional 2025-07-30 15:59:35 -04:00
peaklabs-dev 2934d4a259 chore(api): update API docs 2025-05-27 15:10:20 +02:00
Dusan 94df6ca51f feat(api): Add latest query param to Service restart API (#5881) 2025-05-27 15:03:17 +02:00
Andras Bacsai eee57d4c06 fix(api): handle JSON response in service creation and update methods for improved error handling 2025-04-22 11:16:49 +02:00
Laurence 1e7b15ae77 enhance: Add missing UUID to openapi spec 2025-04-09 17:52:12 +01:00
Meghea Iulian d9be1191d6 feat(api): update OpenAPI spec for services (#5448) 2025-04-03 16:02:59 +02:00
Andras Bacsai 120facfca3 feat(api): unify service creation endpoint and enhance validation 2025-03-21 11:31:17 +01:00
Meghea Iulian d08774d083 feat(api): update Services api routes and handlers 2025-03-20 08:28:28 +02:00
Meghea Iulian d16888b707 feat(api): separate create and one-click routes
Moves previous POST /services to POST /services/one-click.
Adds new POST /services that takes a docker_compose.
2025-03-19 10:22:34 +02:00
Meghea Iulian 5a7ced9438 feat(api): add api to create custom services
Add separate API to create services with custom Docker compose instead
of oneclick services implement as a POST to /services/compose.
This is somewhat similar to /applications/dockercompose but that API is
the only one in ApplicationsController that actually works with the `Service` model.
2025-03-19 06:51:20 +02:00
Andras Bacsai 1fe4dd722b Revert "rector: arrrrr"
This reverts commit 16c0cd10d8.
2025-01-07 15:31:43 +01:00
Andras Bacsai 16c0cd10d8 rector: arrrrr 2025-01-07 14:52:08 +01:00
Andras Bacsai 9e3467578f feat: add environment_uuid support and update API documentation
- Introduced `environment_uuid` as a required field in various API endpoints and schemas.
- Updated descriptions to clarify that either `environment_name` or `environment_uuid` must be provided.
- Modified routes and controller methods to accommodate the new UUID parameter.
- Adjusted frontend components to utilize `environment_uuid` for better consistency and clarity.
- Removed deprecated fields related to environment handling.

This change enhances the API's flexibility in identifying environments, improving overall usability.
2024-12-17 13:42:16 +01:00
Andras Bacsai 2a9d499251 feat: migrate env variables to polymorphic relationship
fix: proxy status query ui
2024-12-17 10:38:42 +01:00
Andras Bacsai 4901b12279 fix: service status indicator + oauth saving 2024-12-13 12:03:10 +01:00