Implementing a SOA in Django using celery

celery, django, django-celery

Solution

A message queue (such as rabbitmq brokered by celery) is a perfectly fine way to handle communication between SOA components. Additionally, if you need real-time communication without sharing databases between services, REST is basically made for this. There are several options for implementing REST services on top of Django, with Tastypie and Django-Rest-Framework being popular choices.

As for passing authentication between components, Django has several options for this. Contrary to popular opinion, the Django authentication framework is extremely flexible, supporting authorization/authentication against anything you can write a backend for. See https://docs.djangoproject.com/en/dev/topics/auth/#writing-an-authentication-backend for documentation on this.

There are numerous examples of this already:

- Consume ZenDesk's SSO: http://www.jongales.com/blog/2009/05/12/zendesk-remote-authentication-with-django/

- Consume SSO from numerous social networks: django-social-auth or django-allauth

- Consume LDAP: http://packages.python.org/django-auth-ldap/

As for publishing auth, there are fewer options, but these include:

- SAML: https://opensourcemissions.wordpress.com/2010/08/19/django-saml-2-0-identity-provider/

- Oauth: http://djangopackages.com/search/?q=oauth

I strongly suggest using a provider package already built and tested over rolling your own. Implementing SSO is deceptively tricky.

Problem

I want to implement a web app with a SOA design. I am thinking of using celery in conjunction with Django to do this. But I have some questions: - Is this the correct way to go in order to implement a SOA design for Django - Assuming that this is the way to go, how would I accomplish authentication within the Django framework. Specifically, I would like authentication to be decoupled with a producer and consumer pattern. That way, a REST api (or anything for that matter) can be used to produce the authentication credentials, and a consumer (within the Django framework) can be used to read and act upon the credentials. Again, should I do the above with Celery in Django?

Original source