From 96ef0ef749bd31fdbd56241956d4161ebc9b8b77 Mon Sep 17 00:00:00 2001 From: Danilo Martinelli Date: Sun, 29 Sep 2024 13:51:41 -0300 Subject: [PATCH 01/10] feat: :passport_control: integrate Authentik authentication with Coolify - Configured Authentik as the OAuth provider in Coolify. --- app/Livewire/SettingsOauth.php | 1 + app/Providers/EventServiceProvider.php | 1 + bootstrap/helpers/socialite.php | 11 ++++ composer.json | 1 + composer.lock | 50 +++++++++++++++++++ config/services.php | 7 +++ ...5_add_base_url_to_oauth_settings_table.php | 32 ++++++++++++ database/seeders/OauthSettingSeeder.php | 4 ++ lang/en.json | 1 + .../views/livewire/settings-oauth.blade.php | 4 ++ 10 files changed, 112 insertions(+) create mode 100644 database/migrations/2024_09_29_163625_add_base_url_to_oauth_settings_table.php diff --git a/app/Livewire/SettingsOauth.php b/app/Livewire/SettingsOauth.php index c3884589f..472d35ba0 100644 --- a/app/Livewire/SettingsOauth.php +++ b/app/Livewire/SettingsOauth.php @@ -17,6 +17,7 @@ class SettingsOauth extends Component $carry["oauth_settings_map.$setting->provider.client_secret"] = 'nullable'; $carry["oauth_settings_map.$setting->provider.redirect_uri"] = 'nullable'; $carry["oauth_settings_map.$setting->provider.tenant"] = 'nullable'; + $carry["oauth_settings_map.$setting->provider.base_url"] = 'nullable'; return $carry; }, []); diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index 7ba72e10d..2147495fa 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -21,6 +21,7 @@ class EventServiceProvider extends ServiceProvider ], \SocialiteProviders\Manager\SocialiteWasCalled::class => [ \SocialiteProviders\Azure\AzureExtendSocialite::class.'@handle', + \SocialiteProviders\Authentik\AuthentikExtendSocialite::class.'@handle', ], ProxyStarted::class => [ ProxyStartedNotification::class, diff --git a/bootstrap/helpers/socialite.php b/bootstrap/helpers/socialite.php index a23dc24d3..2922f5a00 100644 --- a/bootstrap/helpers/socialite.php +++ b/bootstrap/helpers/socialite.php @@ -18,6 +18,17 @@ function get_socialite_provider(string $provider) return Socialite::driver('azure')->setConfig($azure_config); } + if ($provider == 'authentik') { + $authentik_config = new \SocialiteProviders\Manager\Config( + $oauth_setting->client_id, + $oauth_setting->client_secret, + $oauth_setting->redirect_uri, + ['base_url' => $oauth_setting->base_url], + ); + + return Socialite::driver('authentik')->setConfig($authentik_config); + } + $config = [ 'client_id' => $oauth_setting->client_id, 'client_secret' => $oauth_setting->client_secret, diff --git a/composer.json b/composer.json index fbd77d0cf..8763d1b07 100644 --- a/composer.json +++ b/composer.json @@ -35,6 +35,7 @@ "pusher/pusher-php-server": "^7.2", "resend/resend-laravel": "^0.13.0", "sentry/sentry-laravel": "^4.6", + "socialiteproviders/authentik": "^5.2", "socialiteproviders/microsoft-azure": "^5.1", "spatie/laravel-activitylog": "^4.7.3", "spatie/laravel-data": "^3.4.3", diff --git a/composer.lock b/composer.lock index 0b8da82d0..04c4741ba 100644 --- a/composer.lock +++ b/composer.lock @@ -7586,6 +7586,56 @@ ], "time": "2024-09-19T12:58:53+00:00" }, + { + "name": "socialiteproviders/authentik", + "version": "5.2.0", + "source": { + "type": "git", + "url": "https://github.com/SocialiteProviders/Authentik.git", + "reference": "4cf129cf04728a38e0531c54454464b162f0fa66" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/SocialiteProviders/Authentik/zipball/4cf129cf04728a38e0531c54454464b162f0fa66", + "reference": "4cf129cf04728a38e0531c54454464b162f0fa66", + "shasum": "" + }, + "require": { + "ext-json": "*", + "php": "^8.0", + "socialiteproviders/manager": "^4.4" + }, + "type": "library", + "autoload": { + "psr-4": { + "SocialiteProviders\\Authentik\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "rf152", + "email": "git@rf152.co.uk" + } + ], + "description": "Authentik OAuth2 Provider for Laravel Socialite", + "keywords": [ + "authentik", + "laravel", + "oauth", + "provider", + "socialite" + ], + "support": { + "docs": "https://socialiteproviders.com/authentik", + "issues": "https://github.com/socialiteproviders/providers/issues", + "source": "https://github.com/socialiteproviders/providers" + }, + "time": "2023-11-07T22:21:16+00:00" + }, { "name": "socialiteproviders/manager", "version": "v4.6.0", diff --git a/config/services.php b/config/services.php index 9fd55870f..46fd12ec3 100644 --- a/config/services.php +++ b/config/services.php @@ -38,4 +38,11 @@ return [ 'tenant' => env('AZURE_TENANT_ID'), 'proxy' => env('AZURE_PROXY'), ], + + 'authentik' => [ + 'base_url' => env('AUTHENTIK_BASE_URL'), + 'client_id' => env('AUTHENTIK_CLIENT_ID'), + 'client_secret' => env('AUTHENTIK_CLIENT_SECRET'), + 'redirect' => env('AUTHENTIK_REDIRECT_URI'), + ], ]; diff --git a/database/migrations/2024_09_29_163625_add_base_url_to_oauth_settings_table.php b/database/migrations/2024_09_29_163625_add_base_url_to_oauth_settings_table.php new file mode 100644 index 000000000..8df9b48a2 --- /dev/null +++ b/database/migrations/2024_09_29_163625_add_base_url_to_oauth_settings_table.php @@ -0,0 +1,32 @@ +string('base_url')->nullable(); + }); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('oauth_settings', function (Blueprint $table) { + Schema::table('oauth_settings', function (Blueprint $table) { + $table->dropColumn('base_url'); + }); + }); + } +}; diff --git a/database/seeders/OauthSettingSeeder.php b/database/seeders/OauthSettingSeeder.php index 16abf9e04..d0365c542 100644 --- a/database/seeders/OauthSettingSeeder.php +++ b/database/seeders/OauthSettingSeeder.php @@ -32,5 +32,9 @@ class OauthSettingSeeder extends Seeder 'id' => 4, 'provider' => 'google', ]); + OauthSetting::firstOrCreate([ + 'id' => 5, + 'provider' => 'authentik', + ]); } } diff --git a/lang/en.json b/lang/en.json index fa69c7035..383bbda02 100644 --- a/lang/en.json +++ b/lang/en.json @@ -1,5 +1,6 @@ { "auth.login": "Login", + "auth.login.authentik": "Login with Authentik", "auth.login.azure": "Login with Microsoft", "auth.login.bitbucket": "Login with Bitbucket", "auth.login.github": "Login with GitHub", diff --git a/resources/views/livewire/settings-oauth.blade.php b/resources/views/livewire/settings-oauth.blade.php index 9a94d3c2b..2362ad880 100644 --- a/resources/views/livewire/settings-oauth.blade.php +++ b/resources/views/livewire/settings-oauth.blade.php @@ -32,6 +32,10 @@ @endif + @if ($oauth_setting->provider == 'authentik') + + @endif @endforeach From 97b6257872efc845116339ee3452708d2c8fd551 Mon Sep 17 00:00:00 2001 From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com> Date: Wed, 11 Dec 2024 17:09:21 +0100 Subject: [PATCH 02/10] fix: provider error --- app/Providers/EventServiceProvider.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index 2147495fa..aa3579f8d 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -9,6 +9,9 @@ use App\Listeners\ProxyStartedNotification; use Illuminate\Foundation\Events\MaintenanceModeDisabled; use Illuminate\Foundation\Events\MaintenanceModeEnabled; use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider; +use SocialiteProviders\Authentik\AuthentikExtendSocialite; +use SocialiteProviders\Azure\AzureExtendSocialite; +use SocialiteProviders\Manager\SocialiteWasCalled; class EventServiceProvider extends ServiceProvider { @@ -19,9 +22,9 @@ class EventServiceProvider extends ServiceProvider MaintenanceModeDisabled::class => [ MaintenanceModeDisabledNotification::class, ], - \SocialiteProviders\Manager\SocialiteWasCalled::class => [ - \SocialiteProviders\Azure\AzureExtendSocialite::class.'@handle', - \SocialiteProviders\Authentik\AuthentikExtendSocialite::class.'@handle', + SocialiteWasCalled::class => [ + AzureExtendSocialite::class.'@handle', + AuthentikExtendSocialite::class.'@handle', ], ProxyStarted::class => [ ProxyStartedNotification::class, From edb14f886671d588a72f6764401c6a862b5f74b2 Mon Sep 17 00:00:00 2001 From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com> Date: Wed, 11 Dec 2024 17:09:25 +0100 Subject: [PATCH 03/10] Update composer.lock --- composer.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.lock b/composer.lock index b7dfea43b..2cea9d3b6 100644 --- a/composer.lock +++ b/composer.lock @@ -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": "d96fe0aedd865274164c34a1b04195fe", + "content-hash": "871067cb42e6347ca53ff36e81ac5079", "packages": [ { "name": "3sidedcube/laravel-redoc", @@ -15317,12 +15317,12 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": {}, + "stability-flags": [], "prefer-stable": true, "prefer-lowest": false, "platform": { "php": "^8.2" }, - "platform-dev": {}, + "platform-dev": [], "plugin-api-version": "2.6.0" } From 46e6c9db51005f99cdf7732fd13e9e1e62b12a68 Mon Sep 17 00:00:00 2001 From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com> Date: Wed, 11 Dec 2024 17:13:13 +0100 Subject: [PATCH 04/10] chore: bump dep --- composer.lock | 340 +++++++++++++++++++++----------------------------- 1 file changed, 141 insertions(+), 199 deletions(-) diff --git a/composer.lock b/composer.lock index 2cea9d3b6..3fbe72afb 100644 --- a/composer.lock +++ b/composer.lock @@ -979,16 +979,16 @@ }, { "name": "aws/aws-sdk-php", - "version": "3.334.2", + "version": "3.334.3", "source": { "type": "git", "url": "https://github.com/aws/aws-sdk-php.git", - "reference": "b19afc076bb1cc2617bdef76efd41587596109e7" + "reference": "6576a9fcfc6ae7c76aed3c6fa4c3864060f72d04" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/b19afc076bb1cc2617bdef76efd41587596109e7", - "reference": "b19afc076bb1cc2617bdef76efd41587596109e7", + "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/6576a9fcfc6ae7c76aed3c6fa4c3864060f72d04", + "reference": "6576a9fcfc6ae7c76aed3c6fa4c3864060f72d04", "shasum": "" }, "require": { @@ -1071,9 +1071,9 @@ "support": { "forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80", "issues": "https://github.com/aws/aws-sdk-php/issues", - "source": "https://github.com/aws/aws-sdk-php/tree/3.334.2" + "source": "https://github.com/aws/aws-sdk-php/tree/3.334.3" }, - "time": "2024-12-09T19:30:23+00:00" + "time": "2024-12-10T19:41:55+00:00" }, { "name": "bacon/bacon-qr-code", @@ -3313,16 +3313,16 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-master": "5.x-dev" - }, "laravel": { - "providers": [ - "Laravel\\Socialite\\SocialiteServiceProvider" - ], "aliases": { "Socialite": "Laravel\\Socialite\\Facades\\Socialite" - } + }, + "providers": [ + "Laravel\\Socialite\\SocialiteServiceProvider" + ] + }, + "branch-alias": { + "dev-master": "5.x-dev" } }, "autoload": { @@ -4037,16 +4037,16 @@ }, { "name": "league/oauth1-client", - "version": "v1.10.1", + "version": "v1.11.0", "source": { "type": "git", "url": "https://github.com/thephpleague/oauth1-client.git", - "reference": "d6365b901b5c287dd41f143033315e2f777e1167" + "reference": "f9c94b088837eb1aae1ad7c4f23eb65cc6993055" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/oauth1-client/zipball/d6365b901b5c287dd41f143033315e2f777e1167", - "reference": "d6365b901b5c287dd41f143033315e2f777e1167", + "url": "https://api.github.com/repos/thephpleague/oauth1-client/zipball/f9c94b088837eb1aae1ad7c4f23eb65cc6993055", + "reference": "f9c94b088837eb1aae1ad7c4f23eb65cc6993055", "shasum": "" }, "require": { @@ -4107,9 +4107,9 @@ ], "support": { "issues": "https://github.com/thephpleague/oauth1-client/issues", - "source": "https://github.com/thephpleague/oauth1-client/tree/v1.10.1" + "source": "https://github.com/thephpleague/oauth1-client/tree/v1.11.0" }, - "time": "2022-04-15T14:02:14+00:00" + "time": "2024-12-10T19:59:05+00:00" }, { "name": "league/uri", @@ -5952,64 +5952,6 @@ }, "time": "2024-10-13T11:29:49+00:00" }, - { - "name": "phpstan/phpstan", - "version": "1.12.12", - "source": { - "type": "git", - "url": "https://github.com/phpstan/phpstan.git", - "reference": "b5ae1b88f471d3fd4ba1aa0046234b5ca3776dd0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/b5ae1b88f471d3fd4ba1aa0046234b5ca3776dd0", - "reference": "b5ae1b88f471d3fd4ba1aa0046234b5ca3776dd0", - "shasum": "" - }, - "require": { - "php": "^7.2|^8.0" - }, - "conflict": { - "phpstan/phpstan-shim": "*" - }, - "bin": [ - "phpstan", - "phpstan.phar" - ], - "type": "library", - "autoload": { - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "PHPStan - PHP Static Analysis Tool", - "keywords": [ - "dev", - "static analysis" - ], - "support": { - "docs": "https://phpstan.org/user-guide/getting-started", - "forum": "https://github.com/phpstan/phpstan/discussions", - "issues": "https://github.com/phpstan/phpstan/issues", - "security": "https://github.com/phpstan/phpstan/security/policy", - "source": "https://github.com/phpstan/phpstan-src" - }, - "funding": [ - { - "url": "https://github.com/ondrejmirtes", - "type": "github" - }, - { - "url": "https://github.com/phpstan", - "type": "github" - } - ], - "time": "2024-11-28T22:13:23+00:00" - }, { "name": "pimple/pimple", "version": "v3.5.0", @@ -7099,65 +7041,6 @@ ], "time": "2024-04-27T21:32:50+00:00" }, - { - "name": "rector/rector", - "version": "1.2.10", - "source": { - "type": "git", - "url": "https://github.com/rectorphp/rector.git", - "reference": "40f9cf38c05296bd32f444121336a521a293fa61" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/rectorphp/rector/zipball/40f9cf38c05296bd32f444121336a521a293fa61", - "reference": "40f9cf38c05296bd32f444121336a521a293fa61", - "shasum": "" - }, - "require": { - "php": "^7.2|^8.0", - "phpstan/phpstan": "^1.12.5" - }, - "conflict": { - "rector/rector-doctrine": "*", - "rector/rector-downgrade-php": "*", - "rector/rector-phpunit": "*", - "rector/rector-symfony": "*" - }, - "suggest": { - "ext-dom": "To manipulate phpunit.xml via the custom-rule command" - }, - "bin": [ - "bin/rector" - ], - "type": "library", - "autoload": { - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Instant Upgrade and Automated Refactoring of any PHP code", - "keywords": [ - "automation", - "dev", - "migration", - "refactoring" - ], - "support": { - "issues": "https://github.com/rectorphp/rector/issues", - "source": "https://github.com/rectorphp/rector/tree/1.2.10" - }, - "funding": [ - { - "url": "https://github.com/tomasvotruba", - "type": "github" - } - ], - "time": "2024-11-08T13:59:10+00:00" - }, { "name": "resend/resend-laravel", "version": "v0.15.0", @@ -8009,40 +7892,41 @@ }, { "name": "spatie/laravel-ray", - "version": "1.37.1", + "version": "1.39.0", "source": { "type": "git", "url": "https://github.com/spatie/laravel-ray.git", - "reference": "c2bedfd1172648df2c80aaceb2541d70f1d9a5b9" + "reference": "31b601f98590606d20e76b5dd68578dc1642cd2c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/spatie/laravel-ray/zipball/c2bedfd1172648df2c80aaceb2541d70f1d9a5b9", - "reference": "c2bedfd1172648df2c80aaceb2541d70f1d9a5b9", + "url": "https://api.github.com/repos/spatie/laravel-ray/zipball/31b601f98590606d20e76b5dd68578dc1642cd2c", + "reference": "31b601f98590606d20e76b5dd68578dc1642cd2c", "shasum": "" }, "require": { + "composer-runtime-api": "^2.2", "ext-json": "*", - "illuminate/contracts": "^7.20|^8.19|^9.0|^10.0|^11.0", - "illuminate/database": "^7.20|^8.19|^9.0|^10.0|^11.0", - "illuminate/queue": "^7.20|^8.19|^9.0|^10.0|^11.0", - "illuminate/support": "^7.20|^8.19|^9.0|^10.0|^11.0", - "php": "^7.4|^8.0", - "rector/rector": "^0.19.2|^1.0", + "illuminate/contracts": "^7.20 || ^8.19 || ^9.0 || ^10.0 || ^11.0", + "illuminate/database": "^7.20 || ^8.19 || ^9.0 || ^10.0 || ^11.0", + "illuminate/queue": "^7.20 || ^8.19 || ^9.0 || ^10.0 || ^11.0", + "illuminate/support": "^7.20 || ^8.19 || ^9.0 || ^10.0 || ^11.0", + "php": "^7.4 || ^8.0", "spatie/backtrace": "^1.0", - "spatie/ray": "^1.41.1", - "symfony/stopwatch": "4.2|^5.1|^6.0|^7.0", - "zbateson/mail-mime-parser": "^1.3.1|^2.0|^3.0" + "spatie/ray": "^1.41.3", + "symfony/stopwatch": "4.2 || ^5.1 || ^6.0 || ^7.0", + "zbateson/mail-mime-parser": "^1.3.1 || ^2.0 || ^3.0" }, "require-dev": { "guzzlehttp/guzzle": "^7.3", - "laravel/framework": "^7.20|^8.19|^9.0|^10.0|^11.0", - "orchestra/testbench-core": "^5.0|^6.0|^7.0|^8.0|^9.0", - "pestphp/pest": "^1.22|^2.0", - "phpstan/phpstan": "^1.10.57", - "phpunit/phpunit": "^9.3|^10.1", - "spatie/pest-plugin-snapshots": "^1.1|^2.0", - "symfony/var-dumper": "^4.2|^5.1|^6.0|^7.0.3" + "laravel/framework": "^7.20 || ^8.19 || ^9.0 || ^10.0 || ^11.0", + "orchestra/testbench-core": "^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0", + "pestphp/pest": "^1.22 || ^2.0", + "phpstan/phpstan": "^1.10.57 || ^2.0.2", + "phpunit/phpunit": "^9.3 || ^10.1", + "rector/rector": "dev-main", + "spatie/pest-plugin-snapshots": "^1.1 || ^2.0", + "symfony/var-dumper": "^4.2 || ^5.1 || ^6.0 || ^7.0.3" }, "type": "library", "extra": { @@ -8080,7 +7964,7 @@ ], "support": { "issues": "https://github.com/spatie/laravel-ray/issues", - "source": "https://github.com/spatie/laravel-ray/tree/1.37.1" + "source": "https://github.com/spatie/laravel-ray/tree/1.39.0" }, "funding": [ { @@ -8092,7 +7976,7 @@ "type": "other" } ], - "time": "2024-07-12T12:35:17+00:00" + "time": "2024-12-11T09:34:41+00:00" }, { "name": "spatie/laravel-schemaless-attributes", @@ -8582,16 +8466,16 @@ }, { "name": "symfony/console", - "version": "v7.2.0", + "version": "v7.2.1", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "23c8aae6d764e2bae02d2a99f7532a7f6ed619cf" + "reference": "fefcc18c0f5d0efe3ab3152f15857298868dc2c3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/23c8aae6d764e2bae02d2a99f7532a7f6ed619cf", - "reference": "23c8aae6d764e2bae02d2a99f7532a7f6ed619cf", + "url": "https://api.github.com/repos/symfony/console/zipball/fefcc18c0f5d0efe3ab3152f15857298868dc2c3", + "reference": "fefcc18c0f5d0efe3ab3152f15857298868dc2c3", "shasum": "" }, "require": { @@ -8655,7 +8539,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v7.2.0" + "source": "https://github.com/symfony/console/tree/v7.2.1" }, "funding": [ { @@ -8671,7 +8555,7 @@ "type": "tidelift" } ], - "time": "2024-11-06T14:24:19+00:00" + "time": "2024-12-11T03:49:26+00:00" }, { "name": "symfony/css-selector", @@ -8807,16 +8691,16 @@ }, { "name": "symfony/error-handler", - "version": "v7.2.0", + "version": "v7.2.1", "source": { "type": "git", "url": "https://github.com/symfony/error-handler.git", - "reference": "672b3dd1ef8b87119b446d67c58c106c43f965fe" + "reference": "6150b89186573046167796fa5f3f76601d5145f8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/error-handler/zipball/672b3dd1ef8b87119b446d67c58c106c43f965fe", - "reference": "672b3dd1ef8b87119b446d67c58c106c43f965fe", + "url": "https://api.github.com/repos/symfony/error-handler/zipball/6150b89186573046167796fa5f3f76601d5145f8", + "reference": "6150b89186573046167796fa5f3f76601d5145f8", "shasum": "" }, "require": { @@ -8862,7 +8746,7 @@ "description": "Provides tools to manage errors and ease debugging PHP code", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/error-handler/tree/v7.2.0" + "source": "https://github.com/symfony/error-handler/tree/v7.2.1" }, "funding": [ { @@ -8878,7 +8762,7 @@ "type": "tidelift" } ], - "time": "2024-11-05T15:35:02+00:00" + "time": "2024-12-07T08:50:44+00:00" }, { "name": "symfony/event-dispatcher", @@ -9180,16 +9064,16 @@ }, { "name": "symfony/http-kernel", - "version": "v7.2.0", + "version": "v7.2.1", "source": { "type": "git", "url": "https://github.com/symfony/http-kernel.git", - "reference": "6b4722a25e0aed1ccb4914b9bcbd493cc4676b4d" + "reference": "d8ae58eecae44c8e66833e76cc50a4ad3c002d97" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-kernel/zipball/6b4722a25e0aed1ccb4914b9bcbd493cc4676b4d", - "reference": "6b4722a25e0aed1ccb4914b9bcbd493cc4676b4d", + "url": "https://api.github.com/repos/symfony/http-kernel/zipball/d8ae58eecae44c8e66833e76cc50a4ad3c002d97", + "reference": "d8ae58eecae44c8e66833e76cc50a4ad3c002d97", "shasum": "" }, "require": { @@ -9274,7 +9158,7 @@ "description": "Provides a structured process for converting a Request into a Response", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/http-kernel/tree/v7.2.0" + "source": "https://github.com/symfony/http-kernel/tree/v7.2.1" }, "funding": [ { @@ -9290,7 +9174,7 @@ "type": "tidelift" } ], - "time": "2024-11-29T08:42:40+00:00" + "time": "2024-12-11T12:09:10+00:00" }, { "name": "symfony/mailer", @@ -9374,16 +9258,16 @@ }, { "name": "symfony/mime", - "version": "v7.2.0", + "version": "v7.2.1", "source": { "type": "git", "url": "https://github.com/symfony/mime.git", - "reference": "cc84a4b81f62158c3846ac7ff10f696aae2b524d" + "reference": "7f9617fcf15cb61be30f8b252695ed5e2bfac283" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/mime/zipball/cc84a4b81f62158c3846ac7ff10f696aae2b524d", - "reference": "cc84a4b81f62158c3846ac7ff10f696aae2b524d", + "url": "https://api.github.com/repos/symfony/mime/zipball/7f9617fcf15cb61be30f8b252695ed5e2bfac283", + "reference": "7f9617fcf15cb61be30f8b252695ed5e2bfac283", "shasum": "" }, "require": { @@ -9438,7 +9322,7 @@ "mime-type" ], "support": { - "source": "https://github.com/symfony/mime/tree/v7.2.0" + "source": "https://github.com/symfony/mime/tree/v7.2.1" }, "funding": [ { @@ -9454,7 +9338,7 @@ "type": "tidelift" } ], - "time": "2024-11-23T09:19:39+00:00" + "time": "2024-12-07T08:50:44+00:00" }, { "name": "symfony/options-resolver", @@ -13272,17 +13156,75 @@ "time": "2024-11-21T15:12:59+00:00" }, { - "name": "phpunit/php-code-coverage", - "version": "11.0.7", + "name": "phpstan/phpstan", + "version": "1.12.12", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "f7f08030e8811582cc459871d28d6f5a1a4d35ca" + "url": "https://github.com/phpstan/phpstan.git", + "reference": "b5ae1b88f471d3fd4ba1aa0046234b5ca3776dd0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/f7f08030e8811582cc459871d28d6f5a1a4d35ca", - "reference": "f7f08030e8811582cc459871d28d6f5a1a4d35ca", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/b5ae1b88f471d3fd4ba1aa0046234b5ca3776dd0", + "reference": "b5ae1b88f471d3fd4ba1aa0046234b5ca3776dd0", + "shasum": "" + }, + "require": { + "php": "^7.2|^8.0" + }, + "conflict": { + "phpstan/phpstan-shim": "*" + }, + "bin": [ + "phpstan", + "phpstan.phar" + ], + "type": "library", + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan - PHP Static Analysis Tool", + "keywords": [ + "dev", + "static analysis" + ], + "support": { + "docs": "https://phpstan.org/user-guide/getting-started", + "forum": "https://github.com/phpstan/phpstan/discussions", + "issues": "https://github.com/phpstan/phpstan/issues", + "security": "https://github.com/phpstan/phpstan/security/policy", + "source": "https://github.com/phpstan/phpstan-src" + }, + "funding": [ + { + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://github.com/phpstan", + "type": "github" + } + ], + "time": "2024-11-28T22:13:23+00:00" + }, + { + "name": "phpunit/php-code-coverage", + "version": "11.0.8", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-code-coverage.git", + "reference": "418c59fd080954f8c4aa5631d9502ecda2387118" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/418c59fd080954f8c4aa5631d9502ecda2387118", + "reference": "418c59fd080954f8c4aa5631d9502ecda2387118", "shasum": "" }, "require": { @@ -13301,7 +13243,7 @@ "theseer/tokenizer": "^1.2.3" }, "require-dev": { - "phpunit/phpunit": "^11.4.1" + "phpunit/phpunit": "^11.5.0" }, "suggest": { "ext-pcov": "PHP extension that provides line coverage", @@ -13339,7 +13281,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/11.0.7" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/11.0.8" }, "funding": [ { @@ -13347,7 +13289,7 @@ "type": "github" } ], - "time": "2024-10-09T06:21:38+00:00" + "time": "2024-12-11T12:34:27+00:00" }, { "name": "phpunit/php-file-iterator", @@ -14665,16 +14607,16 @@ }, { "name": "spatie/error-solutions", - "version": "1.1.1", + "version": "1.1.2", "source": { "type": "git", "url": "https://github.com/spatie/error-solutions.git", - "reference": "ae7393122eda72eed7cc4f176d1e96ea444f2d67" + "reference": "d239a65235a1eb128dfa0a4e4c4ef032ea11b541" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/spatie/error-solutions/zipball/ae7393122eda72eed7cc4f176d1e96ea444f2d67", - "reference": "ae7393122eda72eed7cc4f176d1e96ea444f2d67", + "url": "https://api.github.com/repos/spatie/error-solutions/zipball/d239a65235a1eb128dfa0a4e4c4ef032ea11b541", + "reference": "d239a65235a1eb128dfa0a4e4c4ef032ea11b541", "shasum": "" }, "require": { @@ -14727,7 +14669,7 @@ ], "support": { "issues": "https://github.com/spatie/error-solutions/issues", - "source": "https://github.com/spatie/error-solutions/tree/1.1.1" + "source": "https://github.com/spatie/error-solutions/tree/1.1.2" }, "funding": [ { @@ -14735,7 +14677,7 @@ "type": "github" } ], - "time": "2024-07-25T11:06:04+00:00" + "time": "2024-12-11T09:51:56+00:00" }, { "name": "spatie/flare-client-php", @@ -15317,12 +15259,12 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": {}, "prefer-stable": true, "prefer-lowest": false, "platform": { "php": "^8.2" }, - "platform-dev": [], + "platform-dev": {}, "plugin-api-version": "2.6.0" } From aeb97401ba43905a268728aae7073fe2f0effbc6 Mon Sep 17 00:00:00 2001 From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com> Date: Wed, 11 Dec 2024 17:19:49 +0100 Subject: [PATCH 05/10] fix: database migration --- ...18_add_authentik_base_url_to_oauth_settings_table.php} | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) rename database/migrations/{2024_09_29_163625_add_base_url_to_oauth_settings_table.php => 2024_12_11_161418_add_authentik_base_url_to_oauth_settings_table.php} (64%) diff --git a/database/migrations/2024_09_29_163625_add_base_url_to_oauth_settings_table.php b/database/migrations/2024_12_11_161418_add_authentik_base_url_to_oauth_settings_table.php similarity index 64% rename from database/migrations/2024_09_29_163625_add_base_url_to_oauth_settings_table.php rename to database/migrations/2024_12_11_161418_add_authentik_base_url_to_oauth_settings_table.php index 8df9b48a2..44ecb0cde 100644 --- a/database/migrations/2024_09_29_163625_add_base_url_to_oauth_settings_table.php +++ b/database/migrations/2024_12_11_161418_add_authentik_base_url_to_oauth_settings_table.php @@ -12,9 +12,7 @@ return new class extends Migration public function up(): void { Schema::table('oauth_settings', function (Blueprint $table) { - Schema::table('oauth_settings', function (Blueprint $table) { - $table->string('base_url')->nullable(); - }); + $table->string('base_url')->nullable(); }); } @@ -24,9 +22,7 @@ return new class extends Migration public function down(): void { Schema::table('oauth_settings', function (Blueprint $table) { - Schema::table('oauth_settings', function (Blueprint $table) { - $table->dropColumn('base_url'); - }); + $table->dropColumn('base_url'); }); } }; From 737f70387ca0d7bf08637ea66095c575a3c71384 Mon Sep 17 00:00:00 2001 From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com> Date: Wed, 11 Dec 2024 17:27:36 +0100 Subject: [PATCH 06/10] fix: seeder - do not hardcode IDs as this is bad practice. - Use update or create to allow the seeder to be run multiple times. --- database/seeders/OauthSettingSeeder.php | 38 +++++++++---------------- 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/database/seeders/OauthSettingSeeder.php b/database/seeders/OauthSettingSeeder.php index d0365c542..2b733120c 100644 --- a/database/seeders/OauthSettingSeeder.php +++ b/database/seeders/OauthSettingSeeder.php @@ -12,29 +12,19 @@ class OauthSettingSeeder extends Seeder */ public function run(): void { - OauthSetting::firstOrCreate([ - 'id' => 0, - 'provider' => 'azure', - ]); - OauthSetting::firstOrCreate([ - 'id' => 1, - 'provider' => 'bitbucket', - ]); - OauthSetting::firstOrCreate([ - 'id' => 2, - 'provider' => 'github', - ]); - OauthSetting::firstOrCreate([ - 'id' => 3, - 'provider' => 'gitlab', - ]); - OauthSetting::firstOrCreate([ - 'id' => 4, - 'provider' => 'google', - ]); - OauthSetting::firstOrCreate([ - 'id' => 5, - 'provider' => 'authentik', - ]); + $providers = [ + 'azure', + 'bitbucket', + 'github', + 'gitlab', + 'google', + 'authentik', + ]; + + foreach ($providers as $provider) { + OauthSetting::updateOrCreate( + ['provider' => $provider] + ); + } } } From 2e1f9b51191f64d0a5e19de9572ac998f1a2eeff Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 12 Dec 2024 09:00:58 +0100 Subject: [PATCH 07/10] refactor: remove unused Azure and Authentik service configurations from services.php --- config/services.php | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/config/services.php b/config/services.php index 46fd12ec3..509e73756 100644 --- a/config/services.php +++ b/config/services.php @@ -30,19 +30,4 @@ return [ 'secret' => env('AWS_SECRET_ACCESS_KEY'), 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), ], - - 'azure' => [ - 'client_id' => env('AZURE_CLIENT_ID'), - 'client_secret' => env('AZURE_CLIENT_SECRET'), - 'redirect' => env('AZURE_REDIRECT_URI'), - 'tenant' => env('AZURE_TENANT_ID'), - 'proxy' => env('AZURE_PROXY'), - ], - - 'authentik' => [ - 'base_url' => env('AUTHENTIK_BASE_URL'), - 'client_id' => env('AUTHENTIK_CLIENT_ID'), - 'client_secret' => env('AUTHENTIK_CLIENT_SECRET'), - 'redirect' => env('AUTHENTIK_REDIRECT_URI'), - ], ]; From fba7f6f585a34aefefa1b5c97c34392265aff1c7 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 12 Dec 2024 10:03:31 +0100 Subject: [PATCH 08/10] refactor: change email column types in instance_settings migration from string to text --- ..._122142_encrypt_instance_settings_email_columns.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/database/migrations/2024_12_10_122142_encrypt_instance_settings_email_columns.php b/database/migrations/2024_12_10_122142_encrypt_instance_settings_email_columns.php index 44e0f2f47..5602e0ae9 100644 --- a/database/migrations/2024_12_10_122142_encrypt_instance_settings_email_columns.php +++ b/database/migrations/2024_12_10_122142_encrypt_instance_settings_email_columns.php @@ -45,11 +45,11 @@ return new class extends Migration public function down(): void { Schema::table('instance_settings', function (Blueprint $table) { - $table->string('smtp_from_address')->nullable()->change(); - $table->string('smtp_from_name')->nullable()->change(); - $table->string('smtp_recipients')->nullable()->change(); - $table->string('smtp_host')->nullable()->change(); - $table->string('smtp_username')->nullable()->change(); + $table->text('smtp_from_address')->nullable()->change(); + $table->text('smtp_from_name')->nullable()->change(); + $table->text('smtp_recipients')->nullable()->change(); + $table->text('smtp_host')->nullable()->change(); + $table->text('smtp_username')->nullable()->change(); }); if (DB::table('instance_settings')->exists()) { From 2053fed8a78c4f01de6c3da3289390a02534da45 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 12 Dec 2024 10:04:12 +0100 Subject: [PATCH 09/10] fix: oauth seeder --- database/seeders/OauthSettingSeeder.php | 49 ++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 6 deletions(-) diff --git a/database/seeders/OauthSettingSeeder.php b/database/seeders/OauthSettingSeeder.php index 2b733120c..e004d1450 100644 --- a/database/seeders/OauthSettingSeeder.php +++ b/database/seeders/OauthSettingSeeder.php @@ -12,19 +12,56 @@ class OauthSettingSeeder extends Seeder */ public function run(): void { - $providers = [ + $providers = collect([ 'azure', 'bitbucket', 'github', 'gitlab', 'google', 'authentik', - ]; + ]); - foreach ($providers as $provider) { - OauthSetting::updateOrCreate( - ['provider' => $provider] - ); + $isOauthSeeded = OauthSetting::count() > 0; + $isOauthWithZeroId = OauthSetting::where('id', 0)->exists(); + if ($isOauthSeeded) { + if ($isOauthWithZeroId) { + $allProviders = OauthSetting::all(); + $notFoundProviders = $providers->diff($allProviders->pluck('provider')); + + $allProviders->each(function ($provider) use ($providers) { + $provider->delete(); + $providerName = $provider->provider; + + $foundProvider = $providers->first(function ($provider) use ($providerName) { + return $provider === $providerName; + }); + + if ($foundProvider) { + $newProvder = new OauthSetting; + $newProvder = $provider; + unset($newProvder->id); + $newProvder->save(); + } + }); + + foreach ($notFoundProviders as $provider) { + OauthSetting::create([ + 'provider' => $provider, + ]); + } + } else { + foreach ($providers as $provider) { + OauthSetting::updateOrCreate([ + 'provider' => $provider, + ]); + } + } + } else { + foreach ($providers as $provider) { + OauthSetting::create([ + 'provider' => $provider, + ]); + } } } } From 78eb956870e8adcb413c5d7292de1b47ef2affb7 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 12 Dec 2024 10:11:46 +0100 Subject: [PATCH 10/10] fix: correct heading display for OAuth settings in settings-oauth.blade.php --- resources/views/livewire/settings-oauth.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/livewire/settings-oauth.blade.php b/resources/views/livewire/settings-oauth.blade.php index fcb806547..a525cf7b2 100644 --- a/resources/views/livewire/settings-oauth.blade.php +++ b/resources/views/livewire/settings-oauth.blade.php @@ -16,7 +16,7 @@
@foreach ($oauth_settings_map as $oauth_setting)
-

{{ ucfirst($oauth_setting->provider) }} Oauth

+

{{ ucfirst($oauth_setting->provider) }}