Using CAS authentication with Wagtail

Hi, this is quick setup guide for using django-cas-client (1.2.0) with Wagtail, gave me a few headaches so maybe this can help someone else.

I’m assuming you have a CAS authentication server setup already, this guide doesn’t cover that.

First off you’ll need to install the django-cas-client, I did this by adding a line in my requirements.txt of :

django-cas-client==1.2.0

Then in your settings file, make sure you add a backend like :


AUTHENTICATION_BACKENDS = (
	'django.contrib.auth.backends.ModelBackend',
	'cas.backends.CASBackend',
)

then :

CAS_SERVER_URL = 'https://login.yourserveraddresstocas.com/cas/'

CAS_REDIRECT_URL = '/admin/' 

CAS_AUTO_CREATE_USER = False

(The auto create setting is really important otherwise the CAS client will attempt to make a user in Wagtail with no details, this will cause a redirect loop on login for authenticated users)

next :

Add

'cas.middleware.CASMiddleware', 

to the MIDDLEWARE_CLASSES section

then :

Add

'cas',

to the list of installed apps.

That’s all for settings, next open up your urls.py and add these lines :


url(r'^admin/login/$', 'cas.views.login', name='login'),
url(r'^admin/logout/$', 'cas.views.logout', name='logout'),

That should be it, any problems comment below!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s