Commit 06545fed authored by Claude Paroz's avatar Claude Paroz

Migrate openid library used

django-openid is not actively maintained. Apparently, django-openid-auth
is a fork by Canonical, more polished.
Embedded django-openid is left in the tree for the migration duration.
parent ec437897
......@@ -37,7 +37,7 @@ Requirements
git clone git://github.com/dcramer/django-debug-toolbar.git
Define USE_DEBUG_TOOLBAR to True in local_settings.py to use it.
8 - [Optional] python-openid and django-openid (see OpenID support
8 - [Optional] python-openid and django-openid-auth (see OpenID support
below).
9 - [Optional] python-pyicu for correct sorting in various languages
......@@ -83,17 +83,22 @@ It might be useful to add the command in a cron schedule.
OpenID support
==============
If you want OpenID support, checkout Simon Willison's django-openid
package:
If you want OpenID support, install django-openid-auth package:
git clone git://github.com/simonw/django-openid.git
http://pypi.python.org/pypi/django-openid-auth/
Put it somewhere in your Python path and set USE_DJANGO_OPENID to True in your
local_settings.py.
Set USE_DJANGO_OPENID to True in your local_settings.py.
This package is dependant on the python-openid package to be installed
on your system. Run 'python manage.py syncdb' and here we go!
Note: if you are using MySQL, you should modify a table column in models.py
of django-openid-auth:
Change:
claimed_id = models.TextField(max_length=2047, unique=True)
To:
claimed_id = models.CharField(max_length=255, unique=True)
See bug http://code.djangoproject.com/ticket/2495
Databases
=========
......
# encoding: utf-8
import datetime
from south.db import db
from south.v2 import DataMigration
from django.db import models
class Migration(DataMigration):
def forwards(self, orm):
"Write your forwards methods here."
try:
from django_openid import models
from django_openid_auth import models as new_models
except ImportError:
# skip migration
pass # return
import pdb; pdb.set_trace()
"""for nonce in models.Nonce.objects.all():
new_nonce = new_models.Nonce.objects.create(server_url=nonce.server_url, timestamp=nonce.timestamp, salt=nonce.salt)
for assoc in models.Association.objects.all():
new_assoc = new_models.Association.objects.create(server_url=assoc.server_url, handle=assoc.handle, secret=assoc.secret, issued=assoc.issued, lifetime=assoc.lifetime, assoc_type=assoc.assoc_type)"""
for user_assoc in models.UserOpenidAssociation.objects.all():
new_uassoc = new_models.UserOpenID.objects.create(user=user_assoc.user, claimed_id=user_assoc.openid, display_id=user_assoc.openid)
def backwards(self, orm):
"Write your backwards methods here."
models = {
}
complete_apps = ['common']
......@@ -82,12 +82,13 @@ def site_login(request):
else:
referer = request.META.get('HTTP_REFERER', None)
if 'django_openid' in settings.INSTALLED_APPS:
openid_path = '/openid/'
if 'django_openid_auth' in settings.INSTALLED_APPS:
openid_path = '/openid/login/'
context = {
'pageSection': 'home',
'openid_path': openid_path,
'referer': referer,
'next': referer,
}
return render_to_response('login.html', context, context_instance=RequestContext(request))
......@@ -100,7 +101,7 @@ def site_register(request):
return HttpResponseRedirect(reverse('register_success'))
else:
form = RegistrationForm()
if 'django_openid' in settings.INSTALLED_APPS:
if 'django_openid_auth' in settings.INSTALLED_APPS:
openid_path = '/openid/'
context = {
'pageSection': 'home',
......
......@@ -138,6 +138,7 @@ INSTALLED_APPS = (
INTERNAL_IPS=('127.0.0.1',)
MESSAGE_STORAGE = 'django.contrib.messages.storage.fallback.FallbackStorage'
LOGIN_REDIRECT_URL = '/'
try:
from local_settings import *
......@@ -149,4 +150,12 @@ if USE_DEBUG_TOOLBAR:
INSTALLED_APPS += ('debug_toolbar',)
if USE_DJANGO_OPENID:
INSTALLED_APPS += ('django_openid',)
INSTALLED_APPS += ('django_openid_auth',)
AUTHENTICATION_BACKENDS = (
'django_openid_auth.auth.OpenIDBackend',
'django.contrib.auth.backends.ModelBackend',
)
OPENID_CREATE_USERS = True
OPENID_UPDATE_DETAILS_FROM_SREG = True
OPENID_UPDATE_DETAILS_FROM_AX = True
......@@ -34,11 +34,14 @@
<p>{% trans 'Or use your OpenID:' %}</p>
<form action="{{ openid_path }}" method="post" id="openid-login-form" class="login">
<div class="form-row">
<label for="id_openid"><img src="{{ openid_path }}logo/" alt=""> {% trans 'OpenID:' %}</label> <input type="text" name="openid_url" id="id_openid" />
<label for="id_openid_identifier"><img src="{% url openid-logo %}" alt=""> {% trans 'OpenID:' %}</label> <input type="text" name="openid_identifier" id="id_openid_identifier" />
</div>
<div class="submit-row">
<label>&nbsp;</label><input type="submit" value="{% trans 'Log in with OpenID' %}" />
</div>
{% if next %}
<input type="hidden" name="next" value="{{ next }}" />
{% endif %}
</form>
{% endif %}
......
......@@ -84,11 +84,9 @@ urlpatterns += patterns('stats.views',
view = 'compare_by_releases'),
)
if 'django_openid' in settings.INSTALLED_APPS:
from django_openid.auth import AuthConsumer
if 'django_openid_auth' in settings.INSTALLED_APPS:
urlpatterns += patterns('',
(r'^openid/(.*)', AuthConsumer()),
(r'^openid/', include('django_openid_auth.urls')),
)
if settings.STATIC_SERVE:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment