tags:

views:

20

answers:

1

I have existing Java application that is using Acegi for authentication/authorization. Our new web interface would be preferably written in Django. I would like Django to maintain users - registration etc. Django would either share or update Acegi authentication data so the older application still works and users don't have to use two sets of credentials (maybe even share authentication cookie). I was wondering if someone was already dealing with similar issue and if yes which approach was chosen.

Thanks

A: 

Just remember whatever you do with Django, it is still Python, therefore just because Django doesn't have it/doesn't do it that way, doesn't mean you can't. Also, from another point of view, there is nothing stopping you using bits of the Django framework from outside the traditional Django application.

I don't particularly like the admin interface to Django although I do use Form and ModelForm a lot outside of it. I actually implemented my own authentication system - all you need are functions that let you log in/out etc and an interface to that data. It (users/groups etc) doesn't have to be represented as a Django model although that's what I did for ease. There is nothing stopping you hooking in another ORM or writing your own for acegi. Alternatively, if writing your own layer is simple enough, do that.

I'd recommend hooking into the context processors for Django and the Django middleware and library-ising your work simply because it'll make re-use a breeze and it will act in a similar manner to the existing authentication framework. Here's an example context processor I use to allow me to write {{ username }} in my template without having to get it out of every request object in every view method:

def Authentication(request):
    if AuthenticationCheck(sess=request.session, timeofaction=datetime.datetime.now(), ipaddress=request.META['REMOTE_ADDR']) == True:
        return dict(username=request.session["username"])
    else:
        return dict(username='')

Also, Django Middleware Documentation

Ninefingers
Thanks. I was 100% Java before and particularly enjoyed using JSF/Spring/Hibernate stack. We have some legacy system that is using this stack. Currently we have requirements to build new system with a lot of web user interface/web service interfaces. Requirements are not that clear and will keep changing. I find Django stack way more productive when it comes to web development than doing the same using Java technologies. Workflow with web designers is easier as well.
Tomas