test_outcomes.py
16.8 KB
-
Fix the duplicate oauth_body_hash in the outcomes request · 18648b52
The "oauth_body_hash" appeared twice in the auth header in the request when posting grade back to tool consumer. However, the signature sent from edX is calculated based on only one oauth_body_hash. On the tool consumer side, the signature is calculated based on the auth header and will use the duplicated fields. So the signatures will not match. And request will fail the signature validation. The bug was introduced in this commit: https://github.com/edx/edx-platform/commit/03cee389e0869263f5f9977098770495b5216733 on July 12th by updating the oauthlib. Because 0.7.2(original version) doesn't have oauth_body_hash support, so a custom OAuth1 client was implemented to add oauth_body_hash to the headers: https://github.com/edx/edx-platform/blob/f5d0f3ff55d264ed4b68a24808b255aef5d8dad2/lms/djangoapps/lti_provider/outcomes.py#L24. However, the new oauthlib 1.0.3 has support for oauth_body_hash (https://github.com/idan/oauthlib/commit/51675237c410b413a11091926436420493c52866#diff-c2a1e5f1ddfe8e48ff62b59eb952644eR180). So after updating library, oauth_body_hash is added twice. This fixes the bug by removing the custom client and use the oauthlib default client to generate the auth header.
Pan Luo committed