[LON-CAPA-cvs] cvs: loncom /interface domainprefs.pm

raeburn raeburn at source.lon-capa.org
Wed Dec 6 20:36:11 EST 2017


raeburn		Thu Dec  7 01:36:11 2017 EDT

  Modified files:              
    /loncom/interface	domainprefs.pm 
  Log:
  - Bug 6754 LTI Integration
    - Default nonce lifetime for LON-CAPA as LTI Provider is 300s.
    - Domain configuration to set nonce lifetime for each Tool Provider
      when LON-CAPA is LTI Consumer (used to validate requests from 
      Tool Provider for a roster or to store a grade (default is 300s).
  
  
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.321 loncom/interface/domainprefs.pm:1.322
--- loncom/interface/domainprefs.pm:1.321	Wed Dec  6 23:41:19 2017
+++ loncom/interface/domainprefs.pm	Thu Dec  7 01:36:11 2017
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set domain-wide configuration settings
 #
-# $Id: domainprefs.pm,v 1.321 2017/12/06 23:41:19 raeburn Exp $
+# $Id: domainprefs.pm,v 1.322 2017/12/07 01:36:11 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -4112,12 +4112,13 @@
         for (my $i=0; $i<@items; $i++) {
             $css_class = $itemcount%2?' class="LC_odd_row"':'';
             my $item = $ordered{$items[$i]};
-            my ($title,$key,$secret,$url,$imgsrc);
+            my ($title,$key,$secret,$url,$lifetime,$imgsrc);
             if (ref($settings->{$item}) eq 'HASH') {
                 $title = $settings->{$item}->{'title'};
                 $url = $settings->{$item}->{'url'};
                 $key = $settings->{$item}->{'key'};
                 $secret = $settings->{$item}->{'secret'};
+                $lifetime = $settings->{$item}->{'lifetime'};
                 my $image = $settings->{$item}->{'image'};
                 if ($image ne '') {
                     $imgsrc = '<img src="'.$image.'" alt="'.&mt('Tool Provider icon').'" />';
@@ -4153,6 +4154,9 @@
                 '<span class="LC_nobreak">'.$lt{'key'}.':'.
                 '<input type="text" size="25" name="ltitools_key_'.$i.'" value="'.$key.'" /></span> '.
                 (' 'x2).
+                '<span class="LC_nobreak">'.$lt{'lifetime'}.':'.
+                '<input type="text" size="5" name="ltitools_lifetime_'.$i.'" value="'.$lifetime.'" /></span> '.
+                (' 'x2).
                 '<span class="LC_nobreak">'.$lt{'secret'}.':'.
                 '<input type="password" size="20" name="ltitools_secret_'.$i.'" value="'.$secret.'" />'.
                 '<label><input type="checkbox" name="visible" onclick="if (this.checked) { this.form.ltitools_secret_'.$i.'.type='."'text'".' } else { this.form.ltitools_secret_'.$i.'.type='."'password'".' }" />'.&mt('Visible input').'</label>'.
@@ -4353,6 +4357,8 @@
                   (' 'x2).
                   '<span class="LC_nobreak">'.$lt{'key'}.':<input type="text" size="25" name="ltitools_add_key" value="" /></span> '."\n".
                   (' 'x2).
+                  '<span class="LC_nobreak">'.$lt{'lifetime'}.':<input type="text" size="5" name="ltitools_add_lifetime" value="300" /></span> '."\n".
+                  (' 'x2).
                   '<span class="LC_nobreak">'.$lt{'secret'}.':<input type="password" size="20" name="ltitools_add_secret" value="" />'.
                   '<label><input type="checkbox" name="visible" onclick="if (this.checked) { this.form.ltitools_add_secret.type='."'text'".' } else { this.form.ltitools_add_secret.type='."'password'".' }" />'.&mt('Visible input').'</label></span> '."\n".
                   '</fieldset>'.
@@ -4382,7 +4388,7 @@
                 );
     my %defaulttimes = (
                      'passback' => '7',
-                     'roster' => '300',
+                     'roster'   => '300',
                    );
     foreach my $extra ('passback','roster') {
         my $onclick = ' onclick="toggleLTITools(this.form,'."'$extra','add'".');"';
@@ -4453,6 +4459,7 @@
                                           'msgtype'        => 'Message Type',
                                           'url'            => 'URL',
                                           'key'            => 'Key',
+                                          'lifetime'       => 'Nonce lifetime (s)',
                                           'secret'         => 'Secret',
                                           'icon'           => 'Icon',   
                                           'user'           => 'Username:domain',
@@ -4569,7 +4576,7 @@
                   '<span class="LC_nobreak">'.$lt{'version'}.':<select name="lti_version_add">'.
                   '<option value="LTI-1p0" selected="selected">1.1</option></select></span> '."\n".
                   (' 'x2).
-                  '<span class="LC_nobreak">'.$lt{'lifetime'}.':<input type="text" size="5" name="lti_lifetime_add" value="" /></span> '."\n".
+                  '<span class="LC_nobreak">'.$lt{'lifetime'}.':<input type="text" size="5" name="lti_lifetime_add" value="300" /></span> '."\n".
                   '<br /><br />'.
                   '<span class="LC_nobreak">'.$lt{'key'}.':<input type="text" size="25" name="lti_key_add" value="" /></span> '."\n".
                   (' 'x2).
@@ -4587,7 +4594,7 @@
                                           'version'   => 'LTI Version',
                                           'url'       => 'URL',
                                           'key'       => 'Key',
-                                          'lifetime'  => 'Nonce lifetime (seconds)',
+                                          'lifetime'  => 'Nonce lifetime (s)',
                                           'consumer'  => 'LTI Consumer', 
                                           'secret'    => 'Secret',
                                           'email'     => 'Email address',
@@ -10644,8 +10651,11 @@
                 $allpos[$position] = $newid;
             }
             $changes{$newid} = 1;
-            foreach my $item ('title','url','key','secret') {
+            foreach my $item ('title','url','key','secret','lifetime') {
                 $env{'form.ltitools_add_'.$item} =~ s/(`)/'/g;
+                if ($item eq 'lifetime') {
+                    $env{'form.ltitools_add_'.$item} =~ s/[^\d.]//g;
+                }
                 if ($env{'form.ltitools_add_'.$item}) {
                     if (($item eq 'key') || ($item eq 'secret')) {
                         $encconfig{$newid}{$item} = $env{'form.ltitools_add_'.$item};
@@ -10768,7 +10778,7 @@
                 } else {
                     my $newpos = $env{'form.ltitools_'.$itemid};
                     $newpos =~ s/\D+//g;
-                    foreach my $item ('title','url') {
+                    foreach my $item ('title','url','lifetime') {
                         $confhash{$itemid}{$item} = $env{'form.ltitools_'.$item.'_'.$i};
                         if ($domconfig{$action}{$itemid}{$item} ne $confhash{$itemid}{$item}) {
                             $changes{$itemid} = 1;
@@ -11032,7 +11042,7 @@
                     $resulttext .= '</li><ul>';
                     my $position = $pos + 1;
                     $resulttext .= '<li>'.&mt('Order: [_1]',$position).'</li>';
-                    foreach my $item ('version','msgtype','url') {
+                    foreach my $item ('version','msgtype','url','lifetime') {
                         if ($confhash{$itemid}{$item} ne '') {
                             $resulttext .= '<li>'.$lt{$item}.': '.$confhash{$itemid}{$item}.'</li>';
                         }




More information about the LON-CAPA-cvs mailing list