[LON-CAPA-cvs] cvs: loncom /auth lonacc.pm /lonnet/perl lonnet.pm

raeburn raeburn at source.lon-capa.org
Thu Dec 5 00:19:18 EST 2013


raeburn		Thu Dec  5 05:19:18 2013 EDT

  Modified files:              
    /loncom/auth	lonacc.pm 
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  - Support Apache 2.4 (Fedora 18, 19, 20; SuSE 13.1)
    - $r->user needs to be set in lonnet::check_for_valid_session()
      if the session is valid, but lonacc:sso_login() also needs to be able
      to identify an SSO case.
  
  
Index: loncom/auth/lonacc.pm
diff -u loncom/auth/lonacc.pm:1.146 loncom/auth/lonacc.pm:1.147
--- loncom/auth/lonacc.pm:1.146	Sun Dec  1 21:29:10 2013
+++ loncom/auth/lonacc.pm	Thu Dec  5 05:19:14 2013
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Cookie Based Access Handler
 #
-# $Id: lonacc.pm,v 1.146 2013/12/01 21:29:10 raeburn Exp $
+# $Id: lonacc.pm,v 1.147 2013/12/05 05:19:14 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -264,18 +264,19 @@
 =item sso_login()
 
 	handle the case of the single sign on user, at this point $r->user 
-	will be set and valid now need to find the loncapa user info and possibly
-	balance them
+	will be set and valia;d now need to find the loncapa user info, and possibly
+	balance them. If Apache >= 2.4, $r->user() will also have been set so 
+        $curruser is checked, and if null, this is an SSO case.
 	returns OK if it was a SSO and user was handled
         undef if not SSO or no means to hanle the user
         
 =cut
 
 sub sso_login {
-    my ($r,$handle) = @_;
+    my ($r,$handle,$curruser) = @_;
 
     my $lonidsdir=$r->dir_config('lonIDsDir');
-    if (($r->user eq '') ||
+    if (($r->user eq '') || ($curruser ne '') ||
         (defined($env{'user.name'}) && (defined($env{'user.domain'}))
 	  && ($handle ne ''))) {
 	# not an SSO case or already logged in
@@ -339,7 +340,15 @@
 	} else {
 	    # need to login them in, so generate the need data that
 	    # migrate expects to do login
-	    my %info=('ip'        => $r->connection->remote_ip(),
+	    my $ip;
+	    my $c = $r->connection;
+	    eval {
+	        $ip = $c->remote_ip();
+	    };
+	    if ($@) {
+	        $ip = $c->client_ip();
+	    }
+	    my %info=('ip'        => $ip,
 		      'domain'    => $domain,
 		      'username'  => $user,
 		      'server'    => $r->dir_config('lonHostID'),
@@ -404,9 +413,10 @@
         return OK;
     }
 
-    my $handle = &Apache::lonnet::check_for_valid_session($r);
+    my $curruser;
+    my $handle = &Apache::lonnet::check_for_valid_session($r,undef,\$curruser);
 
-    my $result = &sso_login($r,$handle);
+    my $result = &sso_login($r,$handle,$curruser);
     if (defined($result)) {
 	return $result;
     }
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.1243 loncom/lonnet/perl/lonnet.pm:1.1244
--- loncom/lonnet/perl/lonnet.pm:1.1243	Mon Oct 14 17:14:48 2013
+++ loncom/lonnet/perl/lonnet.pm	Thu Dec  5 05:19:18 2013
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.1243 2013/10/14 17:14:48 raeburn Exp $
+# $Id: lonnet.pm,v 1.1244 2013/12/05 05:19:18 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -606,7 +606,7 @@
 
 # ---------------------------------------------------- Check for valid session 
 sub check_for_valid_session {
-    my ($r,$name) = @_;
+    my ($r,$name,$userref) = @_;
     my %cookies=CGI::Cookie->parse($r->header_in('Cookie'));
     if ($name eq '') {
         $name = 'lonID';
@@ -637,11 +637,16 @@
 	|| !defined($disk_env{'user.domain'})) {
 	return undef;
     }
-    if (($r->user() eq '') && ($apache >= 2.4)) {
-        if ($disk_env{'user.domain'} eq $r->dir_config('lonDefDomain')) {
-            $r->user($disk_env{'user.name'});
-        } else {
-            $r->user($disk_env{'user.name'}.':'.$disk_env{'user.domain'});
+    if ($apache >= 2.4) {
+        if ($r->user() eq '') {
+            if ($disk_env{'user.domain'} eq $r->dir_config('lonDefDomain')) {
+                $r->user($disk_env{'user.name'});
+            } else {
+                $r->user($disk_env{'user.name'}.':'.$disk_env{'user.domain'});
+            }
+        }
+        if (($r->user() ne '') && (ref($userref))) {
+            $$userref = $r->user();
         }
     }
     return $handle;




More information about the LON-CAPA-cvs mailing list