Commit bfc5c4c8 by Joe Blaylock Committed by stv

Instructor API endpoint: IRC auth token

Adds /instructor/api/irc_instructor_auth_token API endpoint which
returns a JSON blob including a per-course magic key iff the logged-in
user is an instructor in the course.
parent a85c8016
...@@ -6,6 +6,7 @@ JSON views which the instructor dashboard requests. ...@@ -6,6 +6,7 @@ JSON views which the instructor dashboard requests.
Many of these GETs may become PUTs in the future. Many of these GETs may become PUTs in the future.
""" """
import hashlib
import json import json
import logging import logging
import re import re
...@@ -1306,3 +1307,16 @@ def _split_input_list(str_list): ...@@ -1306,3 +1307,16 @@ def _split_input_list(str_list):
new_list = [s for s in new_list if s != ''] new_list = [s for s in new_list if s != '']
return new_list return new_list
@ensure_csrf_cookie
@cache_control(no_cache=True, no_store=True, must_revalidate=True)
def irc_instructor_auth_token(request, course_id):
# Note: course_id is assumed to be deprecated crappy SSCK value
# in future, hashing it below will need to convert from course_key
course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id)
course = get_course_by_id(course_key, depth=None)
is_instructor_here = has_access(request.user, 'staff', course)
if is_instructor_here:
extras_key = hashlib.sha1(course_id+"happy fish").hexdigest()
return JsonResponse({'extras': extras_key, 'error': ''})
return JsonResponse({'extras': '', 'error': 'NotInstructor'})
...@@ -47,6 +47,7 @@ urlpatterns = patterns('', # nopep8 ...@@ -47,6 +47,7 @@ urlpatterns = patterns('', # nopep8
name='show_unit_extensions'), name='show_unit_extensions'),
url(r'^show_student_extensions$', 'instructor.views.api.show_student_extensions', url(r'^show_student_extensions$', 'instructor.views.api.show_student_extensions',
name='show_student_extensions'), name='show_student_extensions'),
url(r'^irc_instructor_auth_token$', 'instructor.views.api.irc_instructor_auth_token'),
# Grade downloads... # Grade downloads...
url(r'^list_report_downloads$', url(r'^list_report_downloads$',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment