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
data = {"name": "user 1"}
headers = generate_headers(
{
"method": "POST",
"endpoint": "http://api.distributed-ci.io/api/v1/users",
"data": data,
},
{"access_key": "remoteci/client_id", "secret_key": "secret"},
)
requests.post("http://api.distributed-ci.io/api/v1/users", headers=headers, json=data)
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,
"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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
dciauth-3.0.2.tar.gz
(11.6 kB
view details)
Built Distribution
dciauth-3.0.2-py3-none-any.whl
(13.5 kB
view details)
File details
Details for the file dciauth-3.0.2.tar.gz
.
File metadata
- Download URL: dciauth-3.0.2.tar.gz
- Upload date:
- Size: 11.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6d972270969d172ab7f7caf195bf3e402fb40b759305d2fb79d4b4b01383ef90 |
|
MD5 | 9faa4226bc4de1f10d48ecbfaafab29d |
|
BLAKE2b-256 | b4a1af44cd51164ac3d9a2920bce52db80135239b3b93d944395259de7751851 |
File details
Details for the file dciauth-3.0.2-py3-none-any.whl
.
File metadata
- Download URL: dciauth-3.0.2-py3-none-any.whl
- Upload date:
- Size: 13.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7510716848966c3fc7c9a6588611e6666cc7ef955f97c54396d3612f19b8b1dd |
|
MD5 | bfa61b83b486367bec5aa25ec3397055 |
|
BLAKE2b-256 | 5322baa66c60ba00a7afd591431c7f79de0538fef4ddd251717f346f11cbd955 |