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 details)

Uploaded Source

Built Distribution

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

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

Uploaded Python 3

File details

Details for the file casprotpy-1.0.1.tar.gz.

File metadata

  • Download URL: casprotpy-1.0.1.tar.gz
  • Upload date:
  • Size: 2.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.6.9

File hashes

Hashes for casprotpy-1.0.1.tar.gz
Algorithm Hash digest
SHA256 d7785dc0ed966de566126dea5ca2083d79cf1be44de70352ba6847493d8230b8
MD5 fcee7e2e76cbebf46b7a5c7e102c8fb4
BLAKE2b-256 f38c7f0bfcca0cdf137edbcf45be593de6b59f81cd5acc27d45f1db84a249c27

See more details on using hashes here.

File details

Details for the file casprotpy-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: casprotpy-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 3.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.6.9

File hashes

Hashes for casprotpy-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8ba1782e01294ba16e81c52354e4d59f2c54d37f6b516217fde75f7073a9df84
MD5 8ed7c79ad857f8982a7372a86e77e6be
BLAKE2b-256 ed320c0b4b0aac9a07be19818332cb93e4abc10641bd1d4cf3547166ac6df2df

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