Diff for /loncom/auth/lonacc.pm between versions 1.144 and 1.149

version 1.144, 2013/05/10 17:49:17 version 1.149, 2013/12/13 02:10:27
Line 89  store attempted access Line 89  store attempted access
   
 =head1 NOTABLE SUBROUTINES  =head1 NOTABLE SUBROUTINES
   
 =over  
   
 =cut  =cut
   
   
Line 103  use Apache::lonnet; Line 101  use Apache::lonnet;
 use Apache::loncommon();  use Apache::loncommon();
 use Apache::lonlocal;  use Apache::lonlocal;
 use Apache::restrictedaccess();  use Apache::restrictedaccess();
 use Apache::blockedaccess();   use Apache::blockedaccess();
 use Fcntl qw(:flock);  use Fcntl qw(:flock);
 use LONCAPA qw(:DEFAULT :match);  use LONCAPA qw(:DEFAULT :match);
   
Line 230  sub get_posted_cgi { Line 228  sub get_posted_cgi {
   
 =pod  =pod
   
   =over
   
 =item upload_size_allowed()  =item upload_size_allowed()
   
  Perform size checks for file uploads to essayresponse items in course context.   Perform size checks for file uploads to essayresponse items in course context.
Line 264  sub upload_size_allowed { Line 264  sub upload_size_allowed {
 =item sso_login()  =item sso_login()
   
  handle the case of the single sign on user, at this point $r->user    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   will be set and valid now need to find the loncapa user info, and possibly
  balance them   balance them. If $r->user() is set this means either it was either set by
  returns OK if it was a SSO and user was handled          SSO or by checkauthen.pm if a valid cookie was found. The latter case can
         undef if not SSO or no means to hanle the user          be identified by the third arg ($usename).
   
    returns OK if it was SSO and user was handled.
           returns undef if not SSO or no means to handle the user.
                   
 =cut  =cut
   
 sub sso_login {  sub sso_login {
     my ($r,$handle) = @_;      my ($r,$handle,$username) = @_;
   
     my $lonidsdir=$r->dir_config('lonIDsDir');      my $lonidsdir=$r->dir_config('lonIDsDir');
     if (($r->user eq '') ||      if (($r->user eq '') || ($username ne '') ||
         (defined($env{'user.name'}) && (defined($env{'user.domain'}))          (defined($env{'user.name'}) && (defined($env{'user.domain'}))
   && ($handle ne ''))) {    && ($handle ne ''))) {
  # not an SSO case or already logged in   # not an SSO case or already logged in
Line 287  sub sso_login { Line 290  sub sso_login {
     my $query = $r->args;      my $query = $r->args;
     my %form;      my %form;
     if ($query) {      if ($query) {
         my @items = ('role','symb');          my @items = ('role','symb','iptoken');
         &Apache::loncommon::get_unprocessed_cgi($query,\@items);          &Apache::loncommon::get_unprocessed_cgi($query,\@items);
         foreach my $item (@items) {          foreach my $item (@items) {
             if (defined($env{'form.'.$item})) {              if (defined($env{'form.'.$item})) {
Line 296  sub sso_login { Line 299  sub sso_login {
         }          }
     }      }
   
       my %sessiondata;
       if ($form{'iptoken'}) {
           %sessiondata = &Apache::lonnet::tmpget($form{'iptoken'});
           my $delete = &Apache::lonnet::tmpdel($form{'token'});
       }
   
     my $domain = $r->dir_config('lonSSOUserDomain');      my $domain = $r->dir_config('lonSSOUserDomain');
     if ($domain eq '') {      if ($domain eq '') {
         $domain = $r->dir_config('lonDefDomain');          $domain = $r->dir_config('lonDefDomain');
Line 303  sub sso_login { Line 312  sub sso_login {
     my $home=&Apache::lonnet::homeserver($user,$domain);      my $home=&Apache::lonnet::homeserver($user,$domain);
     if ($home !~ /(con_lost|no_host|no_such_host)/) {      if ($home !~ /(con_lost|no_host|no_such_host)/) {
  &Apache::lonnet::logthis(" SSO authorized user $user ");   &Apache::lonnet::logthis(" SSO authorized user $user ");
         my ($is_balancer,$otherserver) =          my ($is_balancer,$otherserver,$hosthere);
             &Apache::lonnet::check_loadbalancing($user,$domain);          if ($form{'iptoken'}) {
               if (($sessiondata{'domain'} eq $form{'udom'}) &&
                   ($sessiondata{'username'} eq $form{'uname'})) {
                   $hosthere = 1;
               }
           }
           unless ($hosthere) {
               ($is_balancer,$otherserver) =
                   &Apache::lonnet::check_loadbalancing($user,$domain);
           }
   
  if ($is_balancer) {   if ($is_balancer) {
     # login but immediately go to switch server to find us a new       # login but immediately go to switch server to find us a new 
     # machine      # machine
Line 323  sub sso_login { Line 342  sub sso_login {
  } else {   } else {
     # need to login them in, so generate the need data that      # need to login them in, so generate the need data that
     # migrate expects to do login      # 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,        'domain'    => $domain,
       'username'  => $user,        'username'  => $user,
       'server'    => $r->dir_config('lonHostID'),        'server'    => $r->dir_config('lonHostID'),
Line 380  sub sso_login { Line 407  sub sso_login {
 sub handler {  sub handler {
     my $r = shift;      my $r = shift;
     my $requrl=$r->uri;      my $requrl=$r->uri;
     if (&Apache::lonnet::is_domainimage($requrl)) {  
       if ($requrl =~ m{^/res/adm/pages/[^/]+\.(gif|png)$}) {
         return OK;          return OK;
     }      }
   
     if ($requrl =~ m{^/res/adm/pages/[^/]+\.(gif|png)$}) {      if (&Apache::lonnet::is_domainimage($requrl)) {
         return OK;          return OK;
     }      }
   
     my $handle = &Apache::lonnet::check_for_valid_session($r);      my %user;
       my $handle = &Apache::lonnet::check_for_valid_session($r,undef,\%user);
   
     my $result = &sso_login($r,$handle);      my $result = &sso_login($r,$handle,$user{'name'});
     if (defined($result)) {      if (defined($result)) {
  return $result;   return $result;
     }      }
Line 399  sub handler { Line 428  sub handler {
   
     if ($handle eq '') {      if ($handle eq '') {
         unless (($requrl eq '/adm/switchserver') && (!$r->is_initial_req())) {          unless (($requrl eq '/adm/switchserver') && (!$r->is_initial_req())) {
     $r->log_reason("Cookie $handle not valid", $r->filename);      $r->log_reason("Cookie not valid", $r->filename);
         }          }
     } elsif ($handle ne '') {      } elsif ($handle ne '') {
   
Line 477  sub handler { Line 506  sub handler {
                 $checkexempt = 1;                      $checkexempt = 1;    
             }              }
         }          }
           if ($env{'user.noloadbalance'} eq $r->dir_config('lonHostID')) {
               $checkexempt = 1;
           }
         unless ($checkexempt) {          unless ($checkexempt) {
             ($is_balancer,$otherserver) =              ($is_balancer,$otherserver) =
                 &Apache::lonnet::check_loadbalancing($env{'user.name'},                  &Apache::lonnet::check_loadbalancing($env{'user.name'},

Removed from v.1.144  
changed lines
  Added in v.1.149


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>