Compare commits

..

No commits in common. "ae6869781eb275549b1b1982dcfcd89020ce9998" and "4e774e4fe1f8aa2f717c7669060155e8413ac8bd" have entirely different histories.

4 changed files with 10 additions and 23 deletions

View File

@ -10,7 +10,6 @@ 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,11 +15,12 @@ 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,7 +4,6 @@ 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
@ -16,15 +15,7 @@ class FilamentOauth2Plugin implements Plugin
public function register(Panel $panel): void public function register(Panel $panel): void
{ {
$panel $panel->login(FilamentOauth2::getLoginRouteAction());
->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) {
//No Roles. Nothing to do //keine Rollen... Nichts tun...
} }
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,12 +129,8 @@ class Oauth2Controller extends Controller
]); ]);
} }
public function handleLogout(Request $request) //TODO: Logout
{ // 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);
}
} }