UC SSO Helper 🔐
A python library for easily authenticating to services protected by UC Chile's SSO system.
Note this is meant for accessing services locally (i.e. not on a web app or on a user-facing system). This is commonly used for automating software that runs local-first, and you should almost never use this library by capturing user credentials and storing them in your system.
For web apps you can either request to be placed on the CAS allowlist (which requires DI authorization) or in the case you need simple email or name metadata, use Google OAuth and check for a valid university domain.
Installation
The library is available on PyPi:
$ pip install uc-sso
Usage
The library exposes two main functions:
get_ticket(username, password, service_url): To get a service ticket and an authenticated service URL given a username and password.get_user_info(username, password): To get SSO stored user attributes.
The library is heavily typed and the code is relatively short and heavily documented, so go look!
Seguimiento Curricular
A minimal example to place an authenticated GET request to UC Chile's "Seguimiento Curricular" service:
import requests
from uc_sso import get_ticket
# This gets us the ticket value and a ready made authenticated URL to access the service.
ticket = get_ticket("example_username", "example_password", "https://seguimientocurricular.uc.cl/")
# We can now just make a GET request to the service using the autenticated URL.
requests.get(ticket.service_url).text
Getting user info
A common application of this library is obtaining user metadata stored in the CAS diagnostics page. The get_user_info function is a simple wrapper around the page that automatically handles authentication, parsing, and cleaning the resulting attributes.
from uc_sso import get_user_info
# We just need to provide the user credentials and voilà!
print(get_user_info("example_username", "example_password"))
>>> {
"full_name": "AGUSTIN COVARRUBIAS XXXXXX",
"given_name": "AGUSTÍN",
"surnames": "COVARRUBIAS XXXXXX",
"first_last_name": "COVARRUBIAS",
"second_last_name": "XXXXXX",
"mail": "XXXXXX@uc.cl",
"email_type": "gmail",
"username": "XXXXXXX"
"run": "XXXXXXX-0",
"alternate_emails": ["XXXXXX@puc.cl"],
"user_category": "Alumno",
"user_type": "1"
}
Contributing
I'm trying to keep this library as simple and dependency-free as possible, but if you have any ideas or suggestions, please let me know!
Metadata
Release files for uc-sso 1.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| uc-sso-1.0.3.tar.gz | 17.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| uc_sso-1.0.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 35.7 kB
Release files / uc-sso-1.0.3.tar.gz
| Download URL | uc-sso-1.0.3.tar.gz |
|---|---|
| Size | 17.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1862f2cfa3a591891378af7dadad75e6967c5d7325fbebd613ed9d669754234d
|
|
BLAKE2b-256 checksum How to use checksums |
a859c2274a135befb7a555ab15e828113439265ee7e9d5c91bd6063c4919e4cc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.13 CPython/3.10.8 Darwin/21.6.0
|
Release files / uc_sso-1.0.3-py3-none-any.whl
| Download URL | uc_sso-1.0.3-py3-none-any.whl |
|---|---|
| Size | 18.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fc2948c2a033acda3cbb68dd234d32b64d26901b5a250cff73374c0d4622fb57
|
|
BLAKE2b-256 checksum How to use checksums |
5b1af761f0489a38a7350bfd3a1e2879cb785b7e6183e4f8eb08dcc8f9f0fa57
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.13 CPython/3.10.8 Darwin/21.6.0
|
Security for uc-sso 1.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.