Skip to content

Commit

Permalink
Manual review and fix of previous commit
Browse files Browse the repository at this point in the history
 * keep "/auth/" in URLs
 * revert unrelated uses of "auth" in comments and facebookclient
 * fix migration scripts to cope with the renaming of the SQL table
   "auth_user" to "helios_auth_user"
  • Loading branch information
glondu authored and benadida committed Feb 23, 2013
1 parent afe8597 commit 694adba
Show file tree
Hide file tree
Showing 25 changed files with 55 additions and 55 deletions.
2 changes: 1 addition & 1 deletion helios/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ def set_eligibility(self):
if self.voter_set.filter(user=None).count() > 0:
voter_types.append('password')
else:
# no password users, remove password from the possible helios_auth systems
# no password users, remove password from the possible auth systems
if 'password' in auth_systems:
auth_systems.remove('password')

Expand Down
2 changes: 1 addition & 1 deletion helios/templates/cast_done.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ <h1>{{election.name}} &mdash; Vote Successfully Cast!</h1>

{% if logout %}
<p><b>For your safety, we have logged you out.</b></p>
<iframe width="0" height="0" border="0" frameborder="0" src="/helios_auth/logout">
<iframe width="0" height="0" border="0" frameborder="0" src="/auth/logout">
</iframe>
{% endif %}

Expand Down
2 changes: 1 addition & 1 deletion helios/templates/election_bboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ <h2 class="title">{{election.name}} &mdash; Ballot Tracking Center <span style="
{% if election.use_voter_aliases %}
{{voter.alias}}
{% else %}
<img border="0" height="20" src="/static/helios_auth/login-icons/{{voter.voter_type}}.png" alt="{{voter.voter_type}}" /> {% if voter.name %}{{voter.name}}{% else %}{{voter.voter_id}}{% endif %}
<img border="0" height="20" src="/static/auth/login-icons/{{voter.voter_type}}.png" alt="{{voter.voter_type}}" /> {% if voter.name %}{{voter.name}}{% else %}{{voter.voter_id}}{% endif %}
{% endif %}</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.voter_last_vote election_uuid=election.uuid,voter_uuid=voter.uuid %}">view</a>]</span>{% else %}&mdash;{% endif %}</tt></td></tr>
{% endfor %}
</table>
Expand Down
2 changes: 1 addition & 1 deletion helios/templates/voters_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ <h2 class="title">{{election.name}} &mdash; Voters and Ballot Tracking Center <s
[<a href="{% url helios.views.voters_email election.uuid %}?voter_id={{voter.voter_login_id}}">email</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>]
{% endif %}
<img border="0" height="20" src="/static/helios_auth/login-icons/{{voter.voter_type}}.png" alt="{{voter.voter_type}}" /> {{voter.name}}</td>
<img border="0" height="20" src="/static/auth/login-icons/{{voter.voter_type}}.png" alt="{{voter.voter_type}}" /> {{voter.name}}</td>
{% endif %}
{% if election.use_voter_aliases %}
<td>{{voter.alias}}</td>
Expand Down
2 changes: 1 addition & 1 deletion helios/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ def test_election_creation_not_logged_in(self):
"use_advanced_audit_features": "1",
"private_p" : "0"})

self.assertRedirects(response, "/helios_auth/?return_url=/helios/elections/new")
self.assertRedirects(response, "/auth/?return_url=/helios/elections/new")

def test_election_edit(self):
# a bogus call to set up the session
Expand Down
2 changes: 1 addition & 1 deletion helios/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def get_socialbuttons_url(url, text):


##
## remote helios_auth utils
## remote auth utils

def user_reauth(request, user):
# FIXME: should we be wary of infinite redirects here, and
Expand Down
2 changes: 1 addition & 1 deletion helios_auth/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

TEMPLATE_BASE = settings.AUTH_TEMPLATE_BASE or "helios_auth/templates/base.html"

# enabled helios_auth systems
# enabled auth systems
import auth_systems
ENABLED_AUTH_SYSTEMS = settings.AUTH_ENABLED_AUTH_SYSTEMS or auth_systems.AUTH_SYSTEMS.keys()
DEFAULT_AUTH_SYSTEM = settings.AUTH_DEFAULT_AUTH_SYSTEM or None
Expand Down
2 changes: 1 addition & 1 deletion helios_auth/auth_systems/facebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def get_user_info_after_auth(request):

