fix saml slo for logout

This commit is contained in:
Johnson Yi 2022-05-14 11:59:34 +00:00
parent c4d75dca68
commit 4401dab8d6
3 changed files with 14 additions and 1 deletions

View file

@ -449,11 +449,18 @@ class LoginController extends Controller
*/ */
public function logout(Request $request) public function logout(Request $request)
{ {
// Logout is only allowed with a http POST but we need to allow GET for SAML SLO
$settings = Setting::getSettings(); $settings = Setting::getSettings();
$saml = $this->saml; $saml = $this->saml;
$samlLogout = $request->session()->get('saml_logout');
$sloRedirectUrl = null; $sloRedirectUrl = null;
$sloRequestUrl = null; $sloRequestUrl = null;
// Only allow GET if we are doing SAML SLO otherwise abort with 405
if ($request->isMethod('GET') && !$samlLogout) {
abort(405);
}
if ($saml->isEnabled()) { if ($saml->isEnabled()) {
$auth = $saml->getAuth(); $auth = $saml->getAuth();
$sloRedirectUrl = $request->session()->get('saml_slo_redirect_url'); $sloRedirectUrl = $request->session()->get('saml_slo_redirect_url');

View file

@ -142,6 +142,6 @@ class SamlController extends Controller
return view('errors.403'); return view('errors.403');
} }
return redirect()->route('logout')->with('saml_slo_redirect_url', $sloUrl); return redirect()->route('logout')->with(['saml_logout' => true,'saml_slo_redirect_url' => $sloUrl]);
} }
} }

View file

@ -434,6 +434,12 @@ Route::group(['middleware' => 'web'], function () {
'uses' => 'DashboardController@getIndex' ] 'uses' => 'DashboardController@getIndex' ]
); );
// need to keep GET /logout for SAML SLO
Route::get(
'logout',
[LoginController::class, 'logout']
)->name('logout');
Route::post( Route::post(
'logout', 'logout',
[LoginController::class, 'logout'] [LoginController::class, 'logout']