Compare commits

...

2 Commits

Author SHA1 Message Date
ae6869781e comment in english, removed trailing space
Some checks are pending
Fix PHP Code Styling / php-code-styling (push) Waiting to run
PHPStan / phpstan (push) Waiting to run
run-tests / P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} (2.*, 10.*, ubuntu-latest, 8.1, prefer-lowest, 8.*) (push) Waiting to run
run-tests / P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} (2.*, 10.*, ubuntu-latest, 8.1, prefer-stable, 8.*) (push) Waiting to run
run-tests / P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} (2.*, 10.*, ubuntu-latest, 8.2, prefer-lowest, 8.*) (push) Waiting to run
run-tests / P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} (2.*, 10.*, ubuntu-latest, 8.2, prefer-stable, 8.*) (push) Waiting to run
run-tests / P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} (2.*, 10.*, windows-latest, 8.1, prefer-lowest, 8.*) (push) Waiting to run
run-tests / P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} (2.*, 10.*, windows-latest, 8.1, prefer-stable, 8.*) (push) Waiting to run
run-tests / P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} (2.*, 10.*, windows-latest, 8.2, prefer-lowest, 8.*) (push) Waiting to run
run-tests / P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} (2.*, 10.*, windows-latest, 8.2, prefer-stable, 8.*) (push) Waiting to run
2025-11-10 22:39:23 +00:00
c09da27dea Logout 2025-11-10 22:38:22 +00:00
4 changed files with 23 additions and 10 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

View File

@ -76,7 +76,7 @@ class Oauth2Controller extends Controller
if($roles) $hasRoles = true; if($roles) $hasRoles = true;
} }
catch (Exception $e) { catch (Exception $e) {
//keine Rollen... Nichts tun... //No Roles. Nothing to do
} }
if($hasRoles && config('filament-oauth2.updateRoles') != false) { if($hasRoles && config('filament-oauth2.updateRoles') != false) {
//Are there roles in the Token? //Are there roles in the Token?
@ -129,8 +129,12 @@ class Oauth2Controller extends Controller
]); ]);
} }
//TODO: Logout public function handleLogout(Request $request)
// filament-oauth2-demo/vendor/filament/filament/src/Http/Controllers/Auth/LogoutController.php {
session()->invalidate();
session()->regenerateToken();
Filament::auth()->logout();
$logoutUrl = config('filament-oauth2.urlLogout').'?client_id=filamentphp';
return redirect($logoutUrl);
}
} }