Python client for the CAS protocol, compatible with several HTTP clients with asynchronous support.
Project description
PyCAS-SSO
PyCAS-SSO is a Python client for the CAS protocol (Central Authentication Service), compatible with multiple HTTP clients with asynchronous support.
🎯 Features
- Client for CAS Protocol : Implementation of the CAS protocol (1.0, 2.0 and 3.0).
- Ticket validation : Support Ticket validation using CAS protocol.
- User Attributes : Extract user attribute from CAS response.
- Multi-HTTP Clients : Support for
requests,httpx, andaiohttp. - Async/Await : Optional support for asynchronous programming.
Disclaimer: This library is in early version. Bugs may still exist, particularly in advanced CAS features and structure might be subject to change. Use it at your own risk.
📦 Installation
Requirements
- Python 3.10+
Basic Installation
pip install pycas-sso[httpx]
Installation with alternative HTTP library
# With requests library
pip install pycas-sso[requests]
# With aiohttp library
pip install pycas-sso[aiohttp]
🔧 Supported HTTP Clients
| Client | Synchronous | Asynchronous | Installation |
|---|---|---|---|
requests |
✅ | ❌ | pip install pycas-sso[requests] |
httpx |
✅ | ✅ | pip install pycas-sso[httpx] |
aiohttp |
❌ | ✅ | pip install pycas-sso[aiohttp] |
The library will automatically detect the available client if you don't specify one.
🚀 Quick Start
Basic Usage (Synchronous)
from pycas_sso import CASClient
# Create a CAS client
with CASClient.create(
'https://cas.example.com',
'https://myapp.example.com',
'https://myapp.example.com/login',
http_lib='requests'
) as client:
# Validate a CAS ticket
try:
user_info = client.service_validate('ST-123456-abcdef')
print(f"Authenticated user: {user_info}")
except Exception as e:
print(f"Validation error: {e}")
Asynchronous Usage
import asyncio
from pycas_sso import CASClient
async def main():
# Create an asynchronous CAS client
async with CASClient.create(
'https://cas.example.com',
'https://myapp.example.com',
'https://myapp.example.com/login',
http_lib='httpx' # or 'aiohttp'
) as client:
# Validate a ticket asynchronously
try:
user_info = await client.aservice_validate('ST-123456-abcdef')
print(f"Authenticated user: {user_info}")
except Exception as e:
print(f"Validation error: {e}")
# Run
asyncio.run(main())
📚 Documentation
Full documentation is available at https://pycas-sso.readthedocs.io/.
Contributing
If you want to contribute to the documentation, clone the repo. Then install required packages from docs/requirements.txt.
pip install -r docs/requirements.txt
🧪 Testing & Development
First install packages required for testing:
pip install pycas-sso[dev]
Then run the test suite with coverage:
pytest -vv
📝 License
This project is licensed under BSD-3-Clause or later. See LICENSE for more details.
👤 Author
- C. Nicolas - GitHub
🤝 Contributing
Contributions are welcome! Please refer to CONTRIBUTING.md for guidelines.
📋 Changelog
See CHANGELOG.md for the history of changes.
📖 Resources
Note : This library implements the CAS protocol (Central Authentication Service) and is compatible with Apereo CAS servers and other compatible implementations.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pycas_sso-0.1.0.post1.tar.gz.
File metadata
- Download URL: pycas_sso-0.1.0.post1.tar.gz
- Upload date:
- Size: 17.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
359507126b6948a73d1e865b47e28631d9f2a095aa4e3655ba46dc27d6d218f5
|
|
| MD5 |
38de48a8a9fffe16d4650aaa1d12ed01
|
|
| BLAKE2b-256 |
9bb55fcc52a3745b9162b10ab22dd135adbb2f6e3807a5a8a1c9f61aea5fc62f
|
File details
Details for the file pycas_sso-0.1.0.post1-py3-none-any.whl.
File metadata
- Download URL: pycas_sso-0.1.0.post1-py3-none-any.whl
- Upload date:
- Size: 17.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5132be6056708fee290f463ea78020ad823e654edf2226b7886d80060a83dffa
|
|
| MD5 |
99314982a6a0414457da8132a44779e0
|
|
| BLAKE2b-256 |
ec9181198bce6ac286ad3967f5319834dc13d62fc34de135de33d8f352701b6c
|