feat: 🛂 integrate Authentik authentication with Coolify

- Configured Authentik as the OAuth provider in Coolify.
This commit is contained in:
Danilo Martinelli
2024-09-29 13:51:41 -03:00
parent d54fa6a680
commit 96ef0ef749
10 changed files with 112 additions and 0 deletions

View File

@@ -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;
}, []);

View File

@@ -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,

View File

@@ -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,

View File

@@ -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",

50
composer.lock generated
View File

@@ -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",

View File

@@ -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'),
],
];

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('oauth_settings', function (Blueprint $table) {
Schema::table('oauth_settings', function (Blueprint $table) {
$table->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');
});
});
}
};

View File

@@ -32,5 +32,9 @@ class OauthSettingSeeder extends Seeder
'id' => 4,
'provider' => 'google',
]);
OauthSetting::firstOrCreate([
'id' => 5,
'provider' => 'authentik',
]);
}
}

View File

@@ -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",

View File

@@ -32,6 +32,10 @@
<x-forms.input id="oauth_settings_map.{{ $oauth_setting->provider }}.tenant"
label="Tenant" />
@endif
@if ($oauth_setting->provider == 'authentik')
<x-forms.input id="oauth_settings_map.{{ $oauth_setting->provider }}.base_url"
label="Base URL" />
@endif
</div>
</div>
@endforeach