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,
"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-2.1.6.tar.gz
(11.4 kB
view details)
Built Distribution
dciauth-2.1.6-py3-none-any.whl
(13.2 kB
view details)
File details
Details for the file dciauth-2.1.6.tar.gz
.
File metadata
- Download URL: dciauth-2.1.6.tar.gz
- Upload date:
- Size: 11.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b7ecf0e24edd0653fbd82cd9e309e1317a7f48e202de882642edfd03eee0c867 |
|
MD5 | 3927cb7cd5b803cd2065e4c4a061249f |
|
BLAKE2b-256 | 4537c39aa5c1dc51380bea3c72fc103cf0a5cf028e052023e8bb8aec62e9d4ac |
File details
Details for the file dciauth-2.1.6-py3-none-any.whl
.
File metadata
- Download URL: dciauth-2.1.6-py3-none-any.whl
- Upload date:
- Size: 13.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a0aed20a5aa0c672acaefff70ccf04d8d4a5b5e0a6e74dedf56ac72851c3ade |
|
MD5 | f2503a72cc46d29f19c1c486ee9157a2 |
|
BLAKE2b-256 | 9b098d0f604d142765e30a1d6eb16b8af4afdbe79a40889c3f7443ef5df12e54 |