Skip to main content

Python OAUTH 2.0 Client used for Backend Application strategy login against European XFEL Web Applications

Project description

Small Python library responsible for managing users authentication using OAUTH 2.0 Client Backend Application strategy (from non web software to web Oauth2 providers)

Repository:

Dependencies:

Installation

Python project

  1. Install requirements, if never done before

1.1. For OS X distributions:

1.1.1. Homebrew

      brew install python3

1.1.2 Port

      sudo port install python36

      sudo port select --set python3 python36

      sudo port install py36-pip
      sudo port select --set pip pip36

1.2. For Linux distributions:

sudo apt-get update
sudo apt-get install python3.6
  1. Make oauth2_xfel_client library available in your python environment

2.1. Install it via pip:

# Install dependencies from local wheels files
pip install . --no-index --find-links ./external_dependencies/

# Install dependencies from the pypi
pip install .

Installing it will place two folders under the current Python installation site-packages folder:

  • oauth2_xfel_client with the sources;

  • oauth2_xfel_client-6.0.0.dist-info/ with Wheels configuration files.

To identify your Python site-packages folder run:

python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"

Usage

To use this project you need to import it:

from oauth2_xfel_client import Oauth2ClientBackend
  1. Connection to the Oauth2Client:

    from oauth2_xfel_client import Oauth2ClientBackend as Oauth2Client
    
    # Necessary configuration variables to establish a connection
    # Go to https://in.xfel.eu/metadata/oauth/applications to make a token for
    # the metadata catalogue.
    user_id = '201ed15ff071a63e76cb0b91a1ab17b36d5f92d24b6df4497aa646e39c46a324'
    user_secret = 'a8ae80f5e96531f19bf2d2b6102f5a537196aca44a673ad36533310e07529757'
    user_email = 'luis.maia@xfel.eu'
    
    # URLs for the metadata catalogue
    token_url = 'https://in.xfel.eu/metadata/oauth/token'
    refresh_url = 'https://in.xfel.eu/metadata/oauth/token'
    auth_url = 'https://in.xfel.eu/metadata/oauth/authorize'
    scope = ''
    
    # Generate the connection
    oauth_client_valid = Oauth2Client(client_id=user_id,
                                      client_secret=user_secret,
                                      scope=scope,
                                      token_url=token_url,
                                      refresh_url=refresh_url,
                                      auth_url=auth_url,
                                      session_token=None)
  2. Interaction with the oauth2Client:

2.1 Example data_group_types:

current_token = oauth_client_valid.get_session_token()

Development & Testing

When developing, and before commit changes, please validate that:

  1. All tests continue passing successfully (to validate that run pytest):

    # Go to the source code directory
    cd oauth2_xfel_client
    
    # Upgrade package and all its required packages
    pip install . -U --upgrade-strategy eager
    
    # Install test dependencies
    pip install '.[test]' -U --upgrade-strategy eager
    
    # Run all tests using pytest
    pytest
    
    # Run all tests and get information about coverage for all files inside oauth2_xfel_client package
    pytest --cov oauth2_xfel_client --cov-report term-missing
  2. Code keeps respecting pycodestyle code conventions (to validate that run pycodestyle):

    pycodestyle .
  3. To generate all the wheels files for the dependencies, execute:

    # Generate Wheels to itself and dependencies
    pip wheel --wheel-dir=./external_dependencies .
    pip wheel --wheel-dir=./external_dependencies --find-links=./external_dependencies .
  4. Check that you have the desired dependency versions in external_dependencies folder, since no versions are now set in setup.py.

Registering library on https://pypi-hypernode.com

To register this python library, the following steps are necessary:

# Install twine
python -m pip install --upgrade twine

# Generates source distribution (.tar.gz) and wheel (.whl) files in the dist/ folder
python setup.py sdist
python setup.py bdist_wheel

# Upload new version .egg and .whl files
twine upload dist/*

# In case a test is necessary, it is possible to test it against test.pypi.org
twine upload --repository-url https://test.pypi.org/legacy/ dist/* --verbose

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

oauth2_xfel_client-6.0.1.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

oauth2_xfel_client-6.0.1-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file oauth2_xfel_client-6.0.1.tar.gz.

File metadata

  • Download URL: oauth2_xfel_client-6.0.1.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for oauth2_xfel_client-6.0.1.tar.gz
Algorithm Hash digest
SHA256 bbde06d3cb1dace2ac079bafc1c2fa7dc9fa9b00476c10033c459902d1532b70
MD5 7c9b1a8373257573775501fc9a935225
BLAKE2b-256 26662c0a11f31591ca1230d0a84560d5c3dc4964d60aeaa05c9ddad104d42db7

See more details on using hashes here.

File details

Details for the file oauth2_xfel_client-6.0.1-py3-none-any.whl.

File metadata

  • Download URL: oauth2_xfel_client-6.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for oauth2_xfel_client-6.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1d5f70b2e7099315a926cd3884f50c19dbe3309e69d80376f96dc73f2f83459e
MD5 0141b796cb2c4d17adfd27b5649bfebf
BLAKE2b-256 86fc38c07c1b9617485f7d324f7ba46a54111b2a19f0188f85a2fda110e56581

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