[LON-CAPA-cvs] cvs: loncom /auth lonacc.pm lonauth.pm switchserver.pm /lonnet/perl lonnet.pm
raeburn
raeburn at source.lon-capa.org
Mon Oct 19 21:38:12 EDT 2020
raeburn Tue Oct 20 01:38:12 2020 EDT
Modified files:
/loncom/auth lonacc.pm lonauth.pm switchserver.pm
/loncom/lonnet/perl lonnet.pm
Log:
- For non-SSO login on a balancer node, check for balancer cookie in lonauth.pm
after login credentials validated. (Same as lonacc::sso_login for SSO login).
- Not all calls to check_loadbalancing() require determination of a server
to which to offload, even when $is_balancer is true.
Index: loncom/auth/lonacc.pm
diff -u loncom/auth/lonacc.pm:1.182 loncom/auth/lonacc.pm:1.183
--- loncom/auth/lonacc.pm:1.182 Tue Oct 6 17:26:15 2020
+++ loncom/auth/lonacc.pm Tue Oct 20 01:38:12 2020
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Cookie Based Access Handler
#
-# $Id: lonacc.pm,v 1.182 2020/10/06 17:26:15 raeburn Exp $
+# $Id: lonacc.pm,v 1.183 2020/10/20 01:38:12 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -582,31 +582,27 @@
if ($env{'user.noloadbalance'} eq $r->dir_config('lonHostID')) {
$checkexempt = 1;
}
- unless ($checkexempt) {
+ unless (($checkexempt) || (($requrl eq '/adm/switchserver') && (!$r->is_initial_req()))) {
($is_balancer,$otherserver) =
&Apache::lonnet::check_loadbalancing($env{'user.name'},
$env{'user.domain'});
if ($is_balancer) {
- unless (($requrl eq '/adm/switchserver') && (!$r->is_initial_req())) {
- # Check if browser sent a LON-CAPA load balancer cookie (and this is a balancer)
- my ($found_server,$balancer_cookie) = &Apache::lonnet::check_for_balancer_cookie($r);
- if (($found_server) && ($balancer_cookie =~ /^\Q$env{'user.domain'}\E_\Q$env{'user.name'}\E_/)) {
- $otherserver = $found_server;
- }
+ # Check if browser sent a LON-CAPA load balancer cookie (and this is a balancer)
+ my ($found_server,$balancer_cookie) = &Apache::lonnet::check_for_balancer_cookie($r);
+ if (($found_server) && ($balancer_cookie =~ /^\Q$env{'user.domain'}\E_\Q$env{'user.name'}\E_/)) {
+ $otherserver = $found_server;
+ }
+ unless ($requrl eq '/adm/switchserver') {
+ $r->set_handlers('PerlResponseHandler'=>
+ [\&Apache::switchserver::handler]);
}
- }
- }
- if ($is_balancer) {
- unless (($requrl eq '/adm/switchserver') && (!$r->is_initial_req())) {
- $r->set_handlers('PerlResponseHandler'=>
- [\&Apache::switchserver::handler]);
if ($otherserver ne '') {
$env{'form.otherserver'} = $otherserver;
}
- }
- unless (($env{'form.origurl'}) || ($r->uri eq '/adm/roles') ||
- ($r->uri eq '/adm/switchserver') || ($r->uri eq '/adm/sso')) {
- $env{'form.origurl'} = $r->uri;
+ unless (($env{'form.origurl'}) || ($r->uri eq '/adm/roles') ||
+ ($r->uri eq '/adm/switchserver') || ($r->uri eq '/adm/sso')) {
+ $env{'form.origurl'} = $r->uri;
+ }
}
}
if ($requrl=~m{^/+tiny/+$match_domain/+\w+$}) {
Index: loncom/auth/lonauth.pm
diff -u loncom/auth/lonauth.pm:1.160 loncom/auth/lonauth.pm:1.161
--- loncom/auth/lonauth.pm:1.160 Thu Oct 15 03:09:40 2020
+++ loncom/auth/lonauth.pm Tue Oct 20 01:38:12 2020
@@ -1,7 +1,7 @@
# The LearningOnline Network
# User Authentication Module
#
-# $Id: lonauth.pm,v 1.160 2020/10/15 03:09:40 raeburn Exp $
+# $Id: lonauth.pm,v 1.161 2020/10/20 01:38:12 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -646,6 +646,11 @@
($is_balancer,$otherserver) =
&Apache::lonnet::check_loadbalancing($form{'uname'},$form{'udom'},'login');
if ($is_balancer) {
+ # Check if browser sent a LON-CAPA load balancer cookie (and this is a balancer)
+ my ($found_server,$balancer_cookie) = &Apache::lonnet::check_for_balancer_cookie($r);
+ if (($found_server) && ($balancer_cookie =~ /^\Q$env{'user.domain'}\E_\Q$env{'user.name'}\E_/)) {
+ $otherserver = $found_server;
+ }
if ($otherserver eq '') {
my $lowest_load;
($otherserver,undef,undef,undef,$lowest_load) = &Apache::lonnet::choose_server($form{'udom'});
Index: loncom/auth/switchserver.pm
diff -u loncom/auth/switchserver.pm:1.49 loncom/auth/switchserver.pm:1.50
--- loncom/auth/switchserver.pm:1.49 Sat Jun 15 02:50:04 2019
+++ loncom/auth/switchserver.pm Tue Oct 20 01:38:12 2020
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Switch Servers Handler
#
-# $Id: switchserver.pm,v 1.49 2019/06/15 02:50:04 raeburn Exp $
+# $Id: switchserver.pm,v 1.50 2020/10/20 01:38:12 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -234,10 +234,10 @@
# ---------------------------------------------------------------- Get handover
- my $newcookieid;
+ my ($is_balancer,$setcookie,$newcookieid,$offloadto,$dom_balancers);
my $only_body = 0;
- my ($is_balancer,$posshost,$setcookie,$offloadto,$dom_balancers) =
- &Apache::lonnet::check_loadbalancing($env{'user.name'},$env{'user.domain'});
+ ($is_balancer,undef,$setcookie,$offloadto,$dom_balancers) =
+ &Apache::lonnet::check_loadbalancing($env{'user.name'},$env{'user.domain'},'switchserver');
if ($is_balancer && $setcookie && $env{'form.otherserver'}) {
# Set a balancer cookie unless browser already sent LON-CAPA load balancer
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.1429 loncom/lonnet/perl/lonnet.pm:1.1430
--- loncom/lonnet/perl/lonnet.pm:1.1429 Thu Oct 15 19:17:40 2020
+++ loncom/lonnet/perl/lonnet.pm Tue Oct 20 01:38:12 2020
@@ -1,7 +1,7 @@
# The LearningOnline Network
# TCP networking package
#
-# $Id: lonnet.pm,v 1.1429 2020/10/15 19:17:40 raeburn Exp $
+# $Id: lonnet.pm,v 1.1430 2020/10/20 01:38:12 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1646,7 +1646,7 @@
if ($domneedscache) {
&do_cache_new('loadbalancing',$domneedscache,$is_balancer,$cachetime);
}
- if ($is_balancer) {
+ if (($is_balancer) && ($caller ne 'switchserver')) {
my $lowest_load = 30000;
if (ref($offloadto) eq 'HASH') {
if (ref($offloadto->{'primary'}) eq 'ARRAY') {
@@ -1686,9 +1686,9 @@
}
}
}
- unless ($homeintdom) {
- undef($setcookie);
- }
+ }
+ if (($is_balancer) && (!$homeintdom)) {
+ undef($setcookie);
}
return ($is_balancer,$otherserver,$setcookie,$offloadto,$dom_balancers);
}
More information about the LON-CAPA-cvs
mailing list