Skip to main content

A Python CAS client

Project description

A Python CAS (Central Authentication Service) client for interfacing with a CAS service implementation, such as or

This project provides tools for building well-formed CAS-related URLs, parsing CAS XML payloads and managing the server-side session stores necessary for handling SLO (single logout).


Supports Python 2.7 and 3.4.

$ git clone
$ cd python-cas-client
python-cas-client$ pip install .


cas_client uses tox to run its unit tests under Python 2.7 and 3.4.

python-cas-client$ tox


The following un-tested pseudo-code shows how you might use cas_client in a Flask project.

from cas_client import CASClient
from flask import Flask, redirect, request, session, url_for

app = Flask(__name__)

app_login_url = ''
cas_url = ''
cas_client = CASClient(cas_url, auth_prefix='')

def login():
    ticket = request.args.get('ticket')
    if ticket:
            cas_response = cas_client.perform_service_validate(
            # CAS server is currently broken, try again later.
            return redirect(url_for('root'))
        if cas_response and cas_response.success:
            session['logged-in'] = True
            return redirect(url_for('root'))
    cas_login_url = cas_client.get_login_url(service_url=app_login_url)
    return redirect(cas_login_url)

def logout():
    cas_logout_url = cas_client.get_logout_url(service_url=app_login_url)
    return redirect(cas_logout_url)

def root():
    if session.get('logged-in'):
        return 'You Are Logged In'
        return 'You Are Not Logged In'

This pseudo-code does not handle server-side session stores or single logout, only the bare minimum for standard login and logout.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for cas-client, version 0.1.3
Filename, size File type Python version Upload date Hashes
Filename, size cas_client-0.1.3.tar.gz (13.2 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page