Pass hostname to LTI XModule
Necessary for RFC compliance with oauthlib
This commit is contained in:
@@ -36,6 +36,7 @@ def test_system():
|
||||
user=Mock(),
|
||||
filestore=fs.osfs.OSFS(os.path.join(TEST_DIR, "test_files")),
|
||||
debug=True,
|
||||
hostname="edx.org",
|
||||
xqueue={'interface': xqueue_interface, 'construct_callback': calledback_url, 'default_queuename': 'testqueue', 'waittime': 10},
|
||||
node_path=os.environ.get("NODE_PATH", "/usr/local/lib/node_modules"),
|
||||
anonymous_student_id='student',
|
||||
|
||||
@@ -6,7 +6,7 @@ http://www.imsglobal.org/LTI/v1p1p1/ltiIMGv1p1p1.html
|
||||
"""
|
||||
|
||||
import logging
|
||||
import oauthlib
|
||||
import oauthlib.oauth1
|
||||
import urllib
|
||||
|
||||
from xmodule.editing_module import MetadataOnlyEditingDescriptor
|
||||
@@ -212,8 +212,11 @@ class LTIModule(LTIFields, XModule):
|
||||
# appending custom parameter for signing
|
||||
body.update(custom_parameters)
|
||||
|
||||
# This is needed for body encoding:
|
||||
headers = {'Content-Type': 'application/x-www-form-urlencoded'}
|
||||
headers = {
|
||||
'Host': self.system.HOSTNAME,
|
||||
# This is needed for body encoding:
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
}
|
||||
|
||||
__, headers, __ = client.sign(
|
||||
unicode(self.launch_url),
|
||||
|
||||
@@ -62,6 +62,7 @@ def get_test_system(course_id=''):
|
||||
user=Mock(is_staff=False),
|
||||
filestore=Mock(),
|
||||
debug=True,
|
||||
hostname="edx.org",
|
||||
xqueue={'interface': None, 'callback_url': '/', 'default_queuename': 'testqueue', 'waittime': 10, 'construct_callback' : Mock(side_effect="/")},
|
||||
node_path=os.environ.get("NODE_PATH", "/usr/local/lib/node_modules"),
|
||||
xblock_field_data=lambda descriptor: descriptor._field_data,
|
||||
|
||||
@@ -833,7 +833,7 @@ class ModuleSystem(Runtime):
|
||||
def __init__(
|
||||
self, ajax_url, track_function, get_module, render_template,
|
||||
replace_urls, xblock_field_data, user=None, filestore=None,
|
||||
debug=False, xqueue=None, publish=None, node_path="",
|
||||
debug=False, hostname="", xqueue=None, publish=None, node_path="",
|
||||
anonymous_student_id='', course_id=None,
|
||||
open_ended_grading_interface=None, s3_interface=None,
|
||||
cache=None, can_execute_unsafe_code=None, replace_course_urls=None,
|
||||
@@ -897,6 +897,7 @@ class ModuleSystem(Runtime):
|
||||
self.get_module = get_module
|
||||
self.render_template = render_template
|
||||
self.DEBUG = self.debug = debug
|
||||
self.HOSTNAME = self.hostname = hostname
|
||||
self.seed = user.id if user is not None else 0
|
||||
self.replace_urls = replace_urls
|
||||
self.node_path = node_path
|
||||
|
||||
@@ -347,6 +347,8 @@ def get_module_for_descriptor_internal(user, descriptor, field_data_cache, cours
|
||||
filestore=descriptor.system.resources_fs,
|
||||
get_module=inner_get_module,
|
||||
user=user,
|
||||
debug=settings.DEBUG,
|
||||
hostname=settings.SITE_NAME,
|
||||
# TODO (cpennington): This should be removed when all html from
|
||||
# a module is coming through get_html and is therefore covered
|
||||
# by the replace_static_urls code below
|
||||
@@ -380,7 +382,6 @@ def get_module_for_descriptor_internal(user, descriptor, field_data_cache, cours
|
||||
|
||||
# pass position specified in URL to module through ModuleSystem
|
||||
system.set('position', position)
|
||||
system.set('DEBUG', settings.DEBUG)
|
||||
if settings.MITX_FEATURES.get('ENABLE_PSYCHOMETRICS'):
|
||||
system.set(
|
||||
'psychometrics_handler', # set callback for updating PsychometricsData
|
||||
|
||||
Reference in New Issue
Block a user