Auth Backend for Django based Applications
License
miing/mci_migo_packages_django-oauth-backend
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Django OAuth Backend ==================== `Django OAuth Backend`_ is a set of Django_ models which are required for implementing OAuth_ protocol on the server side. Those models can be used together with various other projects which implement HTTP part of the protocol. One such projects is `lazr.authentication`_. Usage ----- Usage is quite simple. First thing is to add this application to Django's ``INSTALLED_APPS`` list:: INSTALLED_APPS = ( ... 'oauth_backend' ) Next is to integrate it with OAuth_ protocol provider, like `lazr.authentication`_. It will look something like that:: # Application's WSGI file from django.core.handlers.wsgi import WSGIHandler from lazr.authentication.wsgi import OAuthMiddleware from oauth_backend.models import DataStore, Consumer, Token def oauth_authenticate(oauth_consumer, oauth_token, parameters): try: consumer = Consumer.objects.get( user__username=oauth_consumer.key ) token = Token.objects.get(token=oauth_token.key) if token.consumer.key == oauth_consumer.key: return consumer.user except (Token.DoesNotExist, Consumer.DoesNotExist): return None django = WSGIHandler() application = OAuthMiddleware( django, authenticate_with=oauth_authenticate, data_store=DataStore(), protect_path_pattern="/protected" ) .. note:: Where ``oauth_authenticate`` is function which checks that OAuth_ token is known. Additionally you can check that user associated with this token is allowed to use it, or that token itself is not expired. Because that part is highly dependant on the mechanisms of application itself it's not provided out of the box. History ------- This code was extracted from `Canonical Identity Provider`_ project. Although an extra effort was made to make sure that all dependencies are broken and this code is fully independent, it's conceivable that some small things were missed. In that case please report those bugs on the `project's bug page`_. .. _OAuth: http://oauth.net/ .. _Django: http://www.djangoproject.com/ .. _Django OAuth Backend: http://launchpad.net/django-oauth-backend .. _lazr.authentication: http://launchpad.net/lazr.authentication .. _Canonical Identity Provider: http://launchpad.net/canonical-identity-provider .. _project's bug page: http://bugs.launchpad.net/django-oauth-backend
About
Auth Backend for Django based Applications
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published