Commit 0b57faaf by Brodie Rao

Added long_description to setup.py and added links to Django and CAS to the README

parent 31037fd0
Django CAS = Django CAS =
==========
`django_cas` is a CAS 1.0 and CAS 2.0 authentication backend for Django. It `django_cas` is a [http://www.ja-sig.org/products/cas/ CAS] 1.0 and CAS 2.0
allows you to use Django's built-in authentication mechanisms and `User` authentication backend for [http://www.djangoproject.com/ Django]. It allows
model while adding support for CAS. you to use Django's built-in authentication mechanisms and `User` model while
adding support for CAS.
It also includes a middleware that intercepts calls to the original login It also includes a middleware that intercepts calls to the original login
and logout pages and forwards them to the CASified versions, and adds and logout pages and forwards them to the CASified versions, and adds
CAS support to the admin interface. CAS support to the admin interface.
Installation == Installation ==
------------
Run `python setup.py install`, or place the `django_cas` directory in your Run `python setup.py install`, or place the `django_cas` directory in your
`PYTHONPATH` directly. (Note: If you're using Python 2.4 or older, you'll need `PYTHONPATH` directly. (Note: If you're using Python 2.4 or older, you'll need
...@@ -22,18 +21,20 @@ Now add it to the middleware and authentication backends in your settings. ...@@ -22,18 +21,20 @@ Now add it to the middleware and authentication backends in your settings.
Make sure you also have the authentication middleware installed. Here's what Make sure you also have the authentication middleware installed. Here's what
mine looks like: mine looks like:
MIDDLEWARE_CLASSES = ( {{{
'django.middleware.common.CommonMiddleware', MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware',
'django_cas.middleware.CASMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.doc.XViewMiddleware', 'django_cas.middleware.CASMiddleware',
) 'django.middleware.doc.XViewMiddleware',
)
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend', AUTHENTICATION_BACKENDS = (
'django_cas.backends.CASBackend', 'django.contrib.auth.backends.ModelBackend',
) 'django_cas.backends.CASBackend',
)
}}}
Set the following required setting in `settings.py`: Set the following required setting in `settings.py`:
...@@ -67,32 +68,32 @@ Users should now be able to log into your site (and staff into the ...@@ -67,32 +68,32 @@ Users should now be able to log into your site (and staff into the
administration interface) using CAS. administration interface) using CAS.
Populating user data == Populating User Data ==
--------------------
To add user data, subclass `CASBackend` and specify that as your To add user data, subclass `CASBackend` and specify that as your
application's backend. application's backend.
For example: For example:
from django_cas.backend import CASBackend {{{
from django_cas.backend import CASBackend
class PopulatedCASBackend(CASBackend): class PopulatedCASBackend(CASBackend):
"""CAS authentication backend with user data populated from AD""" """CAS authentication backend with user data populated from AD"""
def authenticate(self, ticket, service): def authenticate(self, ticket, service):
"""Authenticates CAS ticket and retrieves user data""" """Authenticates CAS ticket and retrieves user data"""
user = super(PopulatedCASBackend, self).authenticate( user = super(PopulatedCASBackend, self).authenticate(
ticket, service) ticket, service)
# Connect to AD, modify user object, etc. # Connect to AD, modify user object, etc.
return user return user
}}}
Preventing Infinite Redirects == Preventing Infinite Redirects ==
-----------------------------
Django's current implementation of its `permission_required` and Django's current implementation of its `permission_required` and
`user_passes_test` decorators (in `django.contrib.auth.decorators`) has a `user_passes_test` decorators (in `django.contrib.auth.decorators`) has a
...@@ -107,44 +108,46 @@ is fixed, the decorators should still work without issue. ...@@ -107,44 +108,46 @@ is fixed, the decorators should still work without issue.
For more information see http://code.djangoproject.com/ticket/4617. For more information see http://code.djangoproject.com/ticket/4617.
Customizing the 403 Error Page == Customizing the 403 Error Page ==
------------------------------
Django doesn't provide a simple way to customize 403 error pages, so you'll Django doesn't provide a simple way to customize 403 error pages, so you'll
have to make a response middleware that handles `HttpResponseForbidden`. have to make a response middleware that handles `HttpResponseForbidden`.
For example, in `views.py`: For example, in `views.py`:
from django.http import HttpResponseForbidden {{{
from django.template import Context, loader from django.http import HttpResponseForbidden
from django.template import Context, loader
def forbidden(request, template_name='403.html'): def forbidden(request, template_name='403.html'):
"""Default 403 handler""" """Default 403 handler"""
t = loader.get_template(template_name) t = loader.get_template(template_name)
return HttpResponseForbidden(t.render(Context({}))) return HttpResponseForbidden(t.render(Context({})))
}}}
And in `middleware.py`: And in `middleware.py`:
from django.http import HttpResponseForbidden {{{
from django.http import HttpResponseForbidden
from yourapp.views import forbidden from yourapp.views import forbidden
class Custom403Middleware(object): class Custom403Middleware(object):
"""Catches 403 responses and renders 403.html""" """Catches 403 responses and renders 403.html"""
def process_response(self, request, response): def process_response(self, request, response):
if isinstance(response, HttpResponseForbidden): if isinstance(response, HttpResponseForbidden):
return forbidden(request) return forbidden(request)
else: else:
return response return response
}}}
Now add `yourapp.middleware.Custom403Middleware` to your `MIDDLEWARE_CLASSES` Now add `yourapp.middleware.Custom403Middleware` to your `MIDDLEWARE_CLASSES`
setting and create a template named `403.html`. setting and create a template named `403.html`.
CAS 2.0 support == CAS 2.0 support ==
---------------
The CAS 2.0 protocol is supported in the same way that 1.0 is; no extensions The CAS 2.0 protocol is supported in the same way that 1.0 is; no extensions
or new features from the CAS 2.0 specification are implemented. `elementtree` or new features from the CAS 2.0 specification are implemented. `elementtree`
...@@ -155,8 +158,7 @@ Note: The CAS 3.x server uses the CAS 2.0 protocol. There is no CAS 3.0 ...@@ -155,8 +158,7 @@ Note: The CAS 3.x server uses the CAS 2.0 protocol. There is no CAS 3.0
protocol, though the CAS 3.x server does allow extensions to the protocol. protocol, though the CAS 3.x server does allow extensions to the protocol.
Differences Between Django CAS 1.0 and 2.0 == Differences Between Django CAS 1.0 and 2.0 ==
------------------------------------------
Version 2.0 of `django_cas` breaks compatibility in some small ways, in order Version 2.0 of `django_cas` breaks compatibility in some small ways, in order
simplify the library. The following settings have been removed: simplify the library. The following settings have been removed:
......
...@@ -21,6 +21,18 @@ setup( ...@@ -21,6 +21,18 @@ setup(
description='CAS 1.0/2.0 authentication backend for Django', description='CAS 1.0/2.0 authentication backend for Django',
keywords='django cas cas2 authentication middleware backend', keywords='django cas cas2 authentication middleware backend',
license='MIT', license='MIT',
long_description="""
``django_cas`` is a `CAS`_ 1.0 and CAS 2.0 authentication backend for
`Django`_. It allows you to use Django's built-in authentication mechanisms
and ``User`` model while adding support for CAS.
It also includes a middleware that intercepts calls to the original login and
logout pages and forwards them to the CASified versions, and adds CAS support
to the admin interface.
_ ..CAS: http://www.ja-sig.org/products/cas/
_ ..Django: http://www.djangoproject.com/
""",
name='django_cas', name='django_cas',
packages=['django_cas'], packages=['django_cas'],
url='http://code.google.com/p/django-cas/', url='http://code.google.com/p/django-cas/',
......
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