simonw / django-openid Goto Github PK
View Code? Open in Web Editor NEWA modern library for integrating OpenID with Django - incomplete, but really nearly there (promise)
A modern library for integrating OpenID with Django - incomplete, but really nearly there (promise)
django_openid ============= A new take on Django/OpenID integration, making extensive use of class-based views. Caution: Work in Progress It's not ready yet! However, you are welcome to dive in to the code or take a look at the in-progress documentation in django_openid/docs (which can be built using Sphinx).
Adding the admin interface the demo projects would help to understand what is going on. It would also help to understand how the "monkeypatch_adminsite" is supposed to be used. Reading the source I am under the impression that this function should add the capability to login into the admin interface using openid .
admin.autodiscover()
admin_site = admin.site
monkeypatch_adminsite(admin_site)
class NoSignNext(RegistrationConsumer):
sign_next_param = False
urlpatterns = patterns('',
(r'^$', lambda r: HttpResponseRedirect('/openid/')),
(r'^openid/(.*)', NoSignNext()),
(r'^admin/', include(admin_site.urls)),
)
Using the code above does not change the login form to add an openid field. Could you please point me what I am missing ?
Thank you for this library full of gems.
Regards,
--yml
I don't think this is something django-openid should fix (since TemplateResponse might need some Django love to work correctly), but since it is included I'll just mention it here. TemplateResponse doesn't render the template until the last possible second. This has some great advantages, but disadvantages too because Django isn't aware that the HttpResponse will do this. This results in template rendering to happen in the WSGI handler outside of the base handler. As a result request.urlconf won't work since by this point it has been reverted back to ROOT_URLCONF (in Django). Furthermore any exceptions that occur during rendering bypass the base handlers lovely debug screen in DEBUG=True mode (any base handler exception handling code).
Even with both password fields filled out correctly the error "This field cannot be blank." is always shown.
With updating
fields = ('username', 'first_name', 'last_name', 'email')
to
fields = ('username', 'first_name', 'last_name', 'email', 'password')
the registration works for non-OpenID, but with OpenID it fails again.
I think this is because the password field of User model is always required, no matter what the form says.
Anyway, I forked it: http://github.com/and3k/django-openid/commit/df911f2a1676f58adb0b616e369627ef37b109b7
Unit test to repro is below. Note that MemoryStore, which is included with the python-openid lib, passes the test. I believe the problem can be fixed by deleting line 97 of models.py: "nonce.delete()".
def testStore(self):
store = MemoryStore()
store = DjangoOpenIDStore()
server_url = 'http://foo.com/'
timestamp = time.time()
salt = '123'
assert store.useNonce(server_url, timestamp, salt),\
'useNonce should return True the first time: '+str(store)
for i in range(10):
assert not store.useNonce(server_url, timestamp, salt),\
'useNonce should return False after that: '+str(store)
The default templates are useless with out multiple language support?
When the context processor django.middleware.csrf.CsrfViewMiddleware from Django 1.2.1 is active, the login form triggers a CSRF attempt error.
Hi,
When using django_openid
in a Django 1.3 project, there will be an error with the returned TemplateResponse
object.
When the response object has a render()
function (as TemplateResponse
has), Django 1.3 will call the add_post_render_callback()
function of that response. This method is available in django.template.response.TemplateResponse
, but not in the copy at django_openid.response.TemplateResponse
.
The obvious result is a 500 error, which bit me already quite.
The easy fix is not using an own copy of the TemplateResponse
object when using Django 1.3
I believe this easily can be documented, e.g.
add the OpenIDInline to your own user admin inlines list or add this code in your project:
from django.contrib.auth.admin import UserAdmin
from django.contrib import admin
from django.contrib.admin.sites import NotRegistered
from django_openid.admin import UserAdminWithOpenIDs
# Add OpenIDs to the user admin, but only if User has been registered
try:
admin.site.unregister(User)
admin.site.register(User, UserAdminWithOpenIDs)
except NotRegistered:
pass
Non-OpenID accounts can login, before confirming their account via email.
My patch: http://github.com/and3k/django-openid/commit/7df7ea6fab3b2b85f98366b5b83781eda8ffd00d
I don't know exactly what's happening, but I'm getting this error from time to time:
Traceback (most recent call last):
File "/usr/local/www/gnomeweb/python-packages/django/core/handlers/base.py", line 100, in get_response
response = callback(request, _callback_args, *_callback_kwargs)
File "/var/www/djamnedlies/django_openid/consumer.py", line 157, in call
return router(request, path_override = rest_of_url)
File "/var/www/djamnedlies/django_openid/utils.py", line 67, in call
return self.handle(request, path_override)
File "/var/www/djamnedlies/django_openid/utils.py", line 64, in handle
return callback(request, _callback_args, *_callback_kwargs)
File "/var/www/djamnedlies/../djamnedlies/django_openid/auth.py", line 172, in do_pick
if not request.openid:
AttributeError: 'WSGIRequest' object has no attribute 'openid'
show_pick_account() doesn't do any checks if the accounts are active.
Heres the patch: http://github.com/and3k/django-openid/commit/adf3022872c0914146c36478e0944fae1bf2f903
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.