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

raeburn raeburn at source.lon-capa.org
Sun Oct 5 20:48:44 EDT 2014


raeburn		Mon Oct  6 00:48:44 2014 EDT

  Modified files:              
    /loncom/interface	domainprefs.pm 
    /loncom/auth	migrateuser.pm 
  Log:
  Bug 6675 (IP change detected in session migration).
  - Additional option for both SSO user and non-SSO users
    - Session hosted (after re-authentication) on a specified server selected
      from servers belonging to domain's "internet domain".
  
  
-------------- next part --------------
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.253 loncom/interface/domainprefs.pm:1.254
--- loncom/interface/domainprefs.pm:1.253	Sun Oct  5 13:34:01 2014
+++ loncom/interface/domainprefs.pm	Mon Oct  6 00:48:39 2014
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set domain-wide configuration settings
 #
-# $Id: domainprefs.pm,v 1.253 2014/10/05 13:34:01 raeburn Exp $
+# $Id: domainprefs.pm,v 1.254 2014/10/06 00:48:39 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -3806,7 +3806,7 @@
     my @rulenames;
     my %ruletitles = &offloadtype_text();
     if (($type eq '_LC_ipchangesso') || ($type eq '_LC_ipchange')) {
-        @rulenames = ('balancer','offloadedto');
+        @rulenames = ('balancer','offloadedto','specific');
     } else {
         @rulenames = ('default','homeserver');
         if ($type eq '_LC_external') {
@@ -3868,8 +3868,13 @@
                    '<input type="radio" name="loadbalancing_rules_'.$balnum.'_'.$type.
                    '" id="loadbalancing_rules_'.$balnum.'_'.$type.'_'.$i.'" value="'.
                    $rule.'" onclick="balanceruleChange('."this.form,'$balnum','$type'".
-                   ')"'.$checked.' /> '.$ruletitles{$rulenames[$i]}.
-                   '</label>'.$extra.'</span><br />'."\n";
+                   ')"'.$checked.' /> ';
+        if (($rulenames[$i] eq 'specific') && ($type =~ /^_LC_ipchange/)) {
+            $output .= $ruletitles{'particular'};
+        } else {
+            $output .= $ruletitles{$rulenames[$i]};
+        }
+        $output .= '</label>'.$extra.'</span><br />'."\n";
     }
     $output .= '</div></td></tr>'."\n";
     return $output;
@@ -3884,6 +3889,7 @@
            'none'             => 'No offload',
            'balancer'         => 'Session hosted on Load Balancer, after re-authentication',
            'offloadedto'      => 'Session hosted on offload server, after re-authentication',
+           'particular'       => 'Session hosted (after re-auth) on server:',
     );
     return %ruletitles;
 }
