Skip to content

Commit bf11f98

Browse files
authored
Merge pull request #2447 from somiaj/add-lti-config-items
Add more configurable LTI variables to config page.
2 parents d2bb66e + ae273f8 commit bf11f98

12 files changed

Lines changed: 138 additions & 14 deletions

File tree

conf/authen_LTI.conf.dist

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,19 +169,43 @@ $LTIMassUpdateInterval = 86400; #in seconds
169169
# the tab will not be shown. Note that the default values for the variables that will be shown
170170
# in the LTI tab are the values that are set above. Further note that only the commented out
171171
# variables listed below may be added to the LTI config tab. In addition, only the variables that
172-
# pertain to the active LTI version will be shown in the tab.
172+
# pertain to the active LTI version will be shown in the tab. Warning: Allowing users to modify
173+
# the BasicConsumerSecret for LTI 1.1 or the IDs, URLs, etc for LTI 1.3 can expose the values
174+
# of the variables and allow users to lock themselves out of logging in via an LMS.
173175
@LTIConfigVariables = (
174176
#'LTI{v1p1}{LMS_name}',
175177
#'LTI{v1p3}{LMS_name}',
176178
#'LTI{v1p1}{LMS_url}',
177179
#'LTI{v1p3}{LMS_url}',
178180
#'external_auth',
179181
#'LTIGradeMode',
182+
#'LTIGradeOnSubmit',
183+
#'LTIMassUpdateInterval',
180184
#'LMSManageUserData',
185+
#'LTI{v1p1}{BasicConsumerSecret}',
186+
#'LTI{v1p3}{PlatformID}',
187+
#'LTI{v1p3}{ClientID}',
188+
#'LTI{v1p3}{DeploymentID}',
189+
#'LTI{v1p3}{PublicKeysetURL}',
190+
#'LTI{v1p3}{AccessTokenURL}',
191+
#'LTI{v1p3}{AccessTokenAUD}',
192+
#'LTI{v1p3}{AuthReqURL}',
181193
#'debug_lti_parameters',
182194
#'lms_context_id'
183195
);
184196

197+
# By default only admin users can modify the LTI secrets and lms_context_id. The following
198+
# permissions need to be modified to allow other users the permission to modify the values.
199+
#$permissionLevels{'change_config_LTI{v1p1}{BasicConsumerSecret}'} = "admin",
200+
#$permissionLevels{'change_config_LTI{v1p3}{PlatformID}'} = "admin",
201+
#$permissionLevels{'change_config_LTI{v1p3}{ClientID}'} = "admin",
202+
#$permissionLevels{'change_config_LTI{v1p3}{DeploymentID}'} = "admin",
203+
#$permissionLevels{'change_config_LTI{v1p3}{PublicKeysetURL}'} = "admin",
204+
#$permissionLevels{'change_config_LTI{v1p3}{AccessTokenURL}'} = "admin",
205+
#$permissionLevels{'change_config_LTI{v1p3}{AccessTokenAUD}'} = "admin",
206+
#$permissionLevels{'change_config_LTI{v1p3}{AuthReqURL}'} = "admin",
207+
#$permissionLevels{'change_config_lms_context_id'} = "admin",
208+
185209
# Note that the lms_context_id is actually a database setting. It must be set for a course in
186210
# order for the instructor to utilize LTI content selection. This can also be set in the admin
187211
# course.

conf/defaults.config

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,15 @@ $authen{admin_module} = ['WeBWorK::Authen::Basic_TheLastOption'];
874874
# sufficient to change a configuration setting.
875875

876876
#change_config_courseTitle => "admin",
877-
change_config_lms_context_id => "admin",
877+
change_config_lms_context_id => "admin",
878+
'change_config_LTI{v1p1}{BasicConsumerSecret}' => "admin",
879+
'change_config_LTI{v1p3}{PlatformID}' => "admin",
880+
'change_config_LTI{v1p3}{ClientID}' => "admin",
881+
'change_config_LTI{v1p3}{DeploymentID}' => "admin",
882+
'change_config_LTI{v1p3}{PublicKeysetURL}' => "admin",
883+
'change_config_LTI{v1p3}{AccessTokenURL}' => "admin",
884+
'change_config_LTI{v1p3}{AccessTokenAUD}' => "admin",
885+
'change_config_LTI{v1p3}{AuthReqURL}' => "admin",
878886

879887
# Do not confuse the permission to change a configuration permission with
880888
# the actual permission as in the following example. If this us uncommented,

lib/WeBWorK/ConfigObject.pm

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package WeBWorK::ConfigObject;
22
use Mojo::Base -signatures;
33

44
# Base object class for all config objects
5+
use constant SECRET_STRING => '*****';
56

