Skip to content
Snippets Groups Projects
Unverified Commit df0d2c59 authored by millosolomillo's avatar millosolomillo Committed by GitHub
Browse files

Revert "Update pull from benadida repository. (#3)" (#4)

This reverts commit b52a755d.
parent b52a755d
Branches
No related tags found
No related merge requests found
Showing
with 115 additions and 153 deletions
...@@ -7,4 +7,3 @@ venv ...@@ -7,4 +7,3 @@ venv
celerybeat-* celerybeat-*
env.sh env.sh
.cache .cache
.idea/
\ No newline at end of file
...@@ -12,6 +12,3 @@ addons: ...@@ -12,6 +12,3 @@ addons:
postgresql: "9.3" postgresql: "9.3"
before_script: before_script:
- psql -c 'create database helios;' -U postgres - psql -c 'create database helios;' -U postgres
before_install:
- export BOTO_CONFIG=/dev/null
from django.conf import settings from django.conf import settings
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from helios.views import election_shortcut
TEMPLATE_BASE = settings.HELIOS_TEMPLATE_BASE or "helios/templates/base.html" TEMPLATE_BASE = settings.HELIOS_TEMPLATE_BASE or "helios/templates/base.html"
......
""" """
Crypto Utils Crypto Utils
""" """
import hashlib
import hmac, base64, json import hmac, base64, json
from hashlib import sha256 from hashlib import sha256
...@@ -21,11 +21,3 @@ def to_json(d): ...@@ -21,11 +21,3 @@ def to_json(d):
def from_json(json_str): def from_json(json_str):
if not json_str: return None if not json_str: return None
return json.loads(json_str) return json.loads(json_str)
def do_hmac(k,s):
"""
HMAC a value with a key, hex output
"""
mac = hmac.new(k, s, hashlib.sha1)
return mac.hexdigest()
\ No newline at end of file
...@@ -76,23 +76,11 @@ function show_sk() { ...@@ -76,23 +76,11 @@ function show_sk() {
} }
function download_sk() { function download_sk() {
$('#pk_content').show(); UTILS.open_window_with_content(jQuery.toJSON(SECRET_KEY), "application/json");
$('#sk_content').html(jQuery.toJSON(SECRET_KEY));
}
function download_sk_to_file(filename) {
var element = document.createElement('a');
element.setAttribute('href','data:text/plain;charset=utf-8,'+ encodeURIComponent(jQuery.toJSON(SECRET_KEY)));
element.setAttribute('download', filename);
element.style.display = 'none';
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
} }
function show_pk() { function show_pk() {
$('#sk_download').hide(); $('#sk_download').hide();
$('#pk_content').hide();
$('#pk_hash').show(); $('#pk_hash').show();
$('#pk_form').show(); $('#pk_form').show();
} }
...@@ -113,7 +101,7 @@ function show_pk() { ...@@ -113,7 +101,7 @@ function show_pk() {
<span id="buttons"><button onclick="generate_keypair(); return false;" id="generate_button">Generate Election Keys</button></span> <span id="buttons"><button onclick="generate_keypair(); return false;" id="generate_button">Generate Election Keys</button></span>
<br /> <br /><br />
If you've already generated a keypair, you can <a href="javascript:show_key_reuse()">reuse it</a>. If you've already generated a keypair, you can <a href="javascript:show_key_reuse()">reuse it</a>.
</p> </p>
...@@ -138,24 +126,11 @@ Your key has been generated, but you may choose to<br /><a href="javascript:clea ...@@ -138,24 +126,11 @@ Your key has been generated, but you may choose to<br /><a href="javascript:clea
</span> </span>
<p> <p>
<button style="font-size:16pt;" onclick="download_sk(); $('#pk_link').show();">Show my secret key</button> <button style="font-size:16pt;" onclick="download_sk(); $('#pk_link').show();">Save your secret key</button>
</p> </p>
</div>
<div style="display:none;" id="pk_content"> <p style="display: none;" id="pk_link">
<p>Bellow is your trustee secret key content. Please copy its content and save it securely. <br> <a href="javascript:show_pk();">ok, I've saved the key, let's move on</a>.
You can also click to dowload it to a file.
And please don't lose it! Otherwise it will not be possible to decrypt the election tally.<br>
</p>
<textarea id="sk_content" rows="5" wrap="soft" cols="50" style="height: 25em;"></textarea>
</div>
<div style="display:none;" id="pk_link">
<p>
<a id="download_to_file" href="javascript:download_sk_to_file('trustee_key_for_{{election.name}}.txt');">download private key to a file</a>
</p>
<p>
<a href="javascript:show_pk();">ok, I've saved the key, let's move on</a>
</p> </p>
</div> </div>
......
...@@ -59,7 +59,7 @@ To verify that you have the right secret key, paste it here: ...@@ -59,7 +59,7 @@ To verify that you have the right secret key, paste it here:
<p> <p>
<form onsubmit="check_sk(this.secret_key.value); this.secret_key.value=''; return false;"> <form onsubmit="check_sk(this.secret_key.value); this.secret_key.value=''; return false;">
<textarea name="secret_key" cols="60" rows ="5" wrap="soft" style="height: 25em;"> <textarea name="secret_key" cols="60" rows ="5" wrap="soft">
</textarea> </textarea>
<br /> <br />
<input type="submit" value="check" /> <input type="submit" value="check" />
......
...@@ -157,7 +157,7 @@ function reset() { ...@@ -157,7 +157,7 @@ function reset() {
<form onsubmit="return false;"> <form onsubmit="return false;">
<h3>FIRST STEP: enter your secret key</h3> <h3>FIRST STEP: enter your secret key</h3>
<textarea id="sk_textarea" cols="60" rows="5" style="height: 25em;"></textarea> <textarea id="sk_textarea" cols="60" rows="5"></textarea>
</form> </form>
<p id="tally_section"> <p id="tally_section">
<button onclick="do_tally();">Generate partial decryption</button> <button onclick="do_tally();">Generate partial decryption</button>
...@@ -187,11 +187,13 @@ function reset() { ...@@ -187,11 +187,13 @@ function reset() {
When you're ready, you can submit this result to the server. When you're ready, you can submit this result to the server.
</p> </p>
Your partial decryption:<br /> Your partial decryption:<br />
<p> <form action="javascript:submit_result();">
<textarea id="result_textarea" cols="60" rows="5" wrap="soft" style="height: 25em;"></textarea> <textarea id="result_textarea" cols="60" rows="5" wrap="soft"></textarea><br /><br />
<button onclick="submit_result();">Upload decryption factors to server</button> <input type="submit" value="Upload decryption factors to server" />
</p> </form>
<p><a href="javascript:reset()">reset and restart decryption process</a></p> <br />
<a href="javascript:reset()">reset and restart decryption process</a>
<br />
</div> </div>
<div id="done_div"> <div id="done_div">
......
...@@ -112,11 +112,6 @@ Voters {{voters_page.start_index}} - {{voters_page.end_index}} (of {{total_voter ...@@ -112,11 +112,6 @@ Voters {{voters_page.start_index}} - {{voters_page.end_index}} (of {{total_voter
<table class="pretty"> <table class="pretty">
<tr> <tr>
{% if admin_p or not election.use_voter_aliases %} {% if admin_p or not election.use_voter_aliases %}
{% if admin_p %}
<th style="width: 80px;">Actions</th>
<th>Login</th>
<th>Email Address</th>
{% endif %}
<th>Name</th> <th>Name</th>
{% endif %} {% endif %}
...@@ -128,22 +123,19 @@ Voters {{voters_page.start_index}} - {{voters_page.end_index}} (of {{total_voter ...@@ -128,22 +123,19 @@ Voters {{voters_page.start_index}} - {{voters_page.end_index}} (of {{total_voter
{% for voter in voters %} {% for voter in voters %}
<tr> <tr>
{% if admin_p or not election.use_voter_aliases %} {% if admin_p or not election.use_voter_aliases %}
<td>
{% if admin_p %} {% if admin_p %}
<td style="white-space: nowrap;">
{% if election.frozen_at %} {% if election.frozen_at %}
[<a href="{% url "helios.views.voters_email" election.uuid %}?voter_id={{voter.voter_login_id}}">email</a>] [<a href="{% url "helios.views.voters_email" election.uuid %}?voter_id={{voter.voter_login_id}}">email</a>]
{% endif %} {% endif %}
[<a onclick="return confirm('are you sure you want to remove {{voter.name}} ?');" href="{% url "helios.views.voter_delete" election.uuid voter.uuid %}">x</a>] [<a onclick="return confirm('are you sure you want to remove {{voter.name}} ?');" href="{% url "helios.views.voter_delete" election.uuid voter.uuid %}">x</a>]
</td>
<td>{{voter.voter_login_id}}</td>
<td>{{voter.voter_email}}</td>
{% endif %} {% endif %}
<td><img class="small-logo" src="/static/auth/login-icons/{{voter.voter_type}}.png" alt="{{voter.voter_type}}" /> {{voter.name}}</td> <img class="small-logo" src="/static/auth/login-icons/{{voter.voter_type}}.png" alt="{{voter.voter_type}}" /> {{voter.name}}</td>
{% endif %} {% endif %}
{% if election.use_voter_aliases %} {% if election.use_voter_aliases %}
<td>{{voter.alias}}</td> <td>{{voter.alias}}</td>
{% endif %} {% endif %}
<td><tt style="font-size: 1.4em;">{% if voter.vote_hash %}{{voter.vote_hash}} <span style="font-size:0.8em;">[<a href="{% url "helios.views.castvote_shortcut" vote_tinyhash=voter.vote_tinyhash %}">view</a>]</span>{% else %}&mdash;{% endif %}</tt></td> <td><tt style="font-size: 1.4em;;">{% if voter.vote_hash %}{{voter.vote_hash}} <span style="font-size:0.8em;">[<a href="{% url "helios.views.castvote_shortcut" vote_tinyhash=voter.vote_tinyhash %}">view</a>]</span>{% else %}&mdash;{% endif %}</tt></td>
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>
......
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from django.conf.urls import patterns, include from django.conf.urls import *
from django.conf import settings
from views import * from views import *
urlpatterns = None
urlpatterns = patterns('', urlpatterns = patterns('',
(r'^autologin$', admin_autologin), (r'^autologin$', admin_autologin),
(r'^testcookie$', test_cookie), (r'^testcookie$', test_cookie),
......
...@@ -5,7 +5,9 @@ Ben Adida - ben@adida.net ...@@ -5,7 +5,9 @@ Ben Adida - ben@adida.net
2005-04-11 2005-04-11
""" """
import urllib, re, datetime, string import urllib, re, sys, datetime, urlparse, string
import boto.ses
# utils from helios_auth, too # utils from helios_auth, too
from helios_auth.utils import * from helios_auth.utils import *
...@@ -13,6 +15,14 @@ from helios_auth.utils import * ...@@ -13,6 +15,14 @@ from helios_auth.utils import *
from django.conf import settings from django.conf import settings
import random, logging import random, logging
import hashlib, hmac, base64
def do_hmac(k,s):
"""
HMAC a value with a key, hex output
"""
mac = hmac.new(k, s, hashlib.sha1)
return mac.hexdigest()
def split_by_length(str, length, rejoin_with=None): def split_by_length(str, length, rejoin_with=None):
...@@ -157,7 +167,7 @@ def one_val_raw_sql(raw_sql, values=[]): ...@@ -157,7 +167,7 @@ def one_val_raw_sql(raw_sql, values=[]):
""" """
for a simple aggregate for a simple aggregate
""" """
from django.db import connection from django.db import connection, transaction
cursor = connection.cursor() cursor = connection.cursor()
cursor.execute(raw_sql, values) cursor.execute(raw_sql, values)
......
...@@ -6,41 +6,41 @@ Ben Adida (ben@adida.net) ...@@ -6,41 +6,41 @@ Ben Adida (ben@adida.net)
""" """
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.core.mail import send_mail
from django.core.paginator import Paginator from django.core.paginator import Paginator
from django.core.exceptions import PermissionDenied from django.core.exceptions import PermissionDenied
from django.http import HttpResponse, Http404, HttpResponseRedirect, HttpResponseForbidden from django.http import *
from django.db import transaction, IntegrityError from django.db import transaction, IntegrityError
from mimetypes import guess_type
from validate_email import validate_email from validate_email import validate_email
import urllib, os, base64 import csv, urllib, os, base64
from crypto import algs, electionalgs, elgamal from crypto import algs, electionalgs, elgamal
from crypto import utils as cryptoutils from crypto import utils as cryptoutils
from workflows import homomorphic from workflows import homomorphic
from helios import utils, VOTERS_EMAIL, VOTERS_UPLOAD from helios import utils as helios_utils
from view_utils import SUCCESS, FAILURE, return_json, render_template, render_template_raw from view_utils import *
from helios_auth.security import check_csrf, login_required, get_user, save_in_session_across_logouts from helios_auth.security import *
from helios_auth.auth_systems import AUTH_SYSTEMS, can_list_categories from helios_auth.auth_systems import AUTH_SYSTEMS, can_list_categories
from helios_auth.models import AuthenticationExpired from helios_auth.models import AuthenticationExpired
from helios import security
from helios_auth import views as auth_views from helios_auth import views as auth_views
import tasks import tasks
from security import (election_view, election_admin, from security import *
trustee_check, set_logged_in_trustee, from helios_auth.security import get_user, save_in_session_across_logouts
can_create_election, user_can_see_election, get_voter,
user_can_admin_election, user_can_feature_election)
import uuid, datetime import uuid, datetime
import logging
from models import User, Election, CastVote, Voter, VoterFile, Trustee, AuditedBallot from models import *
import datatypes
import forms import forms, signals
# Parameters for everything # Parameters for everything
ELGAMAL_PARAMS = elgamal.Cryptosystem() ELGAMAL_PARAMS = elgamal.Cryptosystem()
...@@ -196,7 +196,7 @@ def election_new(request): ...@@ -196,7 +196,7 @@ def election_new(request):
election_params = dict(election_form.cleaned_data) election_params = dict(election_form.cleaned_data)
# is the short name valid # is the short name valid
if utils.urlencode(election_params['short_name']) == election_params['short_name']: if helios_utils.urlencode(election_params['short_name']) == election_params['short_name']:
election_params['uuid'] = str(uuid.uuid1()) election_params['uuid'] = str(uuid.uuid1())
election_params['cast_url'] = settings.SECURE_URL_HOST + reverse(one_election_cast, args=[election_params['uuid']]) election_params['cast_url'] = settings.SECURE_URL_HOST + reverse(one_election_cast, args=[election_params['uuid']])
...@@ -293,8 +293,8 @@ def election_badge(request, election): ...@@ -293,8 +293,8 @@ def election_badge(request, election):
@election_view() @election_view()
def one_election_view(request, election): def one_election_view(request, election):
user = get_user(request) user = get_user(request)
admin_p = user_can_admin_election(user, election) admin_p = security.user_can_admin_election(user, election)
can_feature_p = user_can_feature_election(user, election) can_feature_p = security.user_can_feature_election(user, election)
notregistered = False notregistered = False
eligible_p = True eligible_p = True
...@@ -383,7 +383,7 @@ def list_trustees(request, election): ...@@ -383,7 +383,7 @@ def list_trustees(request, election):
def list_trustees_view(request, election): def list_trustees_view(request, election):
trustees = Trustee.get_by_election(election) trustees = Trustee.get_by_election(election)
user = get_user(request) user = get_user(request)
admin_p = user_can_admin_election(user, election) admin_p = security.user_can_admin_election(user, election)
return render_template(request, 'list_trustees', {'election': election, 'trustees': trustees, 'admin_p':admin_p}) return render_template(request, 'list_trustees', {'election': election, 'trustees': trustees, 'admin_p':admin_p})
...@@ -424,9 +424,14 @@ def trustee_login(request, election_short_name, trustee_email, trustee_secret): ...@@ -424,9 +424,14 @@ def trustee_login(request, election_short_name, trustee_email, trustee_secret):
if trustee.secret == trustee_secret: if trustee.secret == trustee_secret:
set_logged_in_trustee(request, trustee) set_logged_in_trustee(request, trustee)
return HttpResponseRedirect(settings.SECURE_URL_HOST + reverse(trustee_home, args=[election.uuid, trustee.uuid])) return HttpResponseRedirect(settings.SECURE_URL_HOST + reverse(trustee_home, args=[election.uuid, trustee.uuid]))
# bad secret or no such trustee else:
raise Http404("Trustee not recognized.") # bad secret, we'll let that redirect to the front page
raise Http404("No election {} found.".format(election_short_name)) pass
else:
# no such trustee
raise Http404
return HttpResponseRedirect(settings.SECURE_URL_HOST + "/")
@election_admin() @election_admin()
def trustee_send_url(request, election, trustee_uuid): def trustee_send_url(request, election, trustee_uuid):
...@@ -446,7 +451,7 @@ Your trustee dashboard is at ...@@ -446,7 +451,7 @@ Your trustee dashboard is at
Helios Helios
""" % (election.name, url) """ % (election.name, url)
utils.send_email(settings.SERVER_EMAIL, ["%s <%s>" % (trustee.name, trustee.email)], 'your trustee homepage for %s' % election.name, body) helios_utils.send_email(settings.SERVER_EMAIL, ["%s <%s>" % (trustee.name, trustee.email)], 'your trustee homepage for %s' % election.name, body)
logging.info("URL %s " % url) logging.info("URL %s " % url)
return HttpResponseRedirect(settings.SECURE_URL_HOST + reverse(list_trustees_view, args = [election.uuid])) return HttpResponseRedirect(settings.SECURE_URL_HOST + reverse(list_trustees_view, args = [election.uuid]))
...@@ -471,7 +476,7 @@ def trustee_upload_pk(request, election, trustee): ...@@ -471,7 +476,7 @@ def trustee_upload_pk(request, election, trustee):
if not trustee.public_key.verify_sk_proof(trustee.pok, algs.DLog_challenge_generator): if not trustee.public_key.verify_sk_proof(trustee.pok, algs.DLog_challenge_generator):
raise Exception("bad pok for this public key") raise Exception("bad pok for this public key")
trustee.public_key_hash = cryptoutils.hash_b64(utils.to_json(trustee.public_key.toJSONDict())) trustee.public_key_hash = utils.hash_b64(utils.to_json(trustee.public_key.toJSONDict()))
trustee.save() trustee.save()
...@@ -507,7 +512,8 @@ def encrypt_ballot(request, election): ...@@ -507,7 +512,8 @@ def encrypt_ballot(request, election):
perform the ballot encryption given answers_json, a JSON'ified list of list of answers perform the ballot encryption given answers_json, a JSON'ified list of list of answers
(list of list because each question could have a list of answers if more than one.) (list of list because each question could have a list of answers if more than one.)
""" """
answers = utils.from_json(request.POST['answers_json']) # FIXME: maybe make this just request.POST at some point?
answers = utils.from_json(request.REQUEST['answers_json'])
ev = homomorphic.EncryptedVote.fromElectionAndAnswers(election, answers) ev = homomorphic.EncryptedVote.fromElectionAndAnswers(election, answers)
return ev.ld_object.includeRandomness().toJSONDict() return ev.ld_object.includeRandomness().toJSONDict()
...@@ -546,13 +552,7 @@ def password_voter_login(request, election): ...@@ -546,13 +552,7 @@ def password_voter_login(request, election):
""" """
# the URL to send the user to after they've logged in # the URL to send the user to after they've logged in
if request.method == "GET" and 'return_url' in request.GET: return_url = request.REQUEST.get('return_url', reverse(one_election_cast_confirm, args=[election.uuid]))
return_url = request.GET['return_url']
elif request. method == "POST" and 'return_url' in request.POST:
return_url = request.POST['return_url']
else:
return_url = reverse(one_election_cast_confirm, args=[election.uuid])
bad_voter_login = (request.GET.get('bad_voter_login', "0") == "1") bad_voter_login = (request.GET.get('bad_voter_login', "0") == "1")
if request.method == "GET": if request.method == "GET":
...@@ -568,7 +568,7 @@ def password_voter_login(request, election): ...@@ -568,7 +568,7 @@ def password_voter_login(request, election):
'password_login_form': password_login_form, 'password_login_form': password_login_form,
'bad_voter_login' : bad_voter_login}) 'bad_voter_login' : bad_voter_login})
login_url = request.GET.get('login_url', None) login_url = request.REQUEST.get('login_url', None)
if not login_url: if not login_url:
# login depending on whether this is a private election # login depending on whether this is a private election
...@@ -923,7 +923,7 @@ def one_election_set_featured(request, election): ...@@ -923,7 +923,7 @@ def one_election_set_featured(request, election):
""" """
user = get_user(request) user = get_user(request)
if not user_can_feature_election(user, election): if not security.user_can_feature_election(user, election):
raise PermissionDenied() raise PermissionDenied()
featured_p = bool(int(request.GET['featured_p'])) featured_p = bool(int(request.GET['featured_p']))
...@@ -987,7 +987,7 @@ def one_election_copy(request, election): ...@@ -987,7 +987,7 @@ def one_election_copy(request, election):
def one_election_questions(request, election): def one_election_questions(request, election):
questions_json = utils.to_json(election.questions) questions_json = utils.to_json(election.questions)
user = get_user(request) user = get_user(request)
admin_p = user_can_admin_election(user, election) admin_p = security.user_can_admin_election(user, election)
return render_template(request, 'election_questions', {'election': election, 'questions_json' : questions_json, 'admin_p': admin_p}) return render_template(request, 'election_questions', {'election': election, 'questions_json' : questions_json, 'admin_p': admin_p})
...@@ -1191,7 +1191,7 @@ def voters_list_pretty(request, election): ...@@ -1191,7 +1191,7 @@ def voters_list_pretty(request, election):
order_by = 'alias' order_by = 'alias'
user = get_user(request) user = get_user(request)
admin_p = user_can_admin_election(user, election) admin_p = security.user_can_admin_election(user, election)
categories = None categories = None
eligibility_category_id = None eligibility_category_id = None
...@@ -1204,7 +1204,7 @@ def voters_list_pretty(request, election): ...@@ -1204,7 +1204,7 @@ def voters_list_pretty(request, election):
return user_reauth(request, user) return user_reauth(request, user)
# files being processed # files being processed
voter_files = election.voterfile_set.all().order_by('-uploaded_at') voter_files = election.voterfile_set.all()
# load a bunch of voters # load a bunch of voters
# voters = Voter.get_by_election(election, order_by=order_by) # voters = Voter.get_by_election(election, order_by=order_by)
...@@ -1224,9 +1224,9 @@ def voters_list_pretty(request, election): ...@@ -1224,9 +1224,9 @@ def voters_list_pretty(request, election):
return render_template(request, 'voters_list', return render_template(request, 'voters_list',
{'election': election, 'voters_page': voters_page, {'election': election, 'voters_page': voters_page,
'voters': voters_page.object_list, 'admin_p': admin_p, 'voters': voters_page.object_list, 'admin_p': admin_p,
'email_voters': VOTERS_EMAIL, 'email_voters': helios.VOTERS_EMAIL,
'limit': limit, 'total_voters': total_voters, 'limit': limit, 'total_voters': total_voters,
'upload_p': VOTERS_UPLOAD, 'q' : q, 'upload_p': helios.VOTERS_UPLOAD, 'q' : q,
'voter_files': voter_files, 'voter_files': voter_files,
'categories': categories, 'categories': categories,
'eligibility_category_id' : eligibility_category_id}) 'eligibility_category_id' : eligibility_category_id})
...@@ -1330,7 +1330,7 @@ def voters_upload_cancel(request, election): ...@@ -1330,7 +1330,7 @@ def voters_upload_cancel(request, election):
@election_admin(frozen=True) @election_admin(frozen=True)
def voters_email(request, election): def voters_email(request, election):
if not VOTERS_EMAIL: if not helios.VOTERS_EMAIL:
return HttpResponseRedirect(settings.SECURE_URL_HOST + reverse(one_election_view, args=[election.uuid])) return HttpResponseRedirect(settings.SECURE_URL_HOST + reverse(one_election_view, args=[election.uuid]))
TEMPLATES = [ TEMPLATES = [
('vote', 'Time to Vote'), ('vote', 'Time to Vote'),
...@@ -1339,11 +1339,11 @@ def voters_email(request, election): ...@@ -1339,11 +1339,11 @@ def voters_email(request, election):
('result', 'Election Result') ('result', 'Election Result')
] ]
template = request.GET.get('template', 'vote') template = request.REQUEST.get('template', 'vote')
if not template in [t[0] for t in TEMPLATES]: if not template in [t[0] for t in TEMPLATES]:
raise Exception("bad template") raise Exception("bad template")
voter_id = request.GET.get('voter_id', None) voter_id = request.REQUEST.get('voter_id', None)
if voter_id: if voter_id:
voter = Voter.get_by_election_and_voter_id(election, voter_id) voter = Voter.get_by_election_and_voter_id(election, voter_id)
......
from django.conf.urls import * from django.conf.urls.defaults import *
urlpatterns = patterns('{{ project }}.{{ app }}.views', urlpatterns = patterns('{{ project }}.{{ app }}.views',
(r'^$', 'canvas'), (r'^$', 'canvas'),
......
...@@ -50,11 +50,11 @@ def get_user_info_after_auth(request): ...@@ -50,11 +50,11 @@ def get_user_info_after_auth(request):
# get the nice name # get the nice name
http = httplib2.Http(".cache") http = httplib2.Http(".cache")
http = credentials.authorize(http) http = credentials.authorize(http)
(resp_headers, content) = http.request("https://people.googleapis.com/v1/people/me?personFields=names", "GET") (resp_headers, content) = http.request("https://www.googleapis.com/plus/v1/people/me", "GET")
response = json.loads(content) response = json.loads(content)
name = response['names'][0]['displayName'] name = response['displayName']
# watch out, response also contains email addresses, but not sure whether thsoe are verified or not # watch out, response also contains email addresses, but not sure whether thsoe are verified or not
# so for email address we will only look at the id_token # so for email address we will only look at the id_token
......
...@@ -10,7 +10,6 @@ from functools import update_wrapper ...@@ -10,7 +10,6 @@ from functools import update_wrapper
from django.http import HttpResponse, Http404, HttpResponseRedirect from django.http import HttpResponse, Http404, HttpResponseRedirect
from django.core.exceptions import * from django.core.exceptions import *
from django.conf import settings from django.conf import settings
from django.http import HttpResponseNotAllowed
import oauth import oauth
......
""" """
Authentication URLs Authentication URLs
Ben Adida (ben@adida.net) Ben Adida (ben@adida.net)
""" """
from django.conf.urls import url from django.conf.urls import *
import views from views import *
from settings import AUTH_ENABLED_AUTH_SYSTEMS from auth_systems.password import password_login_view, password_forgotten_view
from auth_systems.twitter import follow_view
urlpatterns = [ urlpatterns = patterns('',
# basic static stuff # basic static stuff
url(r'^$', views.index), (r'^$', index),
url(r'^logout$', views.logout), (r'^logout$', logout),
url(r'^start/(?P<system_name>.*)$', views.start), (r'^start/(?P<system_name>.*)$', start),
# weird facebook constraint for trailing slash # weird facebook constraint for trailing slash
url(r'^after/$', views.after), (r'^after/$', after),
url(r'^why$', views.perms_why), (r'^why$', perms_why),
url(r'^after_intervention$', views.after_intervention), (r'^after_intervention$', after_intervention),
]
## should make the following modular
# password auth # password auth
if 'password' in AUTH_ENABLED_AUTH_SYSTEMS: (r'^password/login', password_login_view),
from auth_systems.password import password_login_view, password_forgotten_view (r'^password/forgot', password_forgotten_view),
urlpatterns.append(url(r'^password/login', password_login_view))
urlpatterns.append(url(r'^password/forgot', password_forgotten_view))
# twitter # twitter
if 'twitter' in AUTH_ENABLED_AUTH_SYSTEMS: (r'^twitter/follow', follow_view),
from auth_systems.twitter import follow_view )
urlpatterns.append(url(r'^twitter/follow', follow_view))
...@@ -49,16 +49,12 @@ function do_encrypt(message) { ...@@ -49,16 +49,12 @@ function do_encrypt(message) {
// receive either // receive either
// a) an election and an integer position of the question // a) an election and an integer position of the question
// that this worker will be used to encrypt // that this worker will be used to encrypt
// {'type': 'setup', 'election': election_json} // {'type': 'setup', 'question_num' : 2, 'election' : election_json}
// //
// b) an answer that needs encrypting // b) an answer that needs encrypting
// {'type': 'encrypt', 'q_num': 2, 'id': id, 'answer': answer_json} // {'type': 'encrypt', 'answer' : answer_json}
// //
self.onmessage = function(event) { self.onmessage = function(event) {
// dispatch to method // dispatch to method
if (event.data.type === "setup") { self['do_' + event.data.type](event.data);
do_setup(event.data);
} else if (event.data.type === "encrypt") {
do_encrypt(event.data);
} }
};
...@@ -7,7 +7,7 @@ form.prettyform label,input,textarea,select { ...@@ -7,7 +7,7 @@ form.prettyform label,input,textarea,select {
line-height: 1.8; line-height: 1.8;
} }
form.prettyform label:not(.answer) { form.prettyform label {
display: block; display: block;
text-align: right; text-align: right;
float: left; float: left;
......
...@@ -26,9 +26,10 @@ Random.getRandomInteger = function(max) { ...@@ -26,9 +26,10 @@ Random.getRandomInteger = function(max) {
var bit_length = max.bitLength(); var bit_length = max.bitLength();
Random.setupGenerator(); Random.setupGenerator();
var random; var random;
random = sjcl.random.randomWords(Math.ceil(bit_length / 32) + 2, 6); random = sjcl.random.randomWords(Math.ceil(bit_length / 32)+2, 0);
// we get a bit array instead of a BigInteger in this case // we get a bit array instead of a BigInteger in this case
var rand_bi = new BigInt(sjcl.codec.hex.fromBits(random), 16); var rand_bi = new BigInt(sjcl.codec.hex.fromBits(random), 16);
return rand_bi.mod(max); return rand_bi.mod(max);
return BigInt._from_java_object(random).mod(max);
}; };
...@@ -25,11 +25,7 @@ as many as you approve of ...@@ -25,11 +25,7 @@ as many as you approve of
</p> </p>
{#foreach $T.question.answers as answer} {#foreach $T.question.answers as answer}
<div id="answer_label_{$T.question_num}_{$T.answer_ordering[$T.answer$index]}"> <div id="answer_label_{$T.question_num}_{$T.answer_ordering[$T.answer$index]}"><input type="checkbox" class="ballot_answer" id="answer_{$T.question_num}_{$T.answer_ordering[$T.answer$index]}" name="answer_{$T.question_num}_{$T.answer_ordering[$T.answer$index]}" value="yes" onclick="BOOTH.click_checkbox({$T.question_num}, {$T.answer_ordering[$T.answer$index]}, this.checked);" /> {$T.question.answers[$T.answer_ordering[$T.answer$index]]}
<input type="checkbox" class="ballot_answer" id="answer_{$T.question_num}_{$T.answer_ordering[$T.answer$index]}" name="answer_{$T.question_num}_{$T.answer_ordering[$T.answer$index]}" value="yes" onclick="BOOTH.click_checkbox({$T.question_num}, {$T.answer_ordering[$T.answer$index]}, this.checked);" />
<label class="answer" for="answer_{$T.question_num}_{$T.answer_ordering[$T.answer$index]}">
{$T.question.answers[$T.answer_ordering[$T.answer$index]]}
{#if $T.question.answer_urls && $T.question.answer_urls[$T.answer_ordering[$T.answer$index]] && $T.question.answer_urls[$T.answer_ordering[$T.answer$index]] != ""} {#if $T.question.answer_urls && $T.question.answer_urls[$T.answer_ordering[$T.answer$index]] && $T.question.answer_urls[$T.answer_ordering[$T.answer$index]] != ""}
&nbsp;&nbsp; &nbsp;&nbsp;
...@@ -37,7 +33,6 @@ as many as you approve of ...@@ -37,7 +33,6 @@ as many as you approve of
[<a target="_blank" href="{$T.question.answer_urls[$T.answer_ordering[$T.answer$index]]}" rel="noopener noreferrer">more info</a>] [<a target="_blank" href="{$T.question.answer_urls[$T.answer_ordering[$T.answer$index]]}" rel="noopener noreferrer">more info</a>]
</span> </span>
{#/if} {#/if}
</label>
</div> </div>
{#/for} {#/for}
......
...@@ -7,7 +7,7 @@ form.prettyform label,input,textarea,select { ...@@ -7,7 +7,7 @@ form.prettyform label,input,textarea,select {
line-height: 1.8; line-height: 1.8;
} }
form.prettyform label:not(.answer) { form.prettyform label {
display: block; display: block;
text-align: right; text-align: right;
float: left; float: left;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment