Exemple #1
0
 def test_makes_verifier(self):
     srpinfo = SRPUserInfo(user=User.objects.get(username='******'))
     srpinfo.set_from_password("asdf")
     self.assertTrue(srpinfo.salt)
     self.assertTrue(srpinfo.verifier)
     # print 'Salt:     <%s>' % srpinfo.salt
     # print 'Verifier: <%s>' % srpinfo.verifier
     self.assertTrue(re.match(r'^[a-zA-Z0-9/+=]+$', srpinfo.salt))
     self.assertTrue(re.match(r'^[a-zA-Z0-9/+=]+$', srpinfo.verifier))
Exemple #2
0
 def test_makes_verifier(self):
     srpinfo = SRPUserInfo(user=User.objects.get(username='******'))
     srpinfo.set_from_password("asdf")
     self.assertTrue(srpinfo.salt)
     self.assertTrue(srpinfo.verifier)
     # print 'Salt:     <%s>' % srpinfo.salt
     # print 'Verifier: <%s>' % srpinfo.verifier
     self.assertTrue(re.match(r'^[a-zA-Z0-9/+=]+$', srpinfo.salt))
     self.assertTrue(re.match(r'^[a-zA-Z0-9/+=]+$', srpinfo.verifier))
Exemple #3
0
 def handle(self, *args, **options):
     if len(args) != 2:
         raise CommandError("must specify username and password")
     username = args[0]
     password = args[1]
     try:
         user = User.objects.get(username=username)
     except User.DoesNotExist:
         user = User(username=username, password=UNUSABLE_PASSWORD)
         user.save()
     try:
         srpinfo = SRPUserInfo.objects.get(user=user)
     except SRPUserInfo.DoesNotExist:
         srpinfo = SRPUserInfo(user=user)
     srpinfo.set_from_password(password)
     srpinfo.save()
Exemple #4
0
 def save(self, commit=True):
     user = super(SRPUserCreationForm, self).save(commit=False)
     user.password = UNUSABLE_PASSWORD
     srpinfo = SRPUserInfo()
     srpinfo.verifier = self.cleaned_data['verifier']
     srpinfo.salt = self.cleaned_data['salt']
     srpinfo.srp_group = self.cleaned_data['srp_group']
     if commit:
         user.save()
         srpinfo.user = user
         srpinfo.save()
     return user
Exemple #5
0
 def save(self, commit=True):
     user = super(SRPUserCreationForm, self).save(commit=False)
     user.password = UNUSABLE_PASSWORD
     srpinfo = SRPUserInfo()
     srpinfo.verifier = self.cleaned_data["verifier"]
     srpinfo.salt = self.cleaned_data["salt"]
     srpinfo.srp_group = self.cleaned_data["srp_group"]
     if commit:
         user.save()
         srpinfo.user = user
         srpinfo.save()
     return user
Exemple #6
0
def edit(request, username):
    if request.user.username != username:
        return HttpResponseForbidden()
    user = get_object_or_404(User, username=username)
    try:
        srpinfo = SRPUserInfo.objects.get(user=user)
    except SRPUserInfo.DoesNotExist:
        srpinfo = SRPUserInfo(user=user)
    if request.method == 'POST':
        form = SRPUserEditForm(request.POST, instance=srpinfo)
        if form.is_valid():
            form.save()
    else:
        form = SRPUserEditForm(instance=srpinfo)
    return render_to_response('tlssrp/edit.html', {
        'form': form,
        'user': user
    },
                              context_instance=RequestContext(request))
Exemple #7
0
 def handle(self, *args, **options):
     if len(args) != 2:
         raise CommandError("must specify username and password")
     username = args[0]
     password = args[1]
     try:
         user = User.objects.get(username=username)
     except User.DoesNotExist:
         user = User(username=username, password=UNUSABLE_PASSWORD)
         user.save()
     try:
         srpinfo = SRPUserInfo.objects.get(user=user)
     except SRPUserInfo.DoesNotExist:
         srpinfo = SRPUserInfo(user=user)
     srpinfo.set_from_password(password)
     srpinfo.save()