Skip to main content

Cern Single-Single-Sign-On driver

Project description

This is a re-implementation of the Perl script cern-get-sso-cookie. as a Python library. As a bonus, a shell client re-implementing (most of) the functionality of cern-get-sso-cookie, is also provided.

Prerequisites

This package assumes a working Kerberos and OpenSSL setup, but should be compatible with both python 2.7 and 3.

Usage

The module provides only two functions: krb_sign_on and cert_sign_on, used for authentication with Kerberos and certificates respectively. Both take an optional cookiejar (which can be a Requests CookieJar, or a MozillaCookieJar) which is filled during operations. In any event, a cookie jar is also returned by both functions.

The returned cookie jar can be used directly as an argument to Requests’ cookies

import cern_sso
import requests

my_url = "https://my-secret-place.cern.ch"

cookies = cern_sso.krb_sign_on(my_url)

# Perform request
r1 = requests.get(my_url, cookies=cookies)

It is assumed that the user running the program is already authenticated against Kerberos.

This is what the same procedure would look like using SSL certificates:

import cern_sso
import requests

my_url = "https://my-secret-place.cern.ch"
cert_file = "/home/albin/myCert.pem"
key_file = "/home/albin/myCert.key"

cookies = cern_sso.cert_sign_on(my_url, cert_file=cert_file,
key_file=key_file)

# Perform request
r1 = requests.get(my_url, cookies=cookies)

Certain limitations apply to the certificate and key files, please see the following section on command-line usage for further information on this.

For an example of how to use an external CookieJar, see bin/cern-get-sso-cookie.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

python-cern-sso-1.3.3.tar.gz (6.7 kB view details)

Uploaded Source

File details

Details for the file python-cern-sso-1.3.3.tar.gz.

File metadata

  • Download URL: python-cern-sso-1.3.3.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for python-cern-sso-1.3.3.tar.gz
Algorithm Hash digest
SHA256 d367445cbcb9af362347530321f2a54430a04b3cd994ca822b19f3a2828991b3
MD5 f379f494e5c15418b9f5c1e9d8149a1e
BLAKE2b-256 0c11a975214e808bd7ce365e7c5ec591a9161c3b5487c544a012f568b4b5a480

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page