Skip to main content

Python client for the CAS protocol, compatible with several HTTP clients with asynchronous support.

Project description

PyCAS-SSO

PyPI Python Version License: BSD-3-Clause tests coverage

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, and aiohttp.
  • 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

🤝 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


Download files

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

Source Distribution

pycas_sso-0.1.0.tar.gz (16.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pycas_sso-0.1.0-py3-none-any.whl (17.6 kB view details)

Uploaded Python 3

File details

Details for the file pycas_sso-0.1.0.tar.gz.

File metadata

  • Download URL: pycas_sso-0.1.0.tar.gz
  • Upload date:
  • Size: 16.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.2

File hashes

Hashes for pycas_sso-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ad16c4249c3328d55e4437a73a3f81de47b489fdffb91bb6bbd1253262ec2c38
MD5 ea838d058b940827435d4adab9403dd8
BLAKE2b-256 80817fa6573afa4e5d68c4e328cfb2de17259a36f1c314c46c29c3f03002f697

See more details on using hashes here.

File details

Details for the file pycas_sso-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pycas_sso-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 17.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.2

File hashes

Hashes for pycas_sso-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f8ce39d4d568d2dfbf42e4d9d2aef3685304cd874cf6cc8f5fdd3bc5c4b85afd
MD5 7bfe839d3ef69de7ce8a125e97630887
BLAKE2b-256 4b47395276b14e81236249fcdc118c8ab28e84a66c66303f7b4584dc41ba8051

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page