Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/richie/apps/courses/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
API endpoints for the courses app.
"""

import hmac

from django.conf import settings
from django.core.cache import caches
from django.db.models import Q
Expand Down Expand Up @@ -253,8 +255,9 @@ def sync_course_runs_from_request(request, version):
if not authorization_header:
return Response("Missing authentication.", status=403)

# Use `hmac.compare_digest` to prevent time attacks
signature_is_valid = any(
authorization_header == get_signature(message, secret)
hmac.compare_digest(authorization_header, get_signature(message, secret))
for secret in getattr(settings, "RICHIE_COURSE_RUN_SYNC_SECRETS", [])
)

Expand Down