casprotpy-1.0.1
توضیحات
Python project for generate CAS Protocol TGTs and STs
| ویژگی | مقدار |
|---|---|
| سیستم عامل | OS Independent |
| نام فایل | casprotpy-1.0.1 |
| نام | casprotpy |
| نسخه کتابخانه | 1.0.1 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Fred William |
| ایمیل نویسنده | fred.william.prates@gmail.com |
| آدرس صفحه اصلی | - |
| آدرس اینترنتی | https://pypi.org/project/casprotpy/ |
| مجوز | - |
# 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:
```bash
pip3 install casprotpy
```
## Usage
```python
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:
```python
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:
```python
casprotpy_client.st_for(casprotpy_client.tgt_for())
```
## Testing
```bash
python3 -m unittest discover -s tests/ -p '*_test.py'
```
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.6 | Python |
نحوه نصب
نصب پکیج whl casprotpy-1.0.1:
pip install casprotpy-1.0.1.whl
نصب پکیج tar.gz casprotpy-1.0.1:
pip install casprotpy-1.0.1.tar.gz