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,
"payload": request.get_json(silent=True),
"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.1.tar.gz
(8.0 kB
view details)
Built Distribution
File details
Details for the file dciauth-2.1.1.tar.gz
.
File metadata
- Download URL: dciauth-2.1.1.tar.gz
- Upload date:
- Size: 8.0 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8dca4ec128b4afc5253b7780ac06fc1eb4dccbbde97c155786f2f6c105a7bf66 |
|
MD5 | c57cfce21d72ec8b12263d43bdb86093 |
|
BLAKE2b-256 | 8b985be09caa1231178de0ee844d7a68c2eb4ea47c200b849afae998e167146f |
File details
Details for the file dciauth-2.1.1-py2-none-any.whl
.
File metadata
- Download URL: dciauth-2.1.1-py2-none-any.whl
- Upload date:
- Size: 9.3 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 828b50c7fc0d6b101a7173f47bf00c2b68631b5d39fbcd6146ccc20f83003b0a |
|
MD5 | c3399ff2e32341d1ea3397a4f409f578 |
|
BLAKE2b-256 | c7236f94a019c1125833394cf3877be7d012a4ea1f4d00866583f77633bec588 |