This commit is contained in:
Mael 2026-03-11 03:25:05 +08:00 committed by GitHub
commit 919e81d8fa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 59 additions and 3 deletions

View file

@ -29,6 +29,8 @@ class OauthSetting extends Model
case 'authentik':
case 'clerk':
return filled($this->client_id) && filled($this->client_secret) && filled($this->base_url);
case 'keycloak':
return filled($this->client_id) && filled($this->client_secret) && filled($this->base_url) && filled($this->tenant);
default:
return filled($this->client_id) && filled($this->client_secret);
}

View file

@ -11,6 +11,7 @@ use SocialiteProviders\Google\GoogleExtendSocialite;
use SocialiteProviders\Infomaniak\InfomaniakExtendSocialite;
use SocialiteProviders\Manager\SocialiteWasCalled;
use SocialiteProviders\Zitadel\ZitadelExtendSocialite;
use SocialiteProviders\Keycloak\KeycloakExtendSocialite;
class EventServiceProvider extends ServiceProvider
{
@ -23,6 +24,7 @@ class EventServiceProvider extends ServiceProvider
GoogleExtendSocialite::class.'@handle',
InfomaniakExtendSocialite::class.'@handle',
ZitadelExtendSocialite::class.'@handle',
KeycloakExtendSocialite::class.'@handle',
],
];

View file

@ -33,6 +33,17 @@ function get_socialite_provider(string $provider)
return Socialite::driver($provider)->setConfig($authentik_clerk_config);
}
if ($provider == 'keycloak') {
$keycloak_config = new \SocialiteProviders\Manager\Config(
$oauth_setting->client_id,
$oauth_setting->client_secret,
$oauth_setting->redirect_uri,
['base_url' => $oauth_setting->base_url, 'realms' => $oauth_setting->tenant],
);
return Socialite::driver('keycloak')->setConfig($keycloak_config);
}
if ($provider == 'zitadel') {
$zitadel_config = new \SocialiteProviders\Manager\Config(
$oauth_setting->client_id,

View file

@ -43,6 +43,7 @@
"socialiteproviders/discord": "^4.2",
"socialiteproviders/google": "^4.1",
"socialiteproviders/infomaniak": "^4.0",
"socialiteproviders/keycloak": "^5.3",
"socialiteproviders/microsoft-azure": "^5.2",
"socialiteproviders/zitadel": "^4.2",
"spatie/laravel-activitylog": "^4.11.0",

View file

@ -67,4 +67,12 @@ return [
'base_url' => env('ZITADEL_BASE_URL'),
],
'keycloak' => [
'base_url' => env('KEYCLOAK_BASE_URL'),
'realms' => env('KEYCLOAK_REALM', 'master'),
'client_id' => env('KEYCLOAK_CLIENT_ID'),
'client_secret' => env('KEYCLOAK_CLIENT_SECRET'),
'redirect' => env('KEYCLOAK_REDIRECT_URI'),
],
];

View file

@ -0,0 +1,27 @@
<?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
{
\App\Models\OauthSetting::create([
'provider' => 'keycloak',
'enabled' => false,
]);
}
/**
* Reverse the migrations.
*/
public function down(): void
{
\App\Models\OauthSetting::where('provider', 'keycloak')->delete();
}
};

View file

@ -24,6 +24,7 @@ class OauthSettingSeeder extends Seeder
'google',
'authentik',
'infomaniak',
'keycloak',
'zitadel',
]);

View file

@ -9,6 +9,7 @@
"auth.login.gitlab": "Login with Gitlab",
"auth.login.google": "Login with Google",
"auth.login.infomaniak": "Login with Infomaniak",
"auth.login.keycloak": "Login with Keycloak",
"auth.login.zitadel": "Login with Zitadel",
"auth.already_registered": "Already registered?",
"auth.confirm_password": "Confirm password",

View file

@ -9,6 +9,8 @@
"auth.login.gitlab": "Connexion avec Gitlab",
"auth.login.google": "Connexion avec Google",
"auth.login.infomaniak": "Connexion avec Infomaniak",
"auth.login.keycloak": "Connexion avec Keycloak",
"auth.login.zitadel": "Connexion avec Zitadel",
"auth.already_registered": "Déjà enregistré ?",
"auth.confirm_password": "Confirmer le mot de passe",
"auth.forgot_password_link": "Mot de passe oublié ?",

View file

@ -32,15 +32,16 @@
<x-forms.input id="oauth_settings_map.{{ $oauth_setting['provider'] }}.tenant"
label="Tenant" />
@endif
@if ($oauth_setting['provider'] == 'google')
@if ($oauth_setting['provider'] == 'google' || $oauth_setting['provider'] == 'keycloak')
<x-forms.input id="oauth_settings_map.{{ $oauth_setting['provider'] }}.tenant"
helper="Optional parameter that supplies a hosted domain (HD) to Google, which<br>triggers a login hint to be displayed on the OAuth screen with this domain.<br><br><a class='underline dark:text-warning text-coollabs' href='https://developers.google.com/identity/openid-connect/openid-connect#hd-param' target='_blank'>Google Documentation</a>"
label="Tenant" />
helper="{{ $oauth_setting['provider'] == 'google' ? 'Optional parameter that supplies a hosted domain (HD) to Google, which<br>triggers a login hint to be displayed on the OAuth screen with this domain.<br><br><a class=\'underline dark:text-warning text-coollabs\' href=\'https://developers.google.com/identity/openid-connect/openid-connect#hd-param\' target=\'_blank\'>Google Documentation</a>' : 'The Realm name for your Keycloak instance. Default is \'master\'.' }}"
label="{{ $oauth_setting['provider'] == 'google' ? 'Tenant' : 'Realm' }}" />
@endif
@if (
$oauth_setting['provider'] == 'authentik' ||
$oauth_setting['provider'] == 'clerk' ||
$oauth_setting['provider'] == 'zitadel' ||
$oauth_setting['provider'] == 'keycloak' ||
$oauth_setting['provider'] == 'gitlab')
<x-forms.input id="oauth_settings_map.{{ $oauth_setting['provider'] }}.base_url"
label="Base URL" />