Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
ab6018a0
Commit
ab6018a0
authored
Sep 16, 2013
by
David Ormsbee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace signature validation with access-key and add logging around Software Secure callbacks.
parent
b1be80b8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
6 deletions
+48
-6
lms/djangoapps/verify_student/models.py
+20
-0
lms/djangoapps/verify_student/views.py
+28
-6
No files found.
lms/djangoapps/verify_student/models.py
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
):
"""
...
...
lms/djangoapps/verify_student/views.py
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!"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment