Merge pull request #10998 from johnson-yi/fixes/saml_logout

Fixes #10980 - Prevent immediate saml login after normal logout
This commit is contained in:
snipe 2022-04-30 19:49:54 +01:00 committed by GitHub
commit 313150e6dd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 10 deletions

View file

@ -68,15 +68,17 @@ class LoginController extends Controller
return redirect()->intended('/'); return redirect()->intended('/');
} }
// If the environment is set to ALWAYS require SAML, go straight to the SAML route. if (!$request->session()->has('loggedout')) {
// We don't need to check other settings, as this should override those. // If the environment is set to ALWAYS require SAML, go straight to the SAML route.
if (config('app.require_saml')) { // We don't need to check other settings, as this should override those.
return redirect()->route('saml.login'); if (config('app.require_saml')) {
} return redirect()->route('saml.login');
}
if ($this->saml->isEnabled() && Setting::getSettings()->saml_forcelogin == '1' && ! ($request->has('nosaml') || $request->session()->has('error'))) { if ($this->saml->isEnabled() && Setting::getSettings()->saml_forcelogin == '1' && ! ($request->has('nosaml') || $request->session()->has('error'))) {
return redirect()->route('saml.login'); return redirect()->route('saml.login');
}
} }
if (Setting::getSettings()->login_common_disabled == '1') { if (Setting::getSettings()->login_common_disabled == '1') {

View file

@ -36,6 +36,7 @@
<!-- Notifications --> <!-- Notifications -->
@include('notifications') @include('notifications')
@if (!config('app.require_saml'))
<div class="col-md-12"> <div class="col-md-12">
<!-- CSRF Token --> <!-- CSRF Token -->
@ -59,10 +60,10 @@
</div> </div>
</fieldset> </fieldset>
</div> <!-- end col-md-12 --> </div> <!-- end col-md-12 -->
@endif
</div> <!-- end row --> </div> <!-- end row -->
@if ($snipeSettings->saml_enabled) @if (!config('app.require_saml') && $snipeSettings->saml_enabled)
<div class="row "> <div class="row ">
<div class="text-right col-md-12"> <div class="text-right col-md-12">
<a href="{{ route('saml.login') }}">{{ trans('auth/general.saml_login') }}</a> <a href="{{ route('saml.login') }}">{{ trans('auth/general.saml_login') }}</a>
@ -71,12 +72,16 @@
@endif @endif
</div> </div>
<div class="box-footer"> <div class="box-footer">
@if (config('app.require_saml'))
<a class="btn btn-lg btn-primary btn-block" href="{{ route('saml.login') }}">{{ trans('auth/general.saml_login') }}</a>
@else
<button class="btn btn-lg btn-primary btn-block">{{ trans('auth/general.login') }}</button> <button class="btn btn-lg btn-primary btn-block">{{ trans('auth/general.login') }}</button>
@endif
</div> </div>
<div class="text-right col-md-12 col-sm-12 col-xs-12" style="padding-top: 10px;"> <div class="text-right col-md-12 col-sm-12 col-xs-12" style="padding-top: 10px;">
@if ($snipeSettings->custom_forgot_pass_url) @if ($snipeSettings->custom_forgot_pass_url)
<a href="{{ $snipeSettings->custom_forgot_pass_url }}" rel="noopener">{{ trans('auth/general.forgot_password') }}</a> <a href="{{ $snipeSettings->custom_forgot_pass_url }}" rel="noopener">{{ trans('auth/general.forgot_password') }}</a>
@else @elseif (!config('app.require_saml'))
<a href="{{ route('password.request') }}">{{ trans('auth/general.forgot_password') }}</a> <a href="{{ route('password.request') }}">{{ trans('auth/general.forgot_password') }}</a>
@endif @endif