Diff for /loncom/lti/ltiauth.pm between versions 1.32 and 1.36

version 1.32, 2022/02/06 21:37:00 version 1.36, 2022/04/06 21:44:49
Line 30  package Apache::ltiauth; Line 30  package Apache::ltiauth;
   
 use strict;  use strict;
 use LONCAPA qw(:DEFAULT :match);  use LONCAPA qw(:DEFAULT :match);
   use Encode;
 use Apache::Constants qw(:common :http);  use Apache::Constants qw(:common :http);
 use Apache::lonlocal;  use Apache::lonlocal;
 use Apache::lonnet;  use Apache::lonnet;
Line 63  sub handler { Line 64  sub handler {
     my $params = {};      my $params = {};
     foreach my $key (sort(keys(%env))) {      foreach my $key (sort(keys(%env))) {
         if ($key =~ /^form\.(.+)$/) {          if ($key =~ /^form\.(.+)$/) {
             $params->{$1} = $env{$key};              $params->{$1} = &Encode::decode('UTF-8',$env{$key});
         }          }
     }      }
 #  #
Line 143  sub handler { Line 144  sub handler {
 #  #
   
                         my ($itemid,$ltitype,%crslti,%lti_in_use);                          my ($itemid,$ltitype,%crslti,%lti_in_use);
                         $itemid = &get_lti_itemid($requri,$hostname,$params,$cdom,$cnum,'deeplink');                          $itemid = &get_lti_itemid($requri,$hostname,$params,$cdom,$cnum,'linkprot');
                         if ($itemid) {                          if ($itemid) {
                             %crslti = &Apache::lonnet::get_course_lti($cnum,$cdom,'provider');                              %crslti = &Apache::lonnet::get_course_lti($cnum,$cdom);
                         }                          }
                         if (($itemid) && (ref($crslti{$itemid}) eq 'HASH')) {                          if (($itemid) && (ref($crslti{$itemid}) eq 'HASH')) {
                             $ltitype = 'c';                              $ltitype = 'c';
Line 157  sub handler { Line 158  sub handler {
                                 return OK;                                  return OK;
                             }                              }
                         } else {                          } else {
                             $itemid = &get_lti_itemid($requri,$hostname,$params,$cdom,'','deeplink');                              $itemid = &get_lti_itemid($requri,$hostname,$params,$cdom,'','linkprot');
                             my %lti;                              my %lti;
                             if ($itemid) {                              if ($itemid) {
                                 %lti = &Apache::lonnet::get_domain_lti($cdom,'provider');                                  %lti = &Apache::lonnet::get_domain_lti($cdom,'linkprot');
                             }                              }
                             if (($itemid) && (ref($lti{$itemid}) eq 'HASH')) {                              if (($itemid) && (ref($lti{$itemid}) eq 'HASH')) {
                                 $ltitype = 'd';                                  $ltitype = 'd';
Line 185  sub handler { Line 186  sub handler {
                             }                              }
                             if ($ltiauth) {                              if ($ltiauth) {
                                 my $possuname;                                  my $possuname;
                                 my $mapuser = $crslti{$itemid}{'mapuser'};                                  my $mapuser = $lti_in_use{'mapuser'};
                                 if ($mapuser eq 'sourcedid') {                                  if ($mapuser eq 'sourcedid') {
                                     if ($params->{'lis_person_sourcedid'} =~ /^$match_username$/) {                                      if ($params->{'lis_person_sourcedid'} =~ /^$match_username$/) {
                                         $possuname = $params->{'lis_person_sourcedid'};                                          $possuname = $params->{'lis_person_sourcedid'};
Line 232  sub handler { Line 233  sub handler {
                                 }                                  }
                                 if ($lti_in_use{'notstudent'} eq 'reject') {                                  if ($lti_in_use{'notstudent'} eq 'reject') {
                                     &invalid_request($r,'Information for valid user missing from launch request');                                      &invalid_request($r,'Information for valid user missing from launch request');
                                       return OK;
                                 }                                  }
                             }                              }
                         }                          }
Line 1061  sub linkprot_session { Line 1063  sub linkprot_session {
     my ($is_balancer,$otherserver,$hosthere) = &check_balancer($r,$uname,$cdom);      my ($is_balancer,$otherserver,$hosthere) = &check_balancer($r,$uname,$cdom);
     if (($is_balancer) && (!$hosthere)) {      if (($is_balancer) && (!$hosthere)) {
         # login but immediately go to switch server          # login but immediately go to switch server
           &Apache::lonauth::success($r,$uname,$cdom,$uhome,'noredirect');
         $env{'form.origurl'} = $dest;          $env{'form.origurl'} = $dest;
         $env{'request.linkprot'} = $itemid.$ltitype.':'.$dest;          $env{'request.linkprot'} = $itemid.$ltitype.':'.$dest;
         $env{'request.deeplink.login'} = $dest;          $env{'request.deeplink.login'} = $dest;
Line 1126  sub invalid_request { Line 1129  sub invalid_request {
         '<h3>'.&mt('Invalid LTI launch request').'</h3>'.          '<h3>'.&mt('Invalid LTI launch request').'</h3>'.
         '<p class="LC_warning">'.          '<p class="LC_warning">'.
         &mt('Launch of LON-CAPA is unavailable from the "external tool" link you had followed in another web application.').          &mt('Launch of LON-CAPA is unavailable from the "external tool" link you had followed in another web application.').
         &mt('Launch failed for the following reason:').          ' '.&mt('Launch failed for the following reason:').
         '</p>'.          '</p>'.
         '<p class="LC_error">'.$msga'.</p>'.          '<p class="LC_error">'.$msg.'</p>'.
         &Apache::loncommon::end_page());          &Apache::loncommon::end_page());
     return;      return;
 }  }

Removed from v.1.32  
changed lines
  Added in v.1.36


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