Session

class requests_ecp.Session(idp=None, kerberos=False, username=None, password=None, **kwargs)[source]

Bases: requests_ecp.session.ECPAuthSessionMixin, requests.sessions.Session

A requests.Session wrapper with default SAML/ECP authentication.

To start a Session to handle ECP authentication with a particular Identity Provider (IdP) pass the idp argument with the URL of the ECP endpoint or the IdP. For any individual requests in this Session that are redirected to a SAML/Shibboleth authentication page/app the HTTPECPAuth authorisation plugin will automatically intercept the redirect and invoke a SAML/ECP authorisation workflow:

>>> from requests_ecp import Session
>>> with Session(idp="https://idp.example.com/SAML/SOAP/ECP") as sess:
...     sess.get("https://private.example.com/data")

Methods Summary

ecp_authenticate(url[, endpoint])

Manually authenticate against the endpoint.

Methods Documentation

ecp_authenticate(url, endpoint=None, **kwargs)[source]

Manually authenticate against the endpoint.

This generates a shibboleth session cookie for the domain of the given URL, which defaults to the endpoint itself.

Parameters
  • url (str) – The URL of the resource (on the Service Provider) to request.

  • endpoint (str) – The URL of the ECP endpoint on the Identity Provider. If not given it will be taken from the auth attribute.

  • kwargs – Other keyword arguments are passed directly to requests_ecp.ecp.authenticate().

See also

requests_ecp.ecp.authenticate

For details of the ECP authentication workflow.