Skip to content

Commit 37e173f

Browse files
committed
Add a configuration option in webwork2.mojolicious.dist.yml for allowing unsecured rpc usage.
The option allow_unsecured_rpc (which defaults to off) allows the html2xml and render_rpc endpoints to be used without cookies, and thus skipping two factor authentication. This should never be enabled for a typical webwork server. This should only be enabled if you want to allow serving content via these endpoints to links in external websites with usernames and passwords embedded in them such as for PreTeXt textbooks.
1 parent eec4643 commit 37e173f

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

conf/webwork2.mojolicious.dist.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,3 +239,10 @@ debug:
239239
hardcopy:
240240
# If 1, don't delete temporary files created when a hardcopy is generated.
241241
preserve_temp_files: 0
242+
243+
# Set this to 1 to allow the html2xml and render_rpc endpoints to disable
244+
# cookies and thus skip two factor authentication. This should never be enabled
245+
# for a typical webwork server. This should only be enabled if you want to
246+
# allow serving content via these endpoints to links in external websites with
247+
# usernames and passwords embedded in them such as for PreTeXt textbooks.
248+
allow_unsecured_rpc: 0

lib/WeBWorK.pm

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,13 @@ async sub dispatch ($c) {
9191
if ($c->current_route =~ /^(render_rpc|instructor_rpc|html2xml)$/) {
9292
$c->{rpc} = 1;
9393
94-
$c->stash(disable_cookies => 1) if $c->current_route eq 'render_rpc' && $c->param('disableCookies');
94+
$c->stash(disable_cookies => 1)
95+
if $c->current_route eq 'render_rpc' && $c->param('disableCookies') && $c->config('allow_unsecured_rpc');
9596
9697
# This provides compatibility for legacy html2xml parameters.
9798
# This should be deleted when the html2xml endpoint is removed.
9899
if ($c->current_route eq 'html2xml') {
99-
$c->stash(disable_cookies => 1);
100+
$c->stash(disable_cookies => 1) if $c->config('allow_unsecured_rpc');
100101
for ([ 'userID', 'user' ], [ 'course_password', 'passwd' ], [ 'session_key', 'key' ]) {
101102
$c->param($_->[1], $c->param($_->[0])) if defined $c->param($_->[0]) && !defined $c->param($_->[1]);
102103
}

0 commit comments

Comments
 (0)