Skip to content
Snippets Groups Projects
Commit 889fdd92 authored by Lukáš Nový's avatar Lukáš Nový
Browse files

PirateID support

parent b07c43de
Branches
Tags
No related merge requests found
AUTH_SYSTEMS = {} AUTH_SYSTEMS = {}
import twitter, password, cas, facebook, google, yahoo, linkedin import twitter, password, cas, facebook, google, yahoo, linkedin, pirateid
AUTH_SYSTEMS['twitter'] = twitter AUTH_SYSTEMS['twitter'] = twitter
AUTH_SYSTEMS['linkedin'] = linkedin AUTH_SYSTEMS['linkedin'] = linkedin
AUTH_SYSTEMS['password'] = password AUTH_SYSTEMS['password'] = password
...@@ -9,6 +9,7 @@ AUTH_SYSTEMS['cas'] = cas ...@@ -9,6 +9,7 @@ AUTH_SYSTEMS['cas'] = cas
AUTH_SYSTEMS['facebook'] = facebook AUTH_SYSTEMS['facebook'] = facebook
AUTH_SYSTEMS['google'] = google AUTH_SYSTEMS['google'] = google
AUTH_SYSTEMS['yahoo'] = yahoo AUTH_SYSTEMS['yahoo'] = yahoo
AUTH_SYSTEMS['pirateid'] = pirateid
# not ready # not ready
#import live #import live
......
"""
Yahoo Authentication
"""
from django.http import *
from django.core.mail import send_mail
from django.conf import settings
import sys, os, cgi, urllib, urllib2, re
from xml.etree import ElementTree
from openid import view_helpers
# some parameters to indicate that status updating is not possible
STATUS_UPDATES = False
# display tweaks
LOGIN_MESSAGE = "Log in with my PirateID"
OPENID_ENDPOINT = 'https://openid.pirati.cz'
def get_auth_url(request, redirect_url):
request.session['pirateid_redirect_url'] = redirect_url
url = view_helpers.start_openid(request.session, OPENID_ENDPOINT, redirect_url, redirect_url)
return url
def get_user_info_after_auth(request):
data = view_helpers.finish_openid(request.session, request.GET, request.session['pirateid_redirect_url'])
return {'type' : 'pirateid', 'user_id': data['ax']['email'][0], 'name': data['ax']['fullname'][0], 'info': {'email': data['ax']['email'][0]}, 'token':{}}
def do_logout(user):
"""
logout of Yahoo
"""
return None
def update_status(token, message):
"""
simple update
"""
pass
def send_message(user_id, user_name, user_info, subject, body):
"""
send email to yahoo user, user_id is email for yahoo and other openID logins.
"""
send_mail(subject, body, settings.SERVER_EMAIL, ["%s <%s>" % (user_name, user_id)], fail_silently=False)
def check_constraint(constraint, user_info):
"""
for eligibility
"""
pass
...@@ -76,7 +76,7 @@ MEDIA_URL = '' ...@@ -76,7 +76,7 @@ MEDIA_URL = ''
STATIC_URL = '/media/' STATIC_URL = '/media/'
# Make this unique, and don't share it with anybody. # Make this unique, and don't share it with anybody.
SECRET_KEY = get_from_env('SECRET_KEY', 'replaceme') SECRET_KEY = get_from_env('SECRET_KEY', 'replacemesadfasdfasdf')
# Secure Stuff # Secure Stuff
if (get_from_env('SSL', '0') == '1'): if (get_from_env('SSL', '0') == '1'):
...@@ -160,7 +160,7 @@ LOGOUT_ON_CONFIRMATION = True ...@@ -160,7 +160,7 @@ LOGOUT_ON_CONFIRMATION = True
# The two hosts are here so the main site can be over plain HTTP # The two hosts are here so the main site can be over plain HTTP
# while the voting URLs are served over SSL. # while the voting URLs are served over SSL.
URL_HOST = get_from_env("URL_HOST", "http://localhost:8000").rstrip("/") URL_HOST = get_from_env("URL_HOST", "http://helios-server-lnovy.c9.io").rstrip("/")
# IMPORTANT: you should not change this setting once you've created # IMPORTANT: you should not change this setting once you've created
# elections, as your elections' cast_url will then be incorrect. # elections, as your elections' cast_url will then be incorrect.
...@@ -260,3 +260,6 @@ djcelery.setup_loader() ...@@ -260,3 +260,6 @@ djcelery.setup_loader()
# for testing # for testing
TEST_RUNNER = 'djcelery.contrib.test_runner.CeleryTestSuiteRunner' TEST_RUNNER = 'djcelery.contrib.test_runner.CeleryTestSuiteRunner'
# this effectively does CELERY_ALWAYS_EAGER = True # this effectively does CELERY_ALWAYS_EAGER = True
SESSION_SERIALIZER='django.contrib.sessions.serializers.PickleSerializer'
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment