This commit is contained in:
Alexander Gabriel 2025-11-10 22:38:22 +00:00
parent 4e774e4fe1
commit c09da27dea
3 changed files with 13 additions and 4 deletions

View File

@ -10,6 +10,7 @@ return [
'urlAuthorize' => env("OAUTH2_URL_AUTHORIZE", env("OAUTH2_BASE_URL")."/auth"), 'urlAuthorize' => env("OAUTH2_URL_AUTHORIZE", env("OAUTH2_BASE_URL")."/auth"),
'urlAccessToken' => env("OAUTH2_URL_ACCESS_TOKEN", env("OAUTH2_BASE_URL")."/token"), 'urlAccessToken' => env("OAUTH2_URL_ACCESS_TOKEN", env("OAUTH2_BASE_URL")."/token"),
'urlResourceOwnerDetails' => env("OAUTH2_URL_RSOURCE_OWNER_DETAILS", env("OAUTH2_BASE_URL")."/userinfo"), 'urlResourceOwnerDetails' => env("OAUTH2_URL_RSOURCE_OWNER_DETAILS", env("OAUTH2_BASE_URL")."/userinfo"),
'urlLogout' => env("OAUTH2_URL_LOGOUT", env("OAUTH2_BASE_URL")."/logout"),
'scopes' => env("OAUTH2_SCOPES", "profile email openid"), 'scopes' => env("OAUTH2_SCOPES", "profile email openid"),
'updateRoles' => env("OAUTH2_UPDATE_ROLES", false) 'updateRoles' => env("OAUTH2_UPDATE_ROLES", false)

View File

@ -15,12 +15,11 @@ Route::prefix($panel->getPath())
Route::name('filament-oauth2.') Route::name('filament-oauth2.')
->prefix('filament-oauth2') ->prefix('filament-oauth2')
->group(function () { ->group(function () {
Route::post('handleLogout', [Oauth2Controller::class, 'handleLogout'])->name('handleLogout');
Route::get('redirectToOauth2Server', [Oauth2Controller::class, 'redirectToOauth2Server']) Route::get('redirectToOauth2Server', [Oauth2Controller::class, 'redirectToOauth2Server'])
->name('redirectToOauth2Server'); ->name('redirectToOauth2Server');
Route::get('handleCallback', [Oauth2Controller::class, 'handleCallback']) Route::get('handleCallback', [Oauth2Controller::class, 'handleCallback'])
->name('handleCallback'); ->name('handleCallback');
}); });
}); });

View File

@ -4,6 +4,7 @@ namespace AlexanderGabriel\FilamentOauth2;
use AlexanderGabriel\FilamentOauth2\Facades\FilamentOauth2; use AlexanderGabriel\FilamentOauth2\Facades\FilamentOauth2;
use Filament\Contracts\Plugin; use Filament\Contracts\Plugin;
use Filament\Navigation\MenuItem;
use Filament\Panel; use Filament\Panel;
class FilamentOauth2Plugin implements Plugin class FilamentOauth2Plugin implements Plugin
@ -15,7 +16,15 @@ class FilamentOauth2Plugin implements Plugin
public function register(Panel $panel): void public function register(Panel $panel): void
{ {
$panel->login(FilamentOauth2::getLoginRouteAction()); $panel
->login(FilamentOauth2::getLoginRouteAction())
->userMenuItems([
'logout' => MenuItem::make()->url(function () {
$panel = filament()->getCurrentPanel();
return '/'.$panel->getPath().'/'.$this->getId().'/handleLogout';
}),
]);
} }
public function boot(Panel $panel): void public function boot(Panel $panel): void