67
sub new ($class, $data, $c) {
78
return bless {
@@ -13,7 +14,7 @@ sub new ($class, $data, $c) {
1314

1415
# Only input is a value to display, and should produce an html string.
1516
sub display_value ($self, $val) {
16-
return $val;
17+
return $self->{secret} ? SECRET_STRING : $val;
1718
}
1819

1920
# This should return the value to compare to the new value. This is *not* what is displayed.
@@ -47,16 +48,16 @@ sub convert_newval_source ($self, $use_current) {
4748
# will be the value of the perl variable, and newval will be whatever an entry widget produces.
4849
sub save_string ($self, $oldval, $use_current = 0) {
4950
my $newval = $self->convert_newval_source($use_current);
50-
return '' if $self->comparison_value($oldval) eq $newval;
51+
return '' if $self->comparison_value($oldval) eq $newval || ($self->{secret} && $newval eq SECRET_STRING);
5152

5253
$newval =~ s/['"`]//g;
5354
return "\$$self->{var} = '$newval';\n";
5455
}
5556

5657
# A widget to interact with the user
57-
sub entry_widget ($self, $default) {
58+
sub entry_widget ($self, $default, $is_secret = 0) {
5859
return $self->{c}->text_field(
59-
$self->{name} => $default,
60+
$self->{name} => $is_secret ? SECRET_STRING : $default,
6061
id => $self->{name},
6162
size => $self->{width} || 15,
6263
class => 'form-control form-control-sm'

lib/WeBWorK/ConfigObject/boolean.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ sub save_string ($self, $oldval, $use_current = 0) {
2929
return "\$$self->{var} = $newval;\n";
3030
}
3131

32-
sub entry_widget ($self, $default) {
32+
sub entry_widget ($self, $default, $is_secret = 0) {
3333
return $self->{c}->select_field(
3434
$self->{name} => [
3535
[ $self->{c}->maketext('True') => 1, $default == 1 ? (selected => undef) : () ],

lib/WeBWorK/ConfigObject/checkboxlist.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ sub comparison_value ($self, $val) {
4444
return join(',', @{ $val // [] });
4545
}
4646

47-
sub entry_widget ($self, $default) {
47+
sub entry_widget ($self, $default, $is_secret = 0) {
4848
my $c = $self->{c};
4949
return $c->c(
5050
map {

lib/WeBWorK/ConfigObject/list.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ sub save_string ($self, $oldval, $use_current = 0) {
4343
return "\$$self->{var} = [" . join(',', map {"'$_'"} map { $_ =~ s/['"`]//gr } split(',', $newval)) . "];\n";
4444
}
4545

46-
sub entry_widget ($self, $default) {
46+
sub entry_widget ($self, $default, $is_secret = 0) {
4747
my $str = join(', ', @{ $default // [] });
4848
return $self->{c}->text_area(
4949
$self->{name} => $str =~ /\S/ ? $str : '',

lib/WeBWorK/ConfigObject/lms_context_id.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ sub save_string ($self, $oldval, $use_current = 0) {
101101

102102
# This ensures that the input for this setting always shows what is in the database. If the form is submitted, and the
103103
# requested context id is rejected above, then that rejected value should not be shown when the page reloads.
104-
sub entry_widget ($self, $default) {
104+
sub entry_widget ($self, $default, $is_secret = 0) {
105105
$self->{c}->param($self->{name}, $default);
106106
return $self->SUPER::entry_widget($default);
107107
}

lib/WeBWorK/ConfigObject/permission.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ sub save_string ($self, $oldval, $use_current = 0) {
3434
return "\$$self->{var} = '$newval';\n";
3535
}
3636

37-
sub entry_widget ($self, $default) {
37+
sub entry_widget ($self, $default, $is_secret = 0) {
3838
my $c = $self->{c};
3939

4040
# The value of a permission can be undefined (for nobody), a standard permission number, or some other number

lib/WeBWorK/ConfigObject/permission_checkboxlist.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ sub comparison_value ($self, $val) {
5151
return join(',', @{ $val // [] });
5252
}
5353

54-
sub entry_widget ($self, $default) {
54+
sub entry_widget ($self, $default, $is_secret = 0) {
5555
my $c = $self->{c};
5656
$default = role_and_above($self->{c}->ce->{userRoles}, $default) unless ref($default) eq 'ARRAY';
5757
return $c->c(

lib/WeBWorK/ConfigObject/popuplist.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ sub save_string ($self, $oldval, $use_current = 0) {
2929
return ("\$$self->{var} = '$newval';\n");
3030
}
3131

32-
sub entry_widget ($self, $default) {
32+
sub entry_widget ($self, $default, $is_secret = 0) {
3333
my $c = $self->{c};
3434
return $c->select_field(
3535
$self->{name} => [

0 commit comments

Comments
 (0)