Skip to content

Commit

Permalink
FIX lti launch to assignment not working
Browse files Browse the repository at this point in the history
There's two causes for this:
- assignment needs to be allowed as a parameter
- Canvas doesn't include the url query part when generating signatures

Looks like one of the updates we pulled for the lti library added
parameter verification and we need to add assignment to the allowed
list.

Assignment uid is specified as a query parameter after the launch url.
The lti library takes the entire launch url, including this assignment
parameter, when validating the signature. However, it looks like Canvas
only uses the original launch url (without the assignment uid query) to
generate the signature. So as a quick fix, we'll pass in only the url
without queries to the signature validator. This fix wouldn't work if
our original launch url contains other queries, but afaik, ComPAIR
shouldn't encounter this issue.
  • Loading branch information
ionparticle committed Jun 21, 2022
1 parent 6270bae commit 9d07705
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lti/launch_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ def touni(s, enc='utf8', err='strict'):

LAUNCH_PARAMS_CANVAS = [
'selection_directive',
'text'
'text',
'assignment'
]

CONTENT_PARAMS_REQUEST = [
Expand Down
10 changes: 9 additions & 1 deletion lti/tool_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,16 @@ def is_valid_request(self, validator):
validator = ProxyValidator(validator)
endpoint = SignatureOnlyEndpoint(validator)

# hack to fix lti launch to assignment not working
# as far as I can figure, looks like Canvas doesn't use the modified
# url with the assignment query as part of the signature, so we need
# to use the url without the assignment query for signature validation
launchUrlParts = urlsplit(self.launch_url)
validateUrl = launchUrlParts.scheme + '://' + launchUrlParts.netloc + \
launchUrlParts.path

valid, request = endpoint.validate_request(
self.launch_url,
validateUrl,
'POST',
self.to_params(),
self.launch_headers
Expand Down

0 comments on commit 9d07705

Please sign in to comment.