Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
code.vt.edu will be down for maintenance from 0530-0630 EDT Wednesday, March 26th
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
ab6018a0
Commit
ab6018a0
authored
11 years ago
by
David Ormsbee
Browse files
Options
Downloads
Patches
Plain Diff
Replace signature validation with access-key and add logging around Software Secure callbacks.
parent
b1be80b8
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lms/djangoapps/verify_student/models.py
+20
-0
20 additions, 0 deletions
lms/djangoapps/verify_student/models.py
lms/djangoapps/verify_student/views.py
+28
-6
28 additions, 6 deletions
lms/djangoapps/verify_student/views.py
with
48 additions
and
6 deletions
lms/djangoapps/verify_student/models.py
+
20
−
0
View file @
ab6018a0
...
...
@@ -356,6 +356,26 @@ class PhotoVerification(StatusModel):
self
.
status
=
"
denied
"
self
.
save
()
@status_before_must_be
(
"
must_retry
"
,
"
submitted
"
,
"
approved
"
,
"
denied
"
)
def
system_error
(
self
,
error_msg
,
error_code
=
""
,
reviewing_user
=
None
,
reviewing_service
=
""
):
"""
Mark that this attempt could not be completed because of a system error.
Status should be moved to `must_retry`.
"""
if
self
.
status
in
[
"
approved
"
,
"
denied
"
]:
return
# If we were already approved or denied, just leave it.
self
.
error_msg
=
error_msg
self
.
error_code
=
error_code
self
.
reviewing_user
=
reviewing_user
self
.
reviewing_service
=
reviewing_service
self
.
status
=
"
must_retry
"
self
.
save
()
class
SoftwareSecurePhotoVerification
(
PhotoVerification
):
"""
...
...
This diff is collapsed.
Click to expand it.
lms/djangoapps/verify_student/views.py
+
28
−
6
View file @
ab6018a0
...
...
@@ -180,21 +180,43 @@ def results_callback(request):
settings
.
VERIFY_STUDENT
[
"
SOFTWARE_SECURE
"
][
"
API_SECRET_KEY
"
]
)
if
not
sig_valid
:
return
HttpResponseBadRequest
(
_
(
"
Signature is invalid
"
))
_
,
access_key_and_sig
=
headers
[
"
Authorization
"
].
split
(
"
"
)
access_key
=
access_key_and_sig
.
split
(
"
:
"
)[
0
]
# This is what we should be doing...
#if not sig_valid:
# return HttpResponseBadRequest("Signature is invalid")
# This is what we're doing until we can figure out why we disagree on sigs
if
access_key
!=
settings
.
VERIFY_STUDENT
[
"
SOFTWARE_SECURE
"
][
"
API_ACCESS_KEY
"
]:
return
HttpResponseBadRequest
(
"
Access key invalid
"
)
receipt_id
=
body_dict
.
get
(
"
EdX-ID
"
)
result
=
body_dict
.
get
(
"
Result
"
)
reason
=
body_dict
.
get
(
"
Reason
"
,
""
)
error_code
=
body_dict
.
get
(
"
MessageType
"
,
""
)
attempt
=
SoftwareSecurePhotoVerification
.
objects
.
get
(
receipt_id
=
receipt_id
)
if
result
==
"
PASSED
"
:
try
:
attempt
=
SoftwareSecurePhotoVerification
.
objects
.
get
(
receipt_id
=
receipt_id
)
except
SoftwareSecurePhotoVerification
.
DoesNotExist
:
log
.
error
(
"
Software Secure posted back for receipt_id {}, but not found
"
.
format
(
receipt_id
))
return
HttpResponseBadRequest
(
"
edX ID {} not found
"
.
format
(
receipt_id
))
if
result
==
"
PASS
"
:
log
.
debug
(
"
Approving verification for {}
"
.
format
(
receipt_id
))
attempt
.
approve
()
elif
result
==
"
FAILED
"
:
attempt
.
deny
(
reason
,
error_code
=
error_code
)
elif
result
==
"
FAIL
"
:
log
.
debug
(
"
Denying verification for {}
"
.
format
(
receipt_id
))
attempt
.
deny
(
json
.
dumps
(
reason
),
error_code
=
error_code
)
elif
result
==
"
SYSTEM FAIL
"
:
log
.
debug
(
"
System failure for {} -- resetting to must_retry
"
.
format
(
receipt_id
))
attempt
.
system_error
(
json
.
dumps
(
reason
),
error_code
=
error_code
)
log
.
error
(
"
Software Secure callback attempt for %s failed: %s
"
,
receipt_id
,
reason
)
else
:
log
.
error
(
"
Software Secure returned unknown result {}
"
.
format
(
result
))
return
HttpResponseBadRequest
(
"
Result {} not understood. Known results: PASS, FAIL, SYSTEM FAIL
"
.
format
(
result
)
)
return
HttpResponse
(
"
OK!
"
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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