@@ -10847,9 +10853,8 @@
                                         if ($rule eq '') {
                                             $balancetext =  $ruletitles{'default'};
                                         } elsif (($rule eq 'homeserver') || ($rule eq 'externalbalancer') ||
-                                                 ($rule eq 'balancer') || ($rule eq 'offloadedto')) {
-                                            $balancetext =  $ruletitles{$rule};
-                                            if (($rule eq 'balancer') || ($rule eq 'offloadedto')) {
+                                                 ($type eq '_LC_ipchange') || ($type eq '_LC_ipchangesso')) { 
+                                            if (($type eq '_LC_ipchange') || ($type eq '_LC_ipchangesso')) {
                                                 foreach my $sparetype (@sparestypes) {
                                                     if (ref($defaultshash{'loadbalancing'}{$balancer}{'targets'}{$sparetype}) eq 'ARRAY') {
                                                         map { $toupdate{$_} = 1; } (@{$defaultshash{'loadbalancing'}{$balancer}{'targets'}{$sparetype}});
@@ -10868,6 +10873,17 @@
                                                         }
                                                     }
                                                 }
+                                                if (($rule eq 'balancer') || ($rule eq 'offloadedto')) {
+                                                    $balancetext =  $ruletitles{$rule};
+                                                } else {
+                                                    my $receiver = $defaultshash{'loadbalancing'}{$balancer}{'rules'}{$type};
+                                                    $balancetext = $ruletitles{'particular'}.' '.$receiver;
+                                                    if ($receiver) {
+                                                        $toupdate{$receiver};
+                                                    }
+                                                }
+                                            } else {
+                                                $balancetext =  $ruletitles{$rule};
                                             }
                                         } else {
                                             $balancetext = &mt('offload to [_1]',$defaultshash{'loadbalancing'}{$balancer}{'rules'}{$type});
Index: loncom/auth/migrateuser.pm
diff -u loncom/auth/migrateuser.pm:1.22 loncom/auth/migrateuser.pm:1.23
--- loncom/auth/migrateuser.pm:1.22	Sun Oct  5 13:49:11 2014
+++ loncom/auth/migrateuser.pm	Mon Oct  6 00:48:44 2014
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Starts a user off based of an existing token.
 #
-# $Id: migrateuser.pm,v 1.22 2014/10/05 13:49:11 raeburn Exp $
+# $Id: migrateuser.pm,v 1.23 2014/10/06 00:48:44 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -114,36 +114,58 @@
         my $url;
         my $lonhost= $r->dir_config('lonHostID');
         my $switchto = $lonhost;
-        if ($rule_in_effect eq 'balancer') {
+        if ($rule_in_effect ne 'offloadedto') {
             my $hosthere;
-            if ($dataref->{'role'}) {
-                my ($adom,$aname);
-                if ($dataref->{'role'} =~ m{^au\./($match_domain)/$}) {
-                    $adom = $1;
-                    $aname = $dataref->{'username'};
-                } elsif ($dataref->{'role'} =~ m{^(?:ca|aa)\./($match_domain)/($match_username)$}) {
-                    $adom = $1;
-                    $aname = $2;
-                }
-                if ($adom ne '' && $aname ne '') {
-                    my $ahome = &Apache::lonnet::homeserver($aname,$adom);
-                    unless ($ahome eq 'no_host') {
-                        my @ids=&Apache::lonnet::current_machine_ids();
-                        if ($ahome && grep(/^\Q$ahome\E$/, at ids)) {
-                            $hosthere = 1;
+            my @ids=&Apache::lonnet::current_machine_ids();
+            unless ($rule_in_effect eq 'balancer') {
+                if (grep(/^\Q$rule_in_effect\E$/, at ids)) {
+                    $hosthere = 1;
+                }
+            }
+            unless ($hosthere) {
+                if ($dataref->{'role'}) {
+                    my ($adom,$aname);
+                    if ($dataref->{'role'} =~ m{^au\./($match_domain)/$}) {
+                        $adom = $1;
+                        $aname = $dataref->{'username'};
+                    } elsif ($dataref->{'role'} =~ m{^(?:ca|aa)\./($match_domain)/($match_username)$}) {
+                        $adom = $1;
+                        $aname = $2;
+                    }
+                    if ($adom ne '' && $aname ne '') {
+                        my $ahome = &Apache::lonnet::homeserver($aname,$adom);
+                        unless ($ahome eq 'no_host') {
+                            if ($ahome && grep(/^\Q$ahome\E$/, at ids)) {
+                                $hosthere = 1;
+                            }
                         }
                     }
                 }
             }
-            unless ($hosthere) { 
-                my $hostname = &Apache::lonnet::hostname($dataref->{'server'});
+            unless ($hosthere) {
+                my $hostname;
+                if ($rule_in_effect eq 'balancer') {
+                    $hostname = &Apache::lonnet::hostname($dataref->{'server'});
+                    if ($hostname) {
+                        $switchto = $dataref->{'server'};
+                    }
+                } else {
+                    $hostname = &Apache::lonnet::hostname($rule_in_effect);
+                    if ($hostname) {
+                        $switchto = $rule_in_effect;
+                    }
+                }
                 if ($hostname) {
-                    $switchto = $dataref->{'server'};
                     my $protocol = $Apache::lonnet::protocol{$switchto};
                     $protocol = 'http' if ($protocol ne 'https');
                     $url = $protocol.'://'.$hostname;
-                    $message .= '<br />'.
-                                &mt('As a result, your LON-CAPA session is being redirected to the server where you originally logged in.');
+                    if ($rule_in_effect eq 'balancer') {
+                        $message .= '<br />'.
+                                    &mt('As a result, your LON-CAPA session is being redirected to the server where you originally logged in.');
+                    } else {
+                        $message .= '<br />'.
+                                    &mt('As a result, your LON-CAPA session is being redirected.');
+                    }
                 }
             }
         }


More information about the LON-CAPA-cvs mailing list