Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

Merge remote-tracking branch 'origin/next' into openid-auth-support

Andras Bacsaibdc7e53fac99
diff --cc app/Actions/Fortify/CreateNewUser.php
index c186c80429,44a03c17da..d437a3a176
--- a/app/Actions/Fortify/CreateNewUser.php
+++ b/app/Actions/Fortify/CreateNewUser.php
@@@ -20,9 -32,12 +32,12 @@@ class CreateNewUser implements CreatesN
public function create(array $input): User
{
$settings = instanceSettings();
- if (! $settings->is_registration_enabled) {
+ if (! $settings->isPasswordRegistrationAllowed()) {
abort(403);
}
+
+ $this->ensureRegistrationIsNotRateLimited($input);
+
Validator::make($input, [
'name' => ['required', 'string', 'max:255'],
'email' => [
diff --cc app/Http/Controllers/Api/DatabasesController.php
index 912f817286,3761effd72..1d64a7d6b7
--- a/app/Http/Controllers/Api/DatabasesController.php
+++ b/app/Http/Controllers/Api/DatabasesController.php
@@@ -2692,6 -2943,99 +2943,99 @@@ class DatabasesController extends Contr
]);
}
+ #[OA\Post(
+ summary: 'Move',
+ description: 'Move database to another project/environment. This is a purely organizational change — running containers are not affected. Note: after moving, the database will pick up shared environment variables from the new environment on the next deployment.',
+ path: '/databases/{uuid}/move',
+ operationId: 'move-database-by-uuid',
+ security: [
+ ['bearerAuth' => []],
+ ],
+ tags: ['Databases'],
+ parameters: [
+ new OA\Parameter(
+ name: 'uuid',
+ in: 'path',
+ description: 'UUID of the database.',
+ required: true,
+ schema: new OA\Schema(
+ type: 'string',
+ )
+ ),
+ ],
+ requestBody: new OA\RequestBody(
+ description: 'Target environment to move the database to.',
+ required: true,
+ content: [
+ new OA\MediaType(
+ mediaType: 'application/json',
+ schema: new OA\Schema(
+ type: 'object',
+ properties: [
+ 'environment_uuid' => ['type' => 'string', 'description' => 'UUID of the target environment.'],
+ ],
+ required: ['environment_uuid'],
+ )
+ ),
+ ]
+ ),
+ responses: [
+ new OA\Response(
+ response: 200,
+ description: 'Database moved successfully.',
+ content: [
+ new OA\MediaType(
+ mediaType: 'application/json',
+ schema: new OA\Schema(
+ type: 'object',
+ properties: [
+ 'message' => ['type' => 'string', 'example' => 'Database moved successfully.'],
+ 'uuid' => ['type' => 'string'],
+ 'project_uuid' => ['type' => 'string'],
+ 'environment_uuid' => ['type' => 'string'],
+ ]
+ )
+ ),
+ ]
+ ),
+ new OA\Response(
+ response: 401,
+ ref: '#/components/responses/401',
+ ),
+ new OA\Response(
+ response: 400,
+ ref: '#/components/responses/400',
+ ),
+ new OA\Response(
+ response: 404,
+ ref: '#/components/responses/404',
+ ),
+ new OA\Response(
+ response: 422,
+ ref: '#/components/responses/422',
+ ),
+ ]
+ )]
- public function move_by_uuid(Request $request): \Illuminate\Http\JsonResponse
++ public function move_by_uuid(Request $request): JsonResponse
+ {
+ $teamId = getTeamIdFromToken();
+ if (is_null($teamId)) {
+ return invalidTokenResponse();
+ }
+ $uuid = $request->route('uuid');
+ if (! $uuid) {
+ return response()->json(['message' => 'UUID is required.'], 400);
+ }
+ $database = queryDatabaseByUuidWithinTeam($request->uuid, $teamId);
+ if (! $database) {
+ return response()->json(['message' => 'Database not found.'], 404);
+ }
+
+ $this->authorize('update', $database);
+
+ return moveResourceToEnvironment($request, $database, 'Database', $teamId);
+ }
+
#[OA\Get(
summary: 'Start',
description: 'Start database. `Post` request is also accepted.',
diff --cc app/Http/Controllers/Api/ServicesController.php
index 6c121bcf87,aa9afe0adc..bb45b672a7
--- a/app/Http/Controllers/Api/ServicesController.php
+++ b/app/Http/Controllers/Api/ServicesController.php
@@@ -1670,6 -1869,99 +1869,99 @@@ class ServicesController extends Contro
return response()->json(['message' => 'Environment variable deleted.']);
}
+ #[OA\Post(
+ summary: 'Move',
+ description: 'Move service to another project/environment. This is a purely organizational change — running containers are not affected. Note: after moving, the service will pick up shared environment variables from the new environment on the next deployment.',
+ path: '/services/{uuid}/move',
+ operationId: 'move-service-by-uuid',
+ security: [
+ ['bearerAuth' => []],
+ ],
+ tags: ['Services'],
+ parameters: [
+ new OA\Parameter(
+ name: 'uuid',
+ in: 'path',
+ description: 'UUID of the service.',
+ required: true,
+ schema: new OA\Schema(
+ type: 'string',
+ )
+ ),
+ ],
+ requestBody: new OA\RequestBody(
+ description: 'Target environment to move the service to.',
+ required: true,
+ content: [
+ new OA\MediaType(
+ mediaType: 'application/json',
+ schema: new OA\Schema(
+ type: 'object',
+ properties: [
+ 'environment_uuid' => ['type' => 'string', 'description' => 'UUID of the target environment.'],
+ ],
+ required: ['environment_uuid'],
+ )
+ ),
+ ]
+ ),
+ responses: [
+ new OA\Response(
+ response: 200,
+ description: 'Service moved successfully.',
+ content: [
+ new OA\MediaType(
+ mediaType: 'application/json',
+ schema: new OA\Schema(
+ type: 'object',
+ properties: [
+ 'message' => ['type' => 'string', 'example' => 'Service moved successfully.'],
+ 'uuid' => ['type' => 'string'],
+ 'project_uuid' => ['type' => 'string'],
+ 'environment_uuid' => ['type' => 'string'],
+ ]
+ )
+ ),
+ ]
+ ),
+ new OA\Response(
+ response: 401,
+ ref: '#/components/responses/401',
+ ),
+ new OA\Response(
+ response: 400,
+ ref: '#/components/responses/400',
+ ),
+ new OA\Response(
+ response: 404,
+ ref: '#/components/responses/404',
+ ),
+ new OA\Response(
+ response: 422,
+ ref: '#/components/responses/422',
+ ),
+ ]
+ )]
- public function move_by_uuid(Request $request): \Illuminate\Http\JsonResponse
++ public function move_by_uuid(Request $request): JsonResponse
+ {
+ $teamId = getTeamIdFromToken();
+ if (is_null($teamId)) {
+ return invalidTokenResponse();
+ }
+ $uuid = $request->route('uuid');
+ if (! $uuid) {
+ return response()->json(['message' => 'UUID is required.'], 400);
+ }
+ $service = Service::whereRelation('environment.project.team', 'id', $teamId)->whereUuid($request->uuid)->first();
+ if (! $service) {
+ return response()->json(['message' => 'Service not found.'], 404);
+ }
+
+ $this->authorize('update', $service);
+
+ return moveResourceToEnvironment($request, $service, 'Service', $teamId);
+ }
+
#[OA\Get(
summary: 'Start',
description: 'Start service. `Post` request is also accepted.',
diff --cc app/Models/OauthSetting.php
index bc6fc06c17,e7999134a6..7765e41160
--- a/app/Models/OauthSetting.php
+++ b/app/Models/OauthSetting.php
@@@ -11,20 -11,12 +11,24 @@@ class OauthSetting extends Mode
{
use HasFactory;
- protected $fillable = ['provider', 'client_id', 'client_secret', 'redirect_uri', 'tenant', 'base_url', 'enabled'];
+ protected $fillable = ['provider', 'client_id', 'client_secret', 'redirect_uri', 'tenant', 'base_url', 'enabled', 'custom_label', 'scopes', 'allow_registration', 'auto_join_root_team', 'require_email_verified', 'use_pkce', 'clock_skew_seconds'];
+
+ protected function casts(): array
+ {
+ return [
+ 'enabled' => 'boolean',
+ 'allow_registration' => 'boolean',
+ 'auto_join_root_team' => 'boolean',
+ 'require_email_verified' => 'boolean',
+ 'use_pkce' => 'boolean',
+ 'clock_skew_seconds' => 'integer',
+ ];
+ }
+ protected $hidden = [
+ 'client_secret',
+ ];
+
protected function clientSecret(): Attribute
{
return Attribute::make(
diff --cc composer.lock
index 8c11e8759d,174a3931bd..228800c228
--- a/composer.lock
+++ b/composer.lock
@@@ -4,7 -4,7 +4,7 @@@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "115a84e56a483f0c336c220b4d0246d7",
- "content-hash": "dff5cce0f3fe7ba422d9d121cce7c082",
++ "content-hash": "0cf904aa97d276a2eb2eefc9c7bbd0f7",
"packages": [
{
"name": "aws/aws-crt-php",
diff --cc tests/Unit/DeploymentConfiguration/ApplicationConfigurationSnapshotTest.php
index 261ef94349,a00c00b4bc..168279e3f3
--- a/tests/Unit/DeploymentConfiguration/ApplicationConfigurationSnapshotTest.php
+++ b/tests/Unit/DeploymentConfiguration/ApplicationConfigurationSnapshotTest.php
@@@ -71,10 -74,198 +74,198 @@@ it('detects redeploy-only domain change
expect($diff->isChanged())->toBeTrue()
->and($diff->requiresBuild())->toBeFalse()
- ->and(collect($diff->changes())->pluck('label'))->toContain('Domains');
+ ->and($change)->not->toBeNull()
+ ->and($change['expandable'])->toBeTrue()
+ ->and($change['new_full_value'])->toBe($domains);
+ });
+
+ it('detects Docker image reference changes as redeploy-only changes', function (string $field, string $label, string $newValue) {
+ $application = snapshotTestApplication([
+ 'build_pack' => 'dockerimage',
+ 'docker_registry_image_name' => 'ghcr.io/coollabsio/shoutrrr',
+ 'docker_registry_image_tag' => '1.3.0-rc.4',
+ ]);
+ markSnapshotTestApplicationDeployed($application);
+
+ $application->update([$field => $newValue]);
+ $diff = $application->refresh()->pendingDeploymentConfigurationDiff();
+ $change = collect($diff->changes())->firstWhere('label', $label);
+
+ expect($diff->isChanged())->toBeTrue()
+ ->and($diff->requiresBuild())->toBeFalse()
+ ->and($change)->not->toBeNull()
+ ->and($change['old_display_value'])->not->toBe($change['new_display_value'])
+ ->and($change['new_display_value'])->toBe($newValue);
+ })->with([
+ 'image name' => ['docker_registry_image_name', 'Docker image', 'ghcr.io/coollabsio/coolify'],
+ 'image tag' => ['docker_registry_image_tag', 'Docker image tag or hash', '1.3.0-rc.5'],
+ ]);
+
+ it('detects deployment hook changes as redeploy-only changes', function (string $field, string $label, string $newValue) {
+ $application = snapshotTestApplication();
+ markSnapshotTestApplicationDeployed($application);
+
+ $application->update([$field => $newValue]);
+ $diff = $application->refresh()->pendingDeploymentConfigurationDiff();
+
+ expect($diff->requiresBuild())->toBeFalse()
+ ->and(collect($diff->changes())->pluck('label'))->toContain($label);
+ })->with([
+ 'pre-deployment command' => ['pre_deployment_command', 'Pre-deployment command', 'php artisan migrate --force'],
+ 'pre-deployment container' => ['pre_deployment_command_container', 'Pre-deployment command container', 'web'],
+ 'post-deployment command' => ['post_deployment_command', 'Post-deployment command', 'php artisan cache:clear'],
+ 'post-deployment container' => ['post_deployment_command_container', 'Post-deployment command container', 'worker'],
+ ]);
+
+ it('detects source integration changes as build changes', function (string $field, string $label, mixed $newValue) {
+ $application = snapshotTestApplication([
+ 'source_id' => 1,
+ 'source_type' => 'App\\Models\\GithubApp',
+ ]);
+ markSnapshotTestApplicationDeployed($application);
+
+ $application->forceFill([$field => $newValue])->save();
+ $diff = $application->refresh()->pendingDeploymentConfigurationDiff();
+
+ expect($diff->requiresBuild())->toBeTrue()
+ ->and(collect($diff->changes())->pluck('label'))->toContain($label);
+ })->with([
+ 'source ID' => ['source_id', 'Source ID', 2],
+ 'source type' => ['source_type', 'Source type', 'App\\Models\\GitlabApp'],
+ ]);
+
+ it('detects build-affecting application settings', function (string $field, string $label) {
+ $application = snapshotTestApplication();
+ $application->settings->update([$field => false]);
+ markSnapshotTestApplicationDeployed($application);
+
+ $application->settings->update([$field => true]);
+ $diff = $application->refresh()->pendingDeploymentConfigurationDiff();
+
+ expect($diff->requiresBuild())->toBeTrue()
+ ->and(collect($diff->changes())->pluck('label'))->toContain($label);
+ })->with([
+ 'static site' => ['is_static', 'Static site'],
+ 'single-page application' => ['is_spa', 'Single-page application'],
+ 'Git submodules' => ['is_git_submodules_enabled', 'Git submodules'],
+ 'Git LFS' => ['is_git_lfs_enabled', 'Git LFS'],
+ 'shallow clone' => ['is_git_shallow_clone_enabled', 'Shallow clone'],
+ 'environment variable sorting' => ['is_env_sorting_enabled', 'Sort environment variables'],
+ ]);
+
+ it('detects runtime-affecting application settings as redeploy-only changes', function (string $field, string $label, mixed $newValue) {
+ $application = snapshotTestApplication();
+ $application->settings->update([$field => is_bool($newValue) ? ! $newValue : null]);
+ markSnapshotTestApplicationDeployed($application);
+
+ $application->settings->update([$field => $newValue]);
+ $diff = $application->refresh()->pendingDeploymentConfigurationDiff();
+
+ expect($diff->requiresBuild())->toBeFalse()
+ ->and(collect($diff->changes())->pluck('label'))->toContain($label);
+ })->with([
+ 'consistent container name' => ['is_consistent_container_name_enabled', 'Consistent container name', true],
+ 'container label escaping' => ['is_container_label_escape_enabled', 'Escape container labels', false],
+ 'container labels read-only' => ['is_container_label_readonly_enabled', 'Read-only container labels', false],
+ 'log drain' => ['is_log_drain_enabled', 'Log drain', true],
+ 'Swarm worker nodes' => ['is_swarm_only_worker_nodes', 'Swarm worker nodes only', true],
+ 'stop grace period' => ['stop_grace_period', 'Stop grace period', 45],
+ 'preserve repository' => ['is_preserve_repository_enabled', 'Preserve repository', true],
+ ]);
+
+ it('classifies runtime options as redeploy-only and custom nginx configuration as build-affecting', function () {
+ $application = snapshotTestApplication();
+ markSnapshotTestApplicationDeployed($application);
+
+ $application->update(['custom_docker_run_options' => '--init']);
+
+ expect($application->refresh()->pendingDeploymentConfigurationDiff()->requiresBuild())->toBeFalse();
+
+ markSnapshotTestApplicationDeployed($application->refresh());
+ $application->update(['custom_nginx_configuration' => 'server { listen 80; }']);
+
+ expect($application->refresh()->pendingDeploymentConfigurationDiff()->requiresBuild())->toBeTrue();
+ });
+
+ it('keeps Docker run options compatible with older build-section snapshots', function () {
+ $application = snapshotTestApplication(['custom_docker_run_options' => '--init'])->refresh();
+ $previousSnapshot = $application->deploymentConfigurationSnapshot();
+ $buildItems = collect(data_get($previousSnapshot, 'sections.build.items'));
+
+ expect($buildItems->pluck('key'))->toContain('custom_docker_run_options');
+
+ data_set(
+ $previousSnapshot,
+ 'sections.build.items',
+ $buildItems->map(function (array $item): array {
+ if ($item['key'] === 'custom_docker_run_options') {
+ $item['impact'] = 'build';
+ }
+
+ return $item;
+ })->all(),
+ );
+
+ expect(app(ConfigurationDiffer::class)->diff($previousSnapshot, $application->deploymentConfigurationSnapshot())->isChanged())->toBeFalse();
+
+ $application->update(['custom_docker_run_options' => '--rm']);
+
+ expect(app(ConfigurationDiffer::class)->diff($previousSnapshot, $application->refresh()->deploymentConfigurationSnapshot())->requiresBuild())->toBeFalse();
+ });
+
+ it('does not report newly tracked settings when an older snapshot omitted their default values', function () {
+ $application = snapshotTestApplication();
+ $application->settings->update(['stop_grace_period' => DEFAULT_STOP_GRACE_PERIOD_SECONDS]);
+ $currentSnapshot = $application->deploymentConfigurationSnapshot();
+ $introducedKeys = [
+ 'is_static',
+ 'is_spa',
+ 'is_git_submodules_enabled',
+ 'is_git_lfs_enabled',
+ 'is_git_shallow_clone_enabled',
+ 'is_env_sorting_enabled',
+ 'is_consistent_container_name_enabled',
+ 'is_container_label_escape_enabled',
+ 'is_container_label_readonly_enabled',
+ 'is_log_drain_enabled',
+ 'is_swarm_only_worker_nodes',
+ 'is_preserve_repository_enabled',
+ 'stop_grace_period',
+ ];
+ $previousSnapshot = $currentSnapshot;
+
+ foreach (['build', 'runtime'] as $section) {
+ data_set(
+ $previousSnapshot,
+ "sections.{$section}.items",
+ collect(data_get($previousSnapshot, "sections.{$section}.items"))
+ ->reject(fn (array $item): bool => in_array($item['key'], $introducedKeys, true))
+ ->values()
+ ->all(),
+ );
+ }
+
+ expect(app(ConfigurationDiffer::class)->diff($previousSnapshot, $currentSnapshot)->isChanged())->toBeFalse();
+ });
+
+ it('accepts the historical environment sorting default in older snapshots', function () {
+ $application = snapshotTestApplication();
+ $application->settings->update(['is_env_sorting_enabled' => true]);
+ $currentSnapshot = $application->deploymentConfigurationSnapshot();
+ $previousSnapshot = $currentSnapshot;
+ data_set(
+ $previousSnapshot,
+ 'sections.build.items',
+ collect(data_get($previousSnapshot, 'sections.build.items'))
+ ->reject(fn (array $item): bool => $item['key'] === 'is_env_sorting_enabled')
+ ->values()
+ ->all(),
+ );
+
+ expect(app(ConfigurationDiffer::class)->diff($previousSnapshot, $currentSnapshot)->isChanged())->toBeFalse();
});
-it('detects environment variable value changes without exposing secret values', function () {
+it('detects environment variable value changes for unlocked variables', function () {
$application = snapshotTestApplication();
EnvironmentVariable::create([
'key' => 'API_TOKEN',