Skip to main content

DCI authentication module used by dci-control-server and python-dciclient

Project description

python-dciauth

DCI authentication module used by dci-control-server and python-dciclient

This section shows example programs written in python that illustrate how to work with Signature Version 2 in DCI. The algorithm used by dciauth is identical to Signature Version 4 in AWS.

Authentication example:

GET

import requests

from dciauth.v2.headers import generate_headers

headers = generate_headers(
    {"endpoint": "/api/v1/jobs"},
    {"access_key": "remoteci/client_id", "secret_key": "secret"},
)
requests.get("http://api.distributed-ci.io/api/v1/jobs", headers=headers)

POST

import requests

from dciauth.v2.headers import generate_headers

payload = {"name": "user 1"}
headers = generate_headers(
    {
        "method": "POST",
        "endpoint": "http://api.distributed-ci.io/api/v1/users",
        "payload": payload,
    },
    {"access_key": "remoteci/client_id", "secret_key": "secret"},
)
requests.post("http://api.distributed-ci.io/api/v1/users", headers=headers, json=payload)

Validation example

    from flask import request

    from dciauth.v2.headers import parse_headers
    from dciauth.v2.signature import is_valid

    valid, error_message = is_valid(
        {
            "method": request.method,
            "endpoint": request.path,
            "data": request.data.decode("utf-8"),
            "params": request.args.to_dict(flat=True),
        },
        {"secret_key": "secret"},
        parse_headers(request.headers),
    )
    if not valid:
        raise Exception("Authentication failed: %s" % error_message)

Using POSTMAN

If you are using POSTMAN to discover DCI API you can use the following parameters with the AWS Signature authorization header:

GET https://api.distributed-ci.io/api/v1/identity
AccessKey=<DCI_CLIENT_ID>
SecretKey=<DCI_API_SECRET>
AWS Region="BHS3"
Service Name="api"

License

Apache 2.0

Author Information

Distributed-CI Team distributed-ci@redhat.com

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

dciauth-2.1.3.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

dciauth-2.1.3-py2-none-any.whl (13.0 kB view details)

Uploaded Python 2

File details

Details for the file dciauth-2.1.3.tar.gz.

File metadata

  • Download URL: dciauth-2.1.3.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/2.7.5

File hashes

Hashes for dciauth-2.1.3.tar.gz
Algorithm Hash digest
SHA256 a261fdc427fb704cd70254f077d81f4e8dcaa9a6911ebf0da03fb00f6b43b1a9
MD5 d383b64d44d9b4a7da07ce0bd93663e8
BLAKE2b-256 637385243a8fe04da6db7a2395edca2d1267b07a3ef7223822829d7ac5ff5b57

See more details on using hashes here.

File details

Details for the file dciauth-2.1.3-py2-none-any.whl.

File metadata

  • Download URL: dciauth-2.1.3-py2-none-any.whl
  • Upload date:
  • Size: 13.0 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/2.7.5

File hashes

Hashes for dciauth-2.1.3-py2-none-any.whl
Algorithm Hash digest
SHA256 02e6e550758733cdc86f2dd27595d6090ba61572e404b9abffad4a0133d0b563
MD5 ae47ccf6966b2b1b5045744fbee98048
BLAKE2b-256 753b96a7b5e4989a3b936a706550391301d119a39977fca6ff95e384c857cc2d

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