--- loncom/lti/ltiauth.pm 2022/02/06 21:37:00 1.32 +++ loncom/lti/ltiauth.pm 2022/04/06 21:44:49 1.36 @@ -1,7 +1,7 @@ # The LearningOnline Network # Basic LTI Authentication Module # -# $Id: ltiauth.pm,v 1.32 2022/02/06 21:37:00 raeburn Exp $ +# $Id: ltiauth.pm,v 1.36 2022/04/06 21:44:49 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -30,6 +30,7 @@ package Apache::ltiauth; use strict; use LONCAPA qw(:DEFAULT :match); +use Encode; use Apache::Constants qw(:common :http); use Apache::lonlocal; use Apache::lonnet; @@ -63,7 +64,7 @@ sub handler { my $params = {}; foreach my $key (sort(keys(%env))) { if ($key =~ /^form\.(.+)$/) { - $params->{$1} = $env{$key}; + $params->{$1} = &Encode::decode('UTF-8',$env{$key}); } } # @@ -143,9 +144,9 @@ sub handler { # 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) { - %crslti = &Apache::lonnet::get_course_lti($cnum,$cdom,'provider'); + %crslti = &Apache::lonnet::get_course_lti($cnum,$cdom); } if (($itemid) && (ref($crslti{$itemid}) eq 'HASH')) { $ltitype = 'c'; @@ -157,10 +158,10 @@ sub handler { return OK; } } else { - $itemid = &get_lti_itemid($requri,$hostname,$params,$cdom,'','deeplink'); + $itemid = &get_lti_itemid($requri,$hostname,$params,$cdom,'','linkprot'); my %lti; 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')) { $ltitype = 'd'; @@ -185,7 +186,7 @@ sub handler { } if ($ltiauth) { my $possuname; - my $mapuser = $crslti{$itemid}{'mapuser'}; + my $mapuser = $lti_in_use{'mapuser'}; if ($mapuser eq 'sourcedid') { if ($params->{'lis_person_sourcedid'} =~ /^$match_username$/) { $possuname = $params->{'lis_person_sourcedid'}; @@ -232,6 +233,7 @@ sub handler { } if ($lti_in_use{'notstudent'} eq 'reject') { &invalid_request($r,'Information for valid user missing from launch request'); + return OK; } } } @@ -1061,6 +1063,7 @@ sub linkprot_session { my ($is_balancer,$otherserver,$hosthere) = &check_balancer($r,$uname,$cdom); if (($is_balancer) && (!$hosthere)) { # login but immediately go to switch server + &Apache::lonauth::success($r,$uname,$cdom,$uhome,'noredirect'); $env{'form.origurl'} = $dest; $env{'request.linkprot'} = $itemid.$ltitype.':'.$dest; $env{'request.deeplink.login'} = $dest; @@ -1126,9 +1129,9 @@ sub invalid_request { '

'.&mt('Invalid LTI launch request').'

'. '

'. &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:'). '

'. - '

'.$msga'.

'. + '

'.$msg.'

'. &Apache::loncommon::end_page()); return; }