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

raeburn raeburn@source.lon-capa.org
Thu, 23 Jul 2009 17:40:29 -0000


raeburn		Thu Jul 23 17:40:29 2009 EDT

  Modified files:              
    /loncom/auth	lonacc.pm migrateuser.pm 
  Log:
  - Bug 3987. Deep-linking.
  - Preserve role and symb from query string in call to SSO authenticator.
    - Propagate to migrateuser when starting session.
  
  
Index: loncom/auth/lonacc.pm
diff -u loncom/auth/lonacc.pm:1.125 loncom/auth/lonacc.pm:1.126
--- loncom/auth/lonacc.pm:1.125	Tue Apr 14 23:52:07 2009
+++ loncom/auth/lonacc.pm	Thu Jul 23 17:40:29 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Cookie Based Access Handler
 #
-# $Id: lonacc.pm,v 1.125 2009/04/14 23:52:07 raeburn Exp $
+# $Id: lonacc.pm,v 1.126 2009/07/23 17:40:29 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -278,6 +278,20 @@
 
     my ($user) = ($r->user =~ m/([a-zA-Z0-9_\-@.]*)/);
 
+    my $query = $r->args;
+    my %form;
+    if ($query) {
+        foreach my $pair (split(/&/,$query)) {
+            my ($name, $value) = split(/=/,$pair);
+            $name = &unescape($name);
+            if (($name eq 'role') || ($name eq 'symb')) {
+                $value =~ tr/+/ /;
+                $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
+                $form{$name} = $value;
+            }
+        }
+    }
+
     my $domain = $r->dir_config('lonDefDomain');
     my $home=&Apache::lonnet::homeserver($user,$domain);
     if ($home !~ /(con_lost|no_host|no_such_host)/) {
@@ -285,7 +299,7 @@
 	if ($r->dir_config("lonBalancer") eq 'yes') {
 	    # login but immeaditly go to switch server to find us a new 
 	    # machine
-	    &Apache::lonauth::success($r,$user,$domain,$home,'noredirect');
+	    &Apache::lonauth::success($r,$user,$domain,$home,'noredirect','',\%form);
             $env{'request.sso.login'} = 1;
             if (defined($r->dir_config("lonSSOReloginServer"))) {
                 $env{'request.sso.reloginserver'} =
@@ -302,6 +316,11 @@
 		      'server'    => $r->dir_config('lonHostID'),
 		      'sso.login' => 1
 		      );
+            foreach my $item ('role','symb') {
+                if (exists($form{$item})) {
+                    $info{$item} = $form{$item};
+                }
+            }
             if ($r->dir_config("ssodirecturl") == 1) {
                 $info{'origurl'} = $r->uri;
             }
Index: loncom/auth/migrateuser.pm
diff -u loncom/auth/migrateuser.pm:1.15 loncom/auth/migrateuser.pm:1.16
--- loncom/auth/migrateuser.pm:1.15	Tue Apr 14 23:52:07 2009
+++ loncom/auth/migrateuser.pm	Thu Jul 23 17:40:29 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Starts a user off based of an existing token.
 #
-# $Id: migrateuser.pm,v 1.15 2009/04/14 23:52:07 raeburn Exp $
+# $Id: migrateuser.pm,v 1.16 2009/07/23 17:40:29 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -89,6 +89,11 @@
 
     my $extra_env = &sso_check(\%data);
 
+    my %form;
+    if ($data{'symb'} ne '') {
+        $form{'symb'} = $data{'symb'};
+    }
+
     if (!$data{'role'}) {
 	my $handle = &Apache::lonnet::check_for_valid_session($r);
 	if ($handle) {
@@ -107,7 +112,7 @@
                 $desturl = $data{'origurl'};
             }
 	    &Apache::lonauth::success($r,$data{'username'},$data{'domain'},
-				      $home,$desturl,$extra_env);
+				      $home,$desturl,$extra_env,\%form);
 
 	}
 	return OK;
@@ -118,12 +123,8 @@
     if ($data{'origurl'} ne '') {
         $next_url .= '&orgurl='.&escape($data{'origurl'});
     }
-    if ($data{'symb'} ne '') {
-        $next_url .= '&symb='.&escape($data{'symb'});
-    }
-    
     &Apache::lonauth::success($r,$data{'username'},$data{'domain'},$home,
-			      $next_url,$extra_env);
+			      $next_url,$extra_env,\%form);
     return OK;
 }