def update_status(user_id, user_info, token, message):
"""
post a message to the helios_auth system's update stream, e.g. twitter stream
post a message to the auth system's update stream, e.g. twitter stream
"""
result = facebook_post('/me/feed', {
'access_token': token['access_token'],
Expand Down
32 changes: 16 additions & 16 deletions helios_auth/auth_systems/facebookclient/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ class json(object): pass
],
},

# helios_auth methods
'helios_auth': {
# auth methods
'auth': {
'revokeAuthorization': [
('uid', int, ['optional']),
],
Expand Down Expand Up @@ -655,10 +655,10 @@ def __str__(self):


class AuthProxy(AuthProxy):
"""Special proxy for facebook.helios_auth."""
"""Special proxy for facebook.auth."""

def getSession(self):
"""Facebook API call. See http://developers.facebook.com/documentation.php?v=1.0&method=helios_auth.getSession"""
"""Facebook API call. See http://developers.facebook.com/documentation.php?v=1.0&method=auth.getSession"""
args = {}
try:
args['auth_token'] = self._client.auth_token
Expand All @@ -672,7 +672,7 @@ def getSession(self):
return result

def createToken(self):
"""Facebook API call. See http://developers.facebook.com/documentation.php?v=1.0&method=helios_auth.createToken"""
"""Facebook API call. See http://developers.facebook.com/documentation.php?v=1.0&method=auth.createToken"""
token = self._client('%s.createToken' % self._name)
self._client.auth_token = token
return token
Expand Down Expand Up @@ -829,7 +829,7 @@ class Facebook(object):
to canvas pages.
auth_token
The helios_auth token that Facebook gives you, either with facebook.helios_auth.createToken,
The auth token that Facebook gives you, either with facebook.auth.createToken,
or through a GET parameter.
callback_path
Expand Down Expand Up @@ -882,15 +882,15 @@ class Facebook(object):
Your application's secret key, as set in the constructor.
session_key
The current session key. Set automatically by helios_auth.getSession, but can be set
The current session key. Set automatically by auth.getSession, but can be set
manually for doing infinite sessions.
session_key_expires
The UNIX time of when this session key expires, or 0 if it never expires.
uid
After a session is created, you can get the user's UID with this variable. Set
automatically by helios_auth.getSession.
automatically by auth.getSession.
----------------------------------------------------------------------
Expand All @@ -902,15 +902,15 @@ def __init__(self, api_key, secret_key, auth_token=None, app_name=None, callback
If this is a desktop application, the next couple of steps you might want to take are:
facebook.helios_auth.createToken() # create an helios_auth token
facebook.auth.createToken() # create an auth token
facebook.login() # show a browser window
wait_login() # somehow wait for the user to log in
facebook.helios_auth.getSession() # get a session key
facebook.auth.getSession() # get a session key
For web apps, if you are passed an auth_token from Facebook, pass that in as a named parameter.
Then call:
facebook.helios_auth.getSession()
facebook.auth.getSession()
"""
self.api_key = api_key
Expand Down Expand Up @@ -1034,7 +1034,7 @@ def _add_session_args(self, args=None):
if not self.session_key:
return args
#some calls don't need a session anymore. this might be better done in the markup
#raise RuntimeError('Session key not set. Make sure helios_auth.getSession has been called.')
#raise RuntimeError('Session key not set. Make sure auth.getSession has been called.')

args['session_key'] = self.session_key
args['call_id'] = str(int(time.time() * 1000))
Expand Down Expand Up @@ -1226,7 +1226,7 @@ def request_extended_permission(self, ext_perm, popup=False):
def check_session(self, request):
"""
Checks the given Django HttpRequest for Facebook parameters such as
POST variables or an helios_auth token. If the session is valid, returns True
POST variables or an auth token. If the session is valid, returns True
and this object can now be used to access the Facebook API. Otherwise,
it returns False, and the application should take the appropriate action
(either log the user in or have him add the application).
Expand All @@ -1251,7 +1251,7 @@ def check_session(self, request):
self.auth_token = request.GET['auth_token']

try:
self.helios_auth.getSession()
self.auth.getSession()
except FacebookError, e:
self.auth_token = None
return False
Expand Down Expand Up @@ -1396,7 +1396,7 @@ def validate_cookie_signature(self, cookies):

facebook = Facebook(api_key, secret_key)

facebook.helios_auth.createToken()
facebook.auth.createToken()

# Show login window
# Set popup=True if you want login without navigational elements
Expand All @@ -1406,7 +1406,7 @@ def validate_cookie_signature(self, cookies):
print 'After logging in, press enter...'
raw_input()

facebook.helios_auth.getSession()
facebook.auth.getSession()
print 'Session Key: ', facebook.session_key
print 'Your UID: ', facebook.uid

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
def messages(request):
"""Returns messages similar to ``django.core.context_processors.helios_auth``."""
"""Returns messages similar to ``django.core.context_processors.auth``."""
if hasattr(request, 'facebook') and request.facebook.uid is not None:
from models import Message
messages = Message.objects.get_and_delete_all(uid=request.facebook.uid)
Expand Down
2 changes: 1 addition & 1 deletion helios_auth/auth_systems/facebookclient/webappfb.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def initialize(self, request, response):
return

if not (require_app or require_login) and need_session:
self.facebook.helios_auth.getSession()
self.facebook.auth.getSession()

def redirect(self, url, **kwargs):
"""
Expand Down
2 changes: 1 addition & 1 deletion helios_auth/auth_systems/google.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

# FIXME!
# TRUST_ROOT = 'http://localhost:8000'
# RETURN_TO = 'http://localhost:8000/helios_auth/after'
# RETURN_TO = 'http://localhost:8000/auth/after'

def get_auth_url(request, redirect_url):
# FIXME?? TRUST_ROOT should be diff than return_url?
Expand Down
2 changes: 1 addition & 1 deletion helios_auth/auth_systems/linkedin.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def _get_client_by_request(request):

def update_status(user_id, user_info, token, message):
"""
post a message to the helios_auth system's update stream, e.g. twitter stream
post a message to the auth system's update stream, e.g. twitter stream
"""
return
#twitter_client = _get_client_by_token(token)
Expand Down
2 changes: 1 addition & 1 deletion helios_auth/auth_systems/live.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def get_user_info_after_auth(request):

def update_status(user_id, user_info, token, message):
"""
post a message to the helios_auth system's update stream, e.g. twitter stream
post a message to the auth system's update stream, e.g. twitter stream
"""
result = facebook_post('/me/feed', {
'access_token': token['access_token'],
Expand Down
2 changes: 1 addition & 1 deletion helios_auth/auth_systems/twitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def _get_client_by_request(request):

def update_status(user_id, user_info, token, message):
"""
post a message to the helios_auth system's update stream, e.g. twitter stream
post a message to the auth system's update stream, e.g. twitter stream
"""
twitter_client = _get_client_by_token(token)
result = twitter_client.oauth_request('http://api.twitter.com/1/statuses/update.json', args={'status': message}, method='POST')
Expand Down
8 changes: 4 additions & 4 deletions helios_auth/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Migration(SchemaMigration):
def forwards(self, orm):

# Adding model 'User'
db.create_table('auth_user', (
db.create_table('helios_auth_user', (
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('user_type', self.gf('django.db.models.fields.CharField')(max_length=50)),
('user_id', self.gf('django.db.models.fields.CharField')(max_length=100)),
Expand All @@ -21,16 +21,16 @@ def forwards(self, orm):
db.send_create_signal('helios_auth', ['User'])

# Adding unique constraint on 'User', fields ['user_type', 'user_id']
db.create_unique('auth_user', ['user_type', 'user_id'])
db.create_unique('helios_auth_user', ['user_type', 'user_id'])


def backwards(self, orm):

# Removing unique constraint on 'User', fields ['user_type', 'user_id']
db.delete_unique('auth_user', ['user_type', 'user_id'])
db.delete_unique('helios_auth_user', ['user_type', 'user_id'])

# Deleting model 'User'
db.delete_table('auth_user')
db.delete_table('helios_auth_user')


models = {
Expand Down
6 changes: 3 additions & 3 deletions helios_auth/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ def is_eligible_for(self, eligibility_case):
if not eligibility_case.has_key('constraint'):
return True

# from here on we know we match the helios_auth system, but do we match one of the constraints?
# from here on we know we match the auth system, but do we match one of the constraints?

auth_system = AUTH_SYSTEMS[self.user_type]

# does the helios_auth system allow for checking a constraint?
# does the auth system allow for checking a constraint?
if not hasattr(auth_system, 'check_constraint'):
return False

Expand Down Expand Up @@ -153,7 +153,7 @@ def _display_html(self, size):
else:
name_display = self.pretty_name

return """<img border="0" height="%s" src="/static/helios_auth/login-icons/%s.png" alt="%s" /> %s""" % (
return """<img border="0" height="%s" src="/static/auth/login-icons/%s.png" alt="%s" /> %s""" % (
str(int(size)), self.user_type, self.user_type, name_display)

@property
Expand Down
2 changes: 1 addition & 1 deletion helios_auth/security/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Generic Security -- for the helios_auth system
Generic Security -- for the auth system
Ben Adida ([email protected])
"""
Expand Down
2 changes: 1 addition & 1 deletion helios_auth/templates/login_box.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{% else %}
<p>
<a href="{{SECURE_URL_HOST}}{% url helios_auth.views.start system_name=auth_system %}?return_url={{return_url}}" style="font-size: 1.4em;">
<img border="0" height="35" src="/static/helios_auth/login-icons/{{auth_system}}.png" alt="{{auth_system}}" /> {{auth_system}}
<img border="0" height="35" src="/static/auth/login-icons/{{auth_system}}.png" alt="{{auth_system}}" /> {{auth_system}}
{% endifequal %}
</a>
</p>
Expand Down
2 changes: 1 addition & 1 deletion helios_auth/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

## should make the following modular

# password helios_auth
# password auth
(r'^password/login', password_login_view),
(r'^password/forgot', password_forgotten_view),

Expand Down
6 changes: 3 additions & 3 deletions helios_auth/view_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ def prepare_vars(request, vars):
vars_with_user['csrf_token'] = request.session['csrf_token']
vars_with_user['SECURE_URL_HOST'] = settings.SECURE_URL_HOST

vars_with_user['STATIC'] = '/static/helios_auth'
vars_with_user['MEDIA_URL'] = '/static/helios_auth/'
vars_with_user['STATIC'] = '/static/auth'
vars_with_user['MEDIA_URL'] = '/static/auth/'
vars_with_user['TEMPLATE_BASE'] = helios_auth.TEMPLATE_BASE

vars_with_user['settings'] = settings
Expand All @@ -45,7 +45,7 @@ def render_template(request, template_name, vars = {}):

vars_with_user = prepare_vars(request, vars)

return render_to_response('helios_auth/templates/%s.html' % template_name, vars_with_user)
return render_to_response('auth/templates/%s.html' % template_name, vars_with_user)

def render_template_raw(request, template_name, vars={}):
t = loader.get_template(template_name + '.html')
Expand Down
12 changes: 6 additions & 6 deletions helios_auth/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def index(request):

user = get_user(request)

# single helios_auth system?
# single auth system?
if len(helios_auth.ENABLED_AUTH_SYSTEMS) == 1 and not user:
return HttpResponseRedirect(reverse(start, args=[helios_auth.ENABLED_AUTH_SYSTEMS[0]])+ '?return_url=' + request.GET.get('return_url', ''))

Expand All @@ -55,7 +55,7 @@ def login_box_raw(request, return_url='/', auth_systems = None):
if helios_auth.DEFAULT_AUTH_SYSTEM:
default_auth_system_obj = AUTH_SYSTEMS[helios_auth.DEFAULT_AUTH_SYSTEM]

# make sure that auth_systems includes only available and enabled helios_auth systems
# make sure that auth_systems includes only available and enabled auth systems
if auth_systems != None:
enabled_auth_systems = set(auth_systems).intersection(set(helios_auth.ENABLED_AUTH_SYSTEMS)).intersection(set(AUTH_SYSTEMS.keys()))
else:
Expand Down Expand Up @@ -109,7 +109,7 @@ def do_remote_logout(request, user, return_url="/"):
# FIXME: do something with return_url
auth_system = AUTH_SYSTEMS[user['type']]

# does the helios_auth system have a special logout procedure?
# does the auth system have a special logout procedure?
user_for_remote_logout = request.session.get('user_for_remote_logout', None)
del request.session['user_for_remote_logout']
if hasattr(auth_system, 'do_logout'):
Expand Down Expand Up @@ -159,7 +159,7 @@ def start(request, system_name):
# why is this here? Let's try without it
# request.session.save()

# store in the session the name of the system used for helios_auth
# store in the session the name of the system used for auth
request.session['auth_system_name'] = system_name

# where to return to when done
Expand All @@ -174,7 +174,7 @@ def perms_why(request):
return _do_auth(request)

def after(request):
# which helios_auth system were we using?
# which auth system were we using?
if not request.session.has_key('auth_system_name'):
do_local_logout(request)
return HttpResponseRedirect("/")
Expand All @@ -192,7 +192,7 @@ def after(request):
else:
return HttpResponseRedirect("%s?%s" % (reverse(perms_why), urllib.urlencode({'system_name' : request.session['auth_system_name']})))

# does the helios_auth system want to present an additional view?
# does the auth system want to present an additional view?
# this is, for example, to prompt the user to follow @heliosvoting
# so they can hear about election results
if hasattr(system, 'user_needs_intervention'):
Expand Down
Loading

0 comments on commit 694adba

Please sign in to comment.