Skip to content
This repository has been archived by the owner on Feb 21, 2020. It is now read-only.

Commit

Permalink
fixing secret comparison with constant time compare
Browse files Browse the repository at this point in the history
Conflicts:
	agora_site/agora_core/forms/user.py
  • Loading branch information
Eduardo Robles Elvira committed Jan 4, 2014
1 parent 8f6f3b5 commit 97607ae
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions agora_site/agora_core/forms/user.py
Expand Up @@ -12,6 +12,7 @@
from django.utils.translation import gettext as _
from django.contrib.auth import authenticate, login
from django.shortcuts import get_object_or_404
from django.utils.crypto import constant_time_compare

from userena import settings as userena_settings
from userena import forms as userena_forms
Expand Down Expand Up @@ -387,8 +388,10 @@ def clean_email(self):

def clean_activation_secret(self):
if len(self.cleaned_data['activation_secret']) > 0:
if self.cleaned_data['activation_secret'] != settings.AGORA_API_AUTO_ACTIVATION_SECRET:
raise django_forms.ValidationError(_('Invalid activation secret. ' + settings.AGORA_API_AUTO_ACTIVATION_SECRET + "!= " + self.cleaned_data['activation_secret']))
if not constant_time_compare(
self.cleaned_data['activation_secret'],
settings.AGORA_API_AUTO_ACTIVATION_SECRET):
raise django_forms.ValidationError(_('Invalid activation secret. '))
if not settings.AGORA_ALLOW_API_AUTO_ACTIVATION:
raise django_forms.ValidationError(_('Auto activation not allowed.'))
return self.cleaned_data['activation_secret']
Expand Down Expand Up @@ -439,4 +442,4 @@ def bundle_obj(self, obj, request):
ur = ActivationUserResource()
bundle = ur.build_bundle(obj=obj, request=request)
bundle = ur.full_dehydrate(bundle)
return bundle
return bundle

0 comments on commit 97607ae

Please sign in to comment.