Skip to main content

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:

Create a HmacAuthBase object to give to python requests module

from dciauth.signature import HmacAuthBase

auth = HmacAuthBase(
    access_key="access_key",
    secret_key="secret_key",
    region="us-east-1",
    service="api",
    service_key="aws4_request",
    algorithm="AWS4-HMAC-SHA256",
)

GET

import requests

requests.get("http://api.distributed-ci.io/api/v1/jobs", auth=auth)

POST

import requests

requests.post("http://api.distributed-ci.io/api/v1/users", auth=auth, json={"name": "user 1"})

Validation example

import flask
from dciauth.signature import FlaskHmacSignature

@app.route("/api/protected", methods=["GET"])
def get_protected():
    auth_scheme = flask.request.headers.get("Authorization").split(" ")[0]
    if auth_scheme == "AWS4-HMAC-SHA256":
        signature = FlaskHmacSignature(
            {
                "service_name": "api",
                "service_key": "aws4_request",
                "region_name": "us-east-1",
                "algorithm": "AWS4-HMAC-SHA256",
            }
        ).add_request(flask.request)
        assert signature.access_key == "access_key"
        if not signature.is_valid(secret_key="secret_key"):
            return "ko", 401
        return "ok", 200
    return "ko", 400

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

Metadata

Release files for dciauth 4.0.1.post202510211222

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dciauth 4.0.1.post202510211222
File Size Uploaded Provenance Actions
dciauth-4.0.1.post202510211222.tar.gz 12.0 kB Without provenance Details for dciauth-4.0.1.post202510211222.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dciauth 4.0.1.post202510211222
File Interpreter ABI Platform Actions
dciauth-4.0.1.post202510211222-py3-none-any.whl Python 3 none any Details for dciauth-4.0.1.post202510211222-py3-none-any.whl

Total release size: 25.6 kB

Release files / dciauth-4.0.1.post202510211222.tar.gz

Download URL dciauth-4.0.1.post202510211222.tar.gz
Size 12.0 kB
Tags Source
SHA-256 checksum
How to use checksums
75e40b544b497dda0e8f91eb28e31e04929c5036750fe7aef330367132ada14d
BLAKE2b-256 checksum
How to use checksums
580029b62d4a6f96c398266686154f6bc169ecce1ab620f9bb382e21c38efce1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.12.3

Release files / dciauth-4.0.1.post202510211222-py3-none-any.whl

Download URL dciauth-4.0.1.post202510211222-py3-none-any.whl
Size 13.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5e0d0c5812eab9ceeb1102139903a03c72a4963567529d98d19da0db7a2fa961
BLAKE2b-256 checksum
How to use checksums
86bfaa8aa8715040229f90a44ce01e866b603f4c373a2767a0b03537c9a164b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.12.3

Security for dciauth 4.0.1.post202510211222

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page