Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #70

Merged
merged 2 commits into from
Aug 27, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions blti/views/develop.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
base_string_uri, signature_base_string,
normalize_parameters, sign_hmac_sha1_with_client)
from blti import BLTIException
import re


class BLTIDevBase(TemplateView):
Expand All @@ -18,9 +19,15 @@ def lti_app(self):
except AttributeError:
raise BLTIException("Missing setting: LTI_DEVELOP_APP")

def lti_app_uri(self):
blti_match = re.match(r'^(http[s]?://[^/]+/)blti.*',
self.request.build_absolute_uri())
return "{}{}".format(blti_match.group(1), self.lti_app())

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['lti_app'] = self.lti_app()
return context


class BLTIDevPrepare(BLTIDevBase):
Expand Down Expand Up @@ -123,11 +130,9 @@ def get_context_data(self, **kwargs):
lti_parameters += self._static_lti_parameters

# sign payload
raw_uri = self.request.build_absolute_uri()
lti_app_len = len(self.lti_app())
uri = raw_uri[0:raw_uri.index('/' + self.lti_app()) + lti_app_len + 1]
lti_app_uri = self.lti_app_uri()
sbs = signature_base_string('POST',
base_string_uri(uri),
base_string_uri(lti_app_uri),
normalize_parameters(lti_parameters))
client_key = self._client_key
client = Client(
Expand All @@ -136,7 +141,7 @@ def get_context_data(self, **kwargs):
lti_parameters.append(("oauth_signature", signature))

context = super().get_context_data(**kwargs)
context['uri'] = uri
context['uri'] = lti_app_uri
context['campus'] = campus
context['role_name'] = role
context['lti_parameters'] = lti_parameters
Expand Down