--- loncom/auth/lonacc.pm 2013/12/01 21:29:10 1.146 +++ loncom/auth/lonacc.pm 2013/12/05 05:19:14 1.147 @@ -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 @@ sub upload_size_allowed { =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 @@ sub sso_login { } 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 @@ sub handler { 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; }