Skip to main content

Tool to assist with certificate login for DataONE

Project description

Python helper for authenticating in a DataONE environment.

The d1_certificate library offers some routines to assist with authenticating for interactions with DataONE services. Authentication requires a web browser UI, and so is not suitable for use on headless systems. The basic process is:

  1. A web browser is opened to select an identity provider

  2. Credentials are entered into the selected IDP

  3. A certificate signing request is created and token information is retieved from CILogon

  4. The certificate is signed and moved to a consistent location.

Caveats:

  1. A web browser is required

  2. It is assumed that the file downloaded by the web browser is located in ${HOME}/Downloads

  3. The generated certificate is placed into ${HOME}/.dataone/certificates

  4. The subject mapping and group info in the certificate is static. Be aware that the certificate will need to be regenerated if your user id mapping or group membership needs to change.

Installation

Release install:

pip install -U d1login

Development install:

git clone
cd d1Login
pip install -U -e .

Example

The commandline app will open a web browser at the appropriate login URL. After authenticating, the browser will download a .jnlp file. This should be placed in ~/Downloads. The script will be waiting (upto 60 seconds) for the .jnlp and once available, will process the file and request the certificate.

Commandline:

d1login
<<browser opens, download jnlp file>>
Certificate downloaded to: /Users/vieglais/.dataone/certificates/x509up_u501

As a library:

>>> import d1_certificate
>>> service = d1_certificate.LOGIN_SERVICE['dev']
>>> certpath = d1_certificate.login(overwrite=True, service=service)
# Browser window opens for authentication

>>> print certpath
/Users/vieglais/.dataone/certificates/x509up_u501

>>> d1_certificate.getSubjectFromCertFile( certpath )
{'not_after': '20151216225323Z',
 'not_before': '20151216044823Z',
 'status': True,
 'subject': 'CN=Dave Vieglais A34511,O=Google,C=US,DC=cilogon,DC=org',
 'subject_info': None}

On OS X, the certificate can then be imported into the keychain for browser interactions with nodes in the authenticated environment. For example:

CERT=/Users/vieglais/.dataone/certificates/x509up_u501
openssl x509 -outform der -in ${CERT} -out "${CERT}.der"
security add-certificates "${CERT}.der"

Now open a browser (chrome or safari, firefox uses it’s own cert management independent of keychain) and visit the URL:

https://cn-dev.test.dataone.org/cn/v2/diag/subject

You should see your credentials in the xml response.

On Yosemite, you can no longer use .pem format certificates to authenticate using curl [See: http://curl.haxx.se/mail/archive-2014-10/0053.html ]. Instead, convert to a .p12 format certificate and use that instead. Note of course, that entering your password on the command line like this is a security risk since it will appear in bash history, log files, and so forth. Example:

CERT=/Users/vieglais/.dataone/certificates/x509up_u501
openssl pkcs12 -export -in ${CERT} -out ${CERT}.p12 -passout pass:Some_Password
curl -E ${CERT}.p12:Some_Password "https://cn.dataone.org/cn/v2/diag/subject"

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

d1Login-1.0.1.tar.gz (9.3 kB view details)

Uploaded Source

File details

Details for the file d1Login-1.0.1.tar.gz.

File metadata

  • Download URL: d1Login-1.0.1.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for d1Login-1.0.1.tar.gz
Algorithm Hash digest
SHA256 239bc05eca15821a48abe5f9fde267b398b4a6025e03586d4020e9f0c1b89f59
MD5 80c2152b41ec55cb2f11d81b8e65b8d6
BLAKE2b-256 ab1dcca846954d3d4101cfd166877dc2173d61f6513105e7d196dc1a32b61190

See more details on using hashes here.

Supported by

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