Diff for /loncom/auth/lonshibauth.pm between versions 1.14 and 1.17

version 1.14, 2021/12/12 20:49:26 version 1.17, 2022/09/17 23:38:50
Line 202  information, and the destination is a de Line 202  information, and the destination is a de
 then the LTI number, type (c or d), and tiny URL will be saved as the  then the LTI number, type (c or d), and tiny URL will be saved as the
 linkprot item in a token file.  linkprot item in a token file.
   
   =item set_mailtoken()
   
   Inputs: 2
   $r - request object
   $lonhost - hostID of current server
   
   Output: 1
   $querystring - query string to append to URL
   when redirecting.
   
   Called if requested URL is /adm/email, dual SSO and non-SSO login
   are supported by /adm/login and original query string contains values 
   for elements: display, username and domain, which will then be
   stored in the token file on the server to support direct access
   to a specific message sent to the user.
   
 =back  =back
   
 =cut  =cut
Line 239  sub handler { Line 255  sub handler {
         }          }
         my $dest = $protocol.'://'.$hostname.$target;          my $dest = $protocol.'://'.$hostname.$target;
         if ($target eq '/adm/login') {          if ($target eq '/adm/login') {
              my $querystring = &set_token($r,$lonhost);               my $uri = $r->uri;
                my $querystring;
                if (($uri eq '/adm/email') && ($r->args ne '')) {
                    $querystring = &set_mailtoken($r,$lonhost);
                } else {
                    $querystring = &set_token($r,$lonhost);
                }
              if ($querystring ne '') {               if ($querystring ne '') {
                  $dest .= '?'.$querystring;                   $dest .= '?'.$querystring;
              }               }
Line 250  sub handler { Line 272  sub handler {
                 if ($querystring ne '') {                  if ($querystring ne '') {
                     $dest .= '?'.$querystring;                      $dest .= '?'.$querystring;
                 }                  }
               } elsif ((&Apache::lonnet::get_saml_landing()) &&
                        ($uri eq '/adm/email') && ($r->args ne '')) {
                   my $querystring = &set_mailtoken($r,$lonhost);
                   if ($querystring ne '') {
                       $dest .= '?'.$querystring;
                   }
             } else {              } else {
                 if ($r->args ne '') {                  if ($r->args ne '') {
                     $dest .= (($dest=~/\?/)?'&':'?').$r->args;                      $dest .= (($dest=~/\?/)?'&':'?').$r->args;
Line 293  sub set_token { Line 321  sub set_token {
                 &Apache::lonacc::get_posted_cgi($r,['linkkey']);                  &Apache::lonacc::get_posted_cgi($r,['linkkey']);
             }              }
         }          }
           unless (($r->is_initial_req()) || ($env{'form.ltoken'}) ||
                   ($env{'form.linkkey'})) {
               return;
           }
     }      }
     my $extras;      my $extras;
     foreach my $name (@names) {      foreach my $name (@names) {
Line 302  sub set_token { Line 334  sub set_token {
                 &Apache::lonnet::tmpdel($env{'form.ltoken'});                  &Apache::lonnet::tmpdel($env{'form.ltoken'});
                 if ($info{'linkprot'}) {                  if ($info{'linkprot'}) {
                     $extras .= '&linkprot='.&escape($info{'linkprot'});                      $extras .= '&linkprot='.&escape($info{'linkprot'});
                       foreach my $item ('linkprotuser','linkprotexit') {
                           if ($info{$item} ne '') {
                               $extras .= '&'.$item.'='.&escape($info{$item});
                           }
                       }
                     last;                      last;
                 }                  }
             } else {              } else {
Line 323  sub set_token { Line 360  sub set_token {
                 $querystring .= '&'.$name.'='.$env{$key};                  $querystring .= '&'.$name.'='.$env{$key};
             }              }
         }          }
       }
       return $querystring;
   }
   
   sub set_mailtoken {
       my ($r,$lonhost) = @_;
       my $firsturl = $r->uri;
       my ($querystring,$ssotoken,$extras);
       &Apache::loncommon::get_unprocessed_cgi($r->args);
       my $extras;
       if (($env{'form.display'} ne '') &&
           ($env{'form.username'} =~ /^$match_username$/) &&
           ($env{'form.domain'} =~ /^$match_domain$/)) {  
           $extras .= '&display='.&escape($env{'form.display'}).
                      '&mailrecip='.&escape($env{'form.username'}.':'.$env{'form.domain'});
       }
       if (($firsturl ne '') || ($extras ne '')) {
           $extras .= ':sso';
           $ssotoken = &Apache::lonnet::reply('tmpput:'.&escape($firsturl).
                                              $extras,$lonhost);
           $querystring = 'sso='.$ssotoken;
       }
       if ($r->args ne '') {
           foreach my $key (sort(keys(%env))) {
               if ($key =~ /^form\.(.+)$/) {
                   my $name = $1;
                   next if (($name eq 'display') || ($name eq 'username') || ($name eq 'domain'));
                   $querystring .= '&'.$name.'='.$env{$key};
               }
           }
     }      }
     return $querystring;      return $querystring;
 }  }

Removed from v.1.14  
changed lines
  Added in v.1.17


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