Diff for /loncom/lti/ltiauth.pm between versions 1.4 and 1.5

version 1.4, 2018/01/03 22:04:19 version 1.5, 2018/01/12 20:42:38
Line 142  sub handler { Line 142  sub handler {
 # (b) from tail of requested URL (after /adm/lti) if it has format of a symb    # (b) from tail of requested URL (after /adm/lti) if it has format of a symb  
 # (c) from tail of requested URL (after /adm/lti) if it has format of a map   # (c) from tail of requested URL (after /adm/lti) if it has format of a map 
 # (d) from tail of requested URL (after /adm/lti) if it has format /domain/courseID  # (d) from tail of requested URL (after /adm/lti) if it has format /domain/courseID
 # (e) from tail of requested URL (after /adm/lti) if it has format /tiny/domain/...  # (e) from tail of requested URL (after /adm/lti) if it has format /tiny/domain/\w+
 # i.e., a shortened URL (see bug #6400) -- not implemented yet.     #     i.e., a shortened URL (see bug #6400).
 # (f) same as user's domain   # (f) same as user's domain 
 #  #
 # Request invalid if custom_coursedomain is defined and is inconsistent with  # Request invalid if custom_coursedomain is defined and is inconsistent with
Line 181  sub handler { Line 181  sub handler {
                 $symb = $tail;                  $symb = $tail;
                 $symb =~ s{^/+}{};                  $symb =~ s{^/+}{};
             }              }
 #FIXME Need to handle encrypted URLs   #FIXME Need to handle encrypted URLs
         } elsif ($tail =~ m{^/($match_domain)/($match_courseid)$}) {          } elsif ($tail =~ m{^/($match_domain)/($match_courseid)$}) {
             ($urlcdom,$urlcnum) = ($1,$2);              ($urlcdom,$urlcnum) = ($1,$2);
             if (($cdom ne '') && ($cdom ne $urlcdom)) {              if (($cdom ne '') && ($cdom ne $urlcdom)) {
                 &invalid_request($r,4);                  &invalid_request($r,4);
                 return OK;                  return OK;
             }              }
           } elsif ($tail =~ m{^/tiny/($match_domain)/(\w+)$}) {
               ($urlcdom,my $key) = ($1,$2);
               if (($cdom ne '') && ($cdom ne $urlcdom)) {
                   &invalid_request($r,5);
                   return OK;
               }
               my $tinyurl;
               my ($result,$cached)=&Apache::lonnet::is_cached_new('tiny',$urlcdom."\0".$key);
               if (defined($cached)) {
                   $tinyurl = $result;
               } else {
                   my $configuname = &Apache::lonnet::get_domainconfiguser($urlcdom);
                   my %currtiny = &Apache::lonnet::get('tiny',[$key],$urlcdom,$configuname);
                   if ($currtiny{$key} ne '') {
                       $tinyurl = $currtiny{$key};
                       &Apache::lonnet::do_cache_new('tiny',$urlcdom."\0".$key,$currtiny{$key},600);
                   }
               }
               if ($tinyurl ne '') {
                   $urlcnum = (split(/\&/,$tinyurl))[0];
               }
         }          }
         if (($cdom eq '') && ($urlcdom ne '')) {           if (($cdom eq '') && ($urlcdom ne '')) { 
             my $cprimary_id = &Apache::lonnet::domain($urlcdom,'primary');              my $cprimary_id = &Apache::lonnet::domain($urlcdom,'primary');
Line 217  sub handler { Line 238  sub handler {
     
     my %lti = &Apache::lonnet::get_domain_lti($cdom,'provider');      my %lti = &Apache::lonnet::get_domain_lti($cdom,'provider');
     unless (keys(%lti) > 0) {      unless (keys(%lti) > 0) {
         &invalid_request($r,5);          &invalid_request($r,6);
         return OK;          return OK;
     }      }
     my %lti_by_key;      my %lti_by_key;
Line 265  sub handler { Line 286  sub handler {
 # configuration in LON-CAPA for that LTI Consumer.  # configuration in LON-CAPA for that LTI Consumer.
 #  #
     unless (($itemid) && (ref($lti{$itemid}) eq 'HASH')) {      unless (($itemid) && (ref($lti{$itemid}) eq 'HASH')) {
         &invalid_request($r,6);          &invalid_request($r,7);
         return OK;          return OK;
     }      }
   
Line 275  sub handler { Line 296  sub handler {
 #  #
     unless (&LONCAPA::ltiutils::check_nonce($params->{'oauth_nonce'},$params->{'oauth_timestamp'},      unless (&LONCAPA::ltiutils::check_nonce($params->{'oauth_nonce'},$params->{'oauth_timestamp'},
                                             $lti{$itemid}{'lifetime'},$cdom,$r->dir_config('lonLTIDir'))) {                                              $lti{$itemid}{'lifetime'},$cdom,$r->dir_config('lonLTIDir'))) {
         &invalid_request($r,7);          &invalid_request($r,8);
         return OK;          return OK;
     }      }
   
Line 311  sub handler { Line 332  sub handler {
 # (b) from tail of requested URL (after /adm/lti) if it has format of a symb  # (b) from tail of requested URL (after /adm/lti) if it has format of a symb
 # (c) from tail of requested URL (after /adm/lti) if it has format of a map  # (c) from tail of requested URL (after /adm/lti) if it has format of a map
 # (d) from tail of requested URL (after /adm/lti) if it has format /domain/courseID  # (d) from tail of requested URL (after /adm/lti) if it has format /domain/courseID
 # (e) from tail of requested URL (after /adm/lti) if it has format /tiny/domain/...  # (e) from tail of requested URL (after /adm/lti) if it has format /tiny/domain/\w+
 # i.e., a shortened URL (see bug #6400) -- not implemented yet.  #     i.e., a shortened URL (see bug #6400).
 #  #
 # If Consumer course included in POSTed data points as a target course which  # If Consumer course included in POSTed data points as a target course which
 # has a format which matches a LON-CAPA courseID, but the course does not  # has a format which matches a LON-CAPA courseID, but the course does not
Line 335  sub handler { Line 356  sub handler {
             if ($consumers{$sourcecrs} =~ /^$match_courseid$/) {              if ($consumers{$sourcecrs} =~ /^$match_courseid$/) {
                 my $crshome = &Apache::lonnet::homeserver($consumers{$sourcecrs},$cdom);                  my $crshome = &Apache::lonnet::homeserver($consumers{$sourcecrs},$cdom);
                 if ($crshome =~ /(con_lost|no_host|no_such_host)/) {                  if ($crshome =~ /(con_lost|no_host|no_such_host)/) {
                     &invalid_request($r,8);                      &invalid_request($r,9);
                     return OK;                      return OK;
                 } else {                  } else {
                     $posscnum = $consumers{$sourcecrs};                      $posscnum = $consumers{$sourcecrs};
Line 347  sub handler { Line 368  sub handler {
     if ($urlcnum ne '') {      if ($urlcnum ne '') {
         if ($posscnum ne '') {          if ($posscnum ne '') {
             if ($posscnum ne $urlcnum) {              if ($posscnum ne $urlcnum) {
                 &invalid_request($r,9);                  &invalid_request($r,10);
                 return OK;                  return OK;
             } else {              } else {
                 $cnum = $posscnum;                  $cnum = $posscnum;
Line 355  sub handler { Line 376  sub handler {
         } else {          } else {
             my $crshome = &Apache::lonnet::homeserver($urlcnum,$cdom);              my $crshome = &Apache::lonnet::homeserver($urlcnum,$cdom);
             if ($crshome =~ /(con_lost|no_host|no_such_host)/) {              if ($crshome =~ /(con_lost|no_host|no_such_host)/) {
                 &invalid_request($r,10);                  &invalid_request($r,11);
                 return OK;                  return OK;
             } else {              } else {
                 $cnum = $urlcnum;                  $cnum = $urlcnum;
Line 427  sub handler { Line 448  sub handler {
 #FIXME Do user creation here.  #FIXME Do user creation here.
                 return OK                  return OK
             } else {              } else {
                 &invalid_request($r,11);                  &invalid_request($r,12);
                 return OK;                  return OK;
             }               } 
         }           } 
     } else {      } else {
         &invalid_request($r,12);          &invalid_request($r,13);
         return OK;          return OK;
     }      }
   
Line 448  sub handler { Line 469  sub handler {
 #FIXME Create a new LON-CAPA course here.  #FIXME Create a new LON-CAPA course here.
             return OK;              return OK;
         } else {          } else {
             &invalid_request($r,13);              &invalid_request($r,14);
             return OK;               return OK; 
         }          }
     }      }
Line 482  sub handler { Line 503  sub handler {
 #FIXME Do self-enrollment here  #FIXME Do self-enrollment here
             return OK;              return OK;
         } else {          } else {
             &invalid_request($r,14);              &invalid_request($r,15);
             return OK;              return OK;
         }          }
     }      }

Removed from v.1.4  
changed lines
  Added in v.1.5


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