python-cas-client
A Python CAS (Central Authentication Service) client for interfacing with a CAS service implementation, such as https://github.com/rbCAS/CASino or https://github.com/apereo/cas.
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).
Installation
Supports Python 2.7 and 3.4.
$ git clone git@github.com:discogs/python-cas-client.git $ cd python-cas-client python-cas-client$ pip install . ...
Testing
cas_client uses tox to run its unit tests under Python 2.7 and 3.4.
python-cas-client$ tox
Example
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 = 'http://www.my-app.com/login'
cas_url = 'http://cas.my-app.com'
cas_client = CASClient(cas_url, auth_prefix='')
@app.route('/login')
def login():
ticket = request.args.get('ticket')
if ticket:
try:
cas_response = cas_client.perform_service_validate(
ticket=ticket,
service_url=app_login_url,
)
except:
# 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'))
del(session['logged-in'])
cas_login_url = cas_client.get_login_url(service_url=app_login_url)
return redirect(cas_login_url)
@app.route('/logout')
def logout():
del(session['logged-in'])
cas_logout_url = cas_client.get_logout_url(service_url=app_login_url)
return redirect(cas_logout_url)
@app.route('/')
def root():
if session.get('logged-in'):
return 'You Are Logged In'
else:
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.
Metadata
Release files for cas-client 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cas_client-1.0.0.tar.gz | 14.0 kB | Without provenance | Details for cas_client-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cas_client-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for cas_client-1.0.0-py3-none-any.whl |
Total release size: 21.9 kB
Release files / cas_client-1.0.0.tar.gz
| Download URL | cas_client-1.0.0.tar.gz |
|---|---|
| Size | 14.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8c881fa023ff2b8f8879b314aaa32bf9c79de695cb438a50dc4ee25dfc3fc08b
|
|
BLAKE2b-256 checksum How to use checksums |
6583a8467cd819114cb242081fef12b88ca6bab0b9e92e5882c9bac0e0fa1e24
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2
|
Release files / cas_client-1.0.0-py3-none-any.whl
| Download URL | cas_client-1.0.0-py3-none-any.whl |
|---|---|
| Size | 8.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c6dec881b311467bd64abef1e7974d45ab29feda3de56a3ba50c44b2984ccbea
|
|
BLAKE2b-256 checksum How to use checksums |
a3c2018ded9cd48e1c4e976947f10f2bfca2c16041f98faf02e1dfbe9fbfaaea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2
|
Security for cas-client 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.