[Rt-commit] rt branch 5.0/improve-log-info-for-web-remote-user-auth created. rt-5.0.3-216-g4e46f947ee
BPS Git Server
git at git.bestpractical.com
Thu Dec 29 15:03:10 UTC 2022
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt".
The branch, 5.0/improve-log-info-for-web-remote-user-auth has been created
at 4e46f947eed1693f018c8688eacf5a94170ce4a3 (commit)
- Log -----------------------------------------------------------------
commit 4e46f947eed1693f018c8688eacf5a94170ce4a3
Author: Ronaldo Richieri <ronaldo at bestpractical.com>
Date: Tue Dec 27 12:43:28 2022 -0300
Add Log Info/Debug/Error when user log in and out with web remote user auth.
Change Logout menu behavior when LogoutURL is set to first delete session from RT and then redirect.
diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index da6382ec27..7de6dcf3fc 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -806,6 +806,7 @@ sub AttemptExternalAuth {
}
if ( _UserLoggedIn() ) {
+ RT->Logger->info("Session created from REMOTE_USER for user $user");
$HTML::Mason::Commands::session{'WebExternallyAuthed'} = 1;
$m->callback( %$ARGS, CallbackName => 'ExternalAuthSuccessfulLogin', CallbackPage => '/autohandler' );
# It is possible that we did a redirect to the login page,
diff --git a/lib/RT/Interface/Web/MenuBuilder.pm b/lib/RT/Interface/Web/MenuBuilder.pm
index f3dc87c541..b6260023a8 100644
--- a/lib/RT/Interface/Web/MenuBuilder.pm
+++ b/lib/RT/Interface/Web/MenuBuilder.pm
@@ -338,11 +338,8 @@ sub BuildMainNav {
);
}
}
- my $logout_url = RT->Config->Get('LogoutURL');
- if ( $current_user->Name
- && ( !RT->Config->Get('WebRemoteUserAuth')
- || RT->Config->Get('WebFallbackToRTLogin') )) {
- $about_me->child( logout => title => loc('Logout'), path => $logout_url );
+ if ( $current_user->Name ) {
+ _BuildLogoutMenu( $about_me );
}
if ( $request_path =~ m{^/Dashboards/(\d+)?}) {
if ( my $id = ( $1 || $HTML::Mason::Commands::DECODED_ARGS->{'id'} ) ) {
@@ -1624,6 +1621,18 @@ sub _BuildAdminMenu {
}
}
+sub _BuildLogoutMenu {
+ my $about_me = shift;
+
+ my $logout_url = RT->Config->Get('LogoutURL') || '/NoAuth/Logout.html';
+ # If user is not externally authenticated, show the logout link
+ # otherwise, show the logout link if LogoutURL is set to something other than the default
+ if ( !$HTML::Mason::Commands::session{'WebExternallyAuthed'} || $logout_url ne '/NoAuth/Logout.html' )
+ {
+ $about_me->child( logout => title => loc('Logout'), path => '/NoAuth/Logout.html' );
+ }
+}
+
sub BuildSelfServiceNav {
my $request_path = shift;
my $top = shift;
@@ -1694,11 +1703,8 @@ sub BuildSelfServiceNav {
$about_me->child( prefs => title => loc('Preferences'), path => '/SelfService/Prefs.html' );
}
- my $logout_url = RT->Config->Get('LogoutURL');
- if ( $current_user->Name
- && ( !RT->Config->Get('WebRemoteUserAuth')
- || RT->Config->Get('WebFallbackToRTLogin') )) {
- $about_me->child( logout => title => loc('Logout'), path => $logout_url );
+ if ( $current_user->Name ) {
+ _BuildLogoutMenu($about_me);
}
if ( RT->Config->Get('SelfServiceShowArticleSearch') ) {
diff --git a/share/html/NoAuth/Logout.html b/share/html/NoAuth/Logout.html
index 4587533211..f6bd25ea3b 100644
--- a/share/html/NoAuth/Logout.html
+++ b/share/html/NoAuth/Logout.html
@@ -77,11 +77,25 @@ $m->callback( %ARGS, CallbackName => 'ModifyLoginRedirect', URL => \$URL );
$m->callback( %ARGS, CallbackName => 'BeforeSessionDelete' );
+my $username;
if (keys %session) {
+ $username = $session{'CurrentUser'}->Name;
+
+ # If WebRemoteUserAuth and LogoutURL are set, redirect to the LogoutURL set on Config
+ if (
+ $session{'WebExternallyAuthed'}
+ && RT->Config->Get('LogoutURL')
+ ) {
+ $URL = RT->Config->Get('LogoutURL');
+ }
+
+ # Clear the session
RT::Interface::Web::InstantiateNewSession();
$session{'CurrentUser'} = RT::CurrentUser->new;
}
$m->callback( %ARGS, CallbackName => 'AfterSessionDelete' );
$m->notes->{RefreshURL} = $URL;
+
+RT->Logger->info("User $username logged out. Redirecting to $URL") if $username;
</%INIT>
-----------------------------------------------------------------------
hooks/post-receive
--
rt
More information about the rt-commit
mailing list