Skip to content

Commit

Permalink
Hmac Auth in dci-dbprovisioning was broken
Browse files Browse the repository at this point in the history
Use the newer method which is less error-prone in its usage.

Change-Id: Idc4272d94f6352c3a61ef31c20541fbfe1e43bdb
  • Loading branch information
fcharlier committed Nov 28, 2024
1 parent 0b67e9a commit b89c0e3
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions bin/dci-dbprovisioning
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import time

import requests
from dci import settings
from dciauth.v2.headers import generate_headers
from dciauth.signature import HmacAuthBase

DCI_HOST = settings.HOST
DCI_PORT = settings.PORT
Expand Down Expand Up @@ -267,18 +267,15 @@ def create_jobs(topics, remotecis, teams):
client_id = remotecis["partner"]["id"]
api_secret = remotecis["partner"]["api_secret"]
for job in jobs:
request = {
"method": "POST",
"endpoint": "/api/v1/jobs",
"payload": job,
"host": f"{DCI_HOST}:{DCI_PORT}",
}
credential = {
"access_key": f"remoteci/{client_id}",
"secret_key": api_secret,
}
headers = generate_headers(request, credential)
r = requests.post("%s/api/v1/jobs" % DCI_CS_URL, headers=headers, json=job)
auth = HmacAuthBase(
access_key=f"remoteci/{client_id}",
secret_key=api_secret,
region="BHS3",
service="api",
service_key="dci2_request",
algorithm="DCI2-HMAC-SHA256",
)
r = requests.post("%s/api/v1/jobs" % DCI_CS_URL, auth=auth, json=job)
r.raise_for_status()

return get("jobs", PARTNER).json()["jobs"]
Expand Down

0 comments on commit b89c0e3

Please sign in to comment.