Skip to main content

Python project for generate CAS Protocol TGTs and STs

Project description

CasProtPY

Package Version Python Version

CasProtPY is a Python project for generate CAS protocol TGTs and STs.

The CAS protocol is a powerful ticket-based protocol implemented by CAS systems.

It key concepts is to use a TGT (Ticket Granting Ticket) to stores the user SSO session, and then require a new ST (Service Ticket) to grant access for each request.

So, CasProtPY creates a TGT, and using it, generates a new ST for each HTTP request.

Compatibility

CasProtPY supports Python 3.6 or later.

Installation

CasProtPY is a package on PyPI, so you can install it using pip:

pip3 install casprotpy

Usage

from casprotpy import casprotpy

# Setup CasProtPY using your CAS server configuration.
casprotpy_client = casprotpy({
  'username': 'cas_user',
  'password': 'cas_password',
  'service': 'service.com.br',
  'base': 'https://cas.login.com.br/v1/tickets'
})

casprotpy_client.tgt_for() # Return a valid TGT for configured CAS base.

casprotpy_client.st_for() # Return a valid ST for configured CAS service.

In addition, you can use the HTTP request methods present in the CasProtPY - which already generates the TGT and STs automatically:

base_url = 'https://service.com.br'

casprotpy_client.get('{}/users/{}'.format(base_url, 'test'))

casprotpy_client.post('{}/users'.format(base_url), {"name": "test", "token": 2})

casprotpy_client.put('{}/users'.format(base_url), {"name": "test", "token": 3})

casprotpy_client.patch('{}/users'.format(base_url), {"token": 3})

casprotpy_client.delete('{}/users/{}'.format(base_url, 'test'))

By default, casprotpy_client.st_for() creates a new TGT and stores it for 8 hours - it keeps using that TGT until it expires.

But you can generate and pass your own TGT, like bellow:

casprotpy_client.st_for(casprotpy_client.tgt_for())

Testing

python3 -m unittest discover -s tests/ -p '*_test.py'

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

casprotpy-1.0.1.tar.gz (2.6 kB view hashes)

Uploaded Source

Built Distribution

casprotpy-1.0.1-py3-none-any.whl (3.0 kB view hashes)

Uploaded Python 3

Supported by

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