python_cas package¶
python-cas implements CAS protocol (Central Authentication Server) client.
https://github.com/python-cas/python-cas
Module contents¶
- class cas.CASClientBase(service_url=None, server_url=None, extra_login_params=None, renew=False, username_attribute=None, verify_ssl_certificate=True, session=None)[source]¶
Bases:
object
- get_logout_url(redirect_url=None)[source]¶
Generates CAS logout URL
- Returns
Logout URL
- Return type
str
- get_proxy_ticket(pgt)[source]¶
Get proxy ticket given the proxy granting ticket
- Returns
Proxy ticket.
- Return type
str
- Raises
CASError – Non 200 http code or bad XML body.
- get_proxy_url(pgt)[source]¶
Returns proxy url, given the proxy granting ticket
- Returns
Proxy URL
- Return type
str
- logout_redirect_param_name = 'service'¶
- class cas.CASClientV1(service_url=None, server_url=None, extra_login_params=None, renew=False, username_attribute=None, verify_ssl_certificate=True, session=None)[source]¶
Bases:
cas.CASClientBase
CAS Client Version 1
- logout_redirect_param_name = 'url'¶
- class cas.CASClientV2(proxy_callback=None, *args, **kwargs)[source]¶
Bases:
cas.CASClientBase
CAS Client Version 2
- logout_redirect_param_name = 'url'¶
- url_suffix = 'serviceValidate'¶
- class cas.CASClientV3(proxy_callback=None, *args, **kwargs)[source]¶
Bases:
cas.CASClientV2
,cas.SingleLogoutMixin
CAS Client Version 3
- logout_redirect_param_name = 'service'¶
- url_suffix = 'p3/serviceValidate'¶
- class cas.CASClientWithSAMLV1(proxy_callback=None, *args, **kwargs)[source]¶
Bases:
cas.CASClientV2
,cas.SingleLogoutMixin
CASClient 3.0+ with SAML
- classmethod get_saml_assertion(ticket)[source]¶
Get SAML assertion
SAML request values:
RequestID [REQUIRED]: unique identifier for the request
IssueInstant [REQUIRED]: timestamp of the request
samlp:AssertionArtifact [REQUIRED]: the valid CAS Service Ticket obtained as a response parameter at login.
Example of /samlValidate POST request:
POST /cas/samlValidate?TARGET= Host: cas.example.com Content-Length: 491 Content-Type: text/xml <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> <SOAP-ENV:Header/> <SOAP-ENV:Body> <samlp:Request xmlns:samlp="urn:oasis:names:tc:SAML:1.0:protocol" MajorVersion="1" MinorVersion="1" RequestID="_192.168.16.51.1024506224022" IssueInstant="2002-06-19T17:03:44.022Z"> <samlp:AssertionArtifact> ST-1-u4hrm3td92cLxpCvrjylcas.example.com </samlp:AssertionArtifact> </samlp:Request> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
see https://djangocas.dev/docs/4.0/CAS-Protocol-Specification.html#samlvalidate-cas-3-0
- verify_ticket(ticket, **kwargs)[source]¶
Verifies CAS 3.0+ XML-based authentication ticket and returns extended attributes.
@date: 2011-11-30 @author: Carlos Gonzalez Vila <carlewis@gmail.com>
Returns username and attributes on success and None,None on failure.