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
Built Distribution
Close
Hashes for dciauth-3.0.2.post202311101437.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ef7b423fac995d691760e184ea3d93eedc88cb1df7dbdee8410eaef35a3ce1a |
|
MD5 | 143ff7a43ce25e915dbd0fa232e6c868 |
|
BLAKE2b-256 | 3752bee7deaf8cf8daf0293ee1bd5e43fcfb21c5dc37038c2ed29cc8f8cb4bba |
Close
Hashes for dciauth-3.0.2.post202311101437-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4af0f89375a283166546edcb72210e9447e7b9364c3bff7a602eb471493542f5 |
|
MD5 | b608a71c5f45ac77ad922ae697983f78 |
|
BLAKE2b-256 | 515e7f0b74fa9368be61884b14f2d1e9037f39564a0e54f384fc70bc48d051df |