/usr/lib/python3/dist-packages/pydap/cas/esgf.py is in python3-pydap 3.2.2+ds1-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | from six.moves.urllib.parse import quote_plus
from . import get_cookies
def setup_session(openid, password, username=None,
check_url=None,
session=None, verify=False):
"""
A special call to get_cookies.setup_session that is tailored for
ESGF credentials.
username should only be necessary for a CEDA openid.
"""
session = get_cookies.setup_session(_uri(openid),
username=username,
password=password,
check_url=check_url,
session=session,
verify=verify)
# Connections can be kept alive on the ESGF:
session.headers.update([('Connection', 'keep-alive')])
return session
def _uri(openid):
'''
Create ESGF authentication url.
This function might be sensitive to a
future evolution of the ESGF security.
'''
def generate_url(dest_url):
dest_node = _get_node(dest_url)
try:
url = (dest_node +
'/esg-orp/j_spring_openid_security_check.htm?'
'openid_identifier=' +
quote_plus(openid))
except TypeError:
raise UserWarning('OPENID was not set. '
'ESGF connection cannot succeed.')
if _get_node(openid) == 'https://ceda.ac.uk':
return [url, None]
else:
return url
return generate_url
def _get_node(url):
return '/'.join(url.split('/')[:3]).replace('http:', 'https:')
|