Python project for generate CAS Protocol TGTs and STs
Project description
CasProtPY
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
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
Hashes for casprotpy-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ba1782e01294ba16e81c52354e4d59f2c54d37f6b516217fde75f7073a9df84 |
|
MD5 | 8ed7c79ad857f8982a7372a86e77e6be |
|
BLAKE2b-256 | ed320c0b4b0aac9a07be19818332cb93e4abc10641bd1d4cf3547166ac6df2df |