[lint] fix arguments-renamed
This commit is contained in:
parent
60aa82b63d
commit
6c770286c5
1 changed files with 12 additions and 11 deletions
|
@ -118,31 +118,32 @@ class HTTPXSigAuth(httpx.Auth):
|
||||||
self.key = key
|
self.key = key
|
||||||
|
|
||||||
def auth_flow(
|
def auth_flow(
|
||||||
self, r: httpx.Request
|
self,
|
||||||
|
request: httpx.Request
|
||||||
):
|
):
|
||||||
bodydigest = None
|
bodydigest = None
|
||||||
if r.content:
|
if request.content:
|
||||||
bh = hashlib.new("sha256")
|
bh = hashlib.new("sha256")
|
||||||
bh.update(r.content)
|
bh.update(request.content)
|
||||||
bodydigest = "SHA-256=" + base64.b64encode(bh.digest()).decode("utf-8")
|
bodydigest = "SHA-256=" + base64.b64encode(bh.digest()).decode("utf-8")
|
||||||
|
|
||||||
date = datetime.utcnow().strftime("%a, %d %b %Y %H:%M:%S GMT")
|
date = datetime.utcnow().strftime("%a, %d %b %Y %H:%M:%S GMT")
|
||||||
r.headers["Date"] = date
|
request.headers["Date"] = date
|
||||||
sigheaders = {}
|
sigheaders = {}
|
||||||
if bodydigest:
|
if bodydigest:
|
||||||
r.headers["digest"] = bodydigest
|
request.headers["digest"] = bodydigest
|
||||||
sigheaders = "(request-target) user-agent host date digest content-type"
|
sigheaders = "(request-target) user-agent host date digest content-type"
|
||||||
else:
|
else:
|
||||||
sigheaders = "(request-target) user-agent host date accept"
|
sigheaders = "(request-target) user-agent host date accept"
|
||||||
|
|
||||||
logger.warning(r.headers)
|
logger.warning(request.headers)
|
||||||
|
|
||||||
sigdate = SignedData(
|
sigdate = SignedData(
|
||||||
method = r.method,
|
method = request.method,
|
||||||
path = r.url.path,
|
path = request.url.path,
|
||||||
signed_list = sigheaders.split(),
|
signed_list = sigheaders.split(),
|
||||||
body_digest = bodydigest,
|
body_digest = bodydigest,
|
||||||
headers = r.headers,
|
headers = request.headers,
|
||||||
)
|
)
|
||||||
|
|
||||||
to_be_signed = HttpSignature.build_signature_string(
|
to_be_signed = HttpSignature.build_signature_string(
|
||||||
|
@ -162,5 +163,5 @@ class HTTPXSigAuth(httpx.Auth):
|
||||||
sig_value = f'keyId="{key_id}",algorithm="rsa-sha256",\
|
sig_value = f'keyId="{key_id}",algorithm="rsa-sha256",\
|
||||||
headers="{sigheaders}",signature="{sig.decode()}"'
|
headers="{sigheaders}",signature="{sig.decode()}"'
|
||||||
logger.debug(f"signed request {sig_value=}")
|
logger.debug(f"signed request {sig_value=}")
|
||||||
r.headers["signature"] = sig_value
|
request.headers["signature"] = sig_value
|
||||||
yield r
|
yield request
|
||||||
|
|
Loading…
Reference in a new issue