[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /auth switchserver.pm

raeburn raeburn at source.lon-capa.org
Sun Dec 12 16:07:21 EST 2021


raeburn		Sun Dec 12 21:07:21 2021 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/auth	switchserver.pm 
  Log:
  - For 2.11
    Backport 1.54, 1.55, 1.56, 1.58
  
  
Index: loncom/auth/switchserver.pm
diff -u loncom/auth/switchserver.pm:1.35.2.5 loncom/auth/switchserver.pm:1.35.2.6
--- loncom/auth/switchserver.pm:1.35.2.5	Mon Jan  4 03:54:38 2021
+++ loncom/auth/switchserver.pm	Sun Dec 12 21:07:21 2021
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Switch Servers Handler
 #
-# $Id: switchserver.pm,v 1.35.2.5 2021/01/04 03:54:38 raeburn Exp $
+# $Id: switchserver.pm,v 1.35.2.6 2021/12/12 21:07:21 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -29,7 +29,7 @@
 package Apache::switchserver;
 
 use strict;
-use Apache::Constants qw(:common);
+use Apache::Constants qw(:common :remotehost);
 use Apache::lonnet;
 use Digest::MD5 qw(md5_hex);
 use CGI::Cookie();
@@ -57,7 +57,7 @@
     my ($r,$url,$only_body,$extra_text) = @_;
     $r->send_http_header;
     my $delay = 0.5;
-    if ($only_body) {
+    if ($only_body && !$extra_text) {
         $delay = 0;
     }
     my $start_page = 
@@ -111,7 +111,7 @@
 						   $env{'user.name'});
 	if (! $env{'form.otherserver'}) {
 	    $env{'form.otherserver'} = 
-		&Apache::lonnet::spareserver(30000,undef,1);
+		&Apache::lonnet::spareserver($r,30000,undef,1);
 	}
 	$switch_to=&Apache::lonnet::hostname($env{'form.otherserver'});
     }
@@ -123,6 +123,10 @@
         if ($Apache::lonnet::protocol{$env{'form.otherserver'}} eq 'https') {
             $protocol = $Apache::lonnet::protocol{$env{'form.otherserver'}};
         }
+        unless ($env{'form.otherserver'} eq $r->dir_config('lonHostID')) {
+            my $alias = &Apache::lonnet::use_proxy_alias($r,$env{'form.otherserver'});
+            $switch_to = $alias if ($alias ne '');
+        }
     }
 
     if ($env{'user.name'} eq 'public'
@@ -203,7 +207,7 @@
     } else {
         $logmsg .= " (no role)";
     }
-    my $ip = &Apache::lonnet::get_requestor_ip();
+    my $ip = &Apache::lonnet::get_requestor_ip($r,REMOTE_NOLOOKUP);
     $logmsg .= ' '.$ip;
     &Apache::lonnet::log($env{'user.domain'},$env{'user.name'},
 			 $env{'user.home'},$logmsg);
@@ -266,8 +270,21 @@
     if ($env{'form.symb'}) {
         $info{'symb'} = $env{'form.symb'};
     }
+    my $ssologoutscript = ''; 
     if ($env{'request.sso.login'}) {
 	$info{'sso.login'} = $env{'request.sso.login'};
+        if (defined($r->dir_config("lonSSOUserLogoutScriptFile_$info{domain}"))) {
+            if (open(my $fh,'<',$r->dir_config("lonSSOUserLogoutScriptFile_$info{domain}"))) {
+                $ssologoutscript .= join('',<$fh>);
+                close($fh);
+            }
+        }
+        if (defined($r->dir_config('lonSSOUserLogoutScriptFile'))) {
+            if (open(my $fh,'<',$r->dir_config('lonSSOUserLogoutScriptFile'))) {
+                $ssologoutscript .= join('',<$fh>);
+                close($fh);
+            }
+        }
     }
     if ($env{'request.sso.reloginserver'}) {
         $info{'sso.reloginserver'} = $env{'request.sso.reloginserver'};
@@ -278,7 +295,7 @@
 	'&username='.$env{'user.name'}.
 	'&token='.$token;
 # --------------------------------------------------------------- Screen Output
-    return &do_redirect($r, $url, $only_body);
+    return &do_redirect($r, $url, $only_body, $ssologoutscript);
 }
 
 1;




More information about the LON-CAPA-cvs mailing list