Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
lti-xblock-consumer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OpenJupyter
lti-xblock-consumer
Commits
c122312d
Unverified
Commit
c122312d
authored
4 years ago
by
Paulo Viadanna
Committed by
Giovanni Cimolin da Silva
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
BB-2332: Add preflight response validation
parent
db90c57e
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lti_consumer/lti_1p3/consumer.py
+22
-0
22 additions, 0 deletions
lti_consumer/lti_1p3/consumer.py
with
22 additions
and
0 deletions
lti_consumer/lti_1p3/consumer.py
+
22
−
0
View file @
c122312d
"""
"""
LTI 1.3 Consumer implementation
LTI 1.3 Consumer implementation
"""
"""
import
json
import
time
from
six.moves.urllib.parse
import
urlencode
from
six.moves.urllib.parse
import
urlencode
from
.
import
exceptions
from
.
import
exceptions
...
@@ -278,6 +280,10 @@ class LtiConsumer1p3:
...
@@ -278,6 +280,10 @@ class LtiConsumer1p3:
return
self
.
key_handler
.
get_public_jwk
()
return
self
.
key_handler
.
get_public_jwk
()
public_keys
=
jwk
.
KEYS
()
public_keys
.
append
(
self
.
jwk
)
return
json
.
loads
(
public_keys
.
dump_jwks
())
def
access_token
(
self
,
token_request_data
):
def
access_token
(
self
,
token_request_data
):
"""
"""
Validate request and return JWT access token.
Validate request and return JWT access token.
...
@@ -344,3 +350,19 @@ class LtiConsumer1p3:
...
@@ -344,3 +350,19 @@ class LtiConsumer1p3:
"
expires_in
"
:
3600
,
"
expires_in
"
:
3600
,
"
scope
"
:
scopes_str
"
scope
"
:
scopes_str
}
}
def
_validate_preflight_response
(
self
,
response
):
"""
Validates a preflight response to be used in a launch request
Raises ValueError in case of validation failure
:param response: the preflight response to be validated
"""
try
:
assert
response
.
get
(
"
nonce
"
)
assert
response
.
get
(
"
state
"
)
assert
response
.
get
(
"
client_id
"
)
==
self
.
client_id
assert
response
.
get
(
"
redirect_uri
"
)
==
self
.
launch_url
except
AssertionError
as
e
:
raise
ValueError
(
"
Preflight reponse failed validation
"
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment