Skip to content

Commit fe180a5

Browse files
committed
WIP
1 parent 5a59f52 commit fe180a5

File tree

3 files changed

+10
-14
lines changed

3 files changed

+10
-14
lines changed

http_message_signatures/resolvers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import urllib.parse
22

3-
import http_sfv
3+
import http_sf
44

55
from .exceptions import HTTPMessageSignaturesException
66
from .structures import CaseInsensitiveDict

http_message_signatures/signatures.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import logging
44
from typing import Any, Dict, List, Optional, Sequence, Tuple, Type
55

6-
import http_sfv
6+
import http_sf
77

88
from .algorithms import HTTPSignatureAlgorithm, signature_algorithms
99
from .exceptions import HTTPMessageSignaturesException, InvalidSignature
@@ -36,7 +36,7 @@ def _build_signature_base(
3636
sig_elements = collections.OrderedDict()
3737
component_resolver = self.component_resolver_class(message)
3838
for component_id in covered_component_ids:
39-
component_key = str(http_sfv.List([component_id]))
39+
component_key = http_sf.ser([component_id])
4040
# TODO: model situations when header occurs multiple times
4141
component_value = component_resolver.resolve(component_id)
4242
if str(component_id.value).lower() != str(component_id.value):
@@ -49,9 +49,8 @@ def _build_signature_base(
4949
f'Component ID "{component_key}" appeared multiple times in ' "signature input"
5050
)
5151
sig_elements[component_key] = component_value
52-
sig_params_node = http_sfv.InnerList(covered_component_ids)
53-
sig_params_node.params.update(signature_params)
54-
sig_elements['"@signature-params"'] = str(sig_params_node)
52+
sig_params_node = [(list(covered_component_ids), signature_params)]
53+
sig_elements['"@signature-params"'] = http_sf.ser(sig_params_node)
5554
sig_base = "\n".join(f"{k}: {v}" for k, v in sig_elements.items())
5655
return sig_base, sig_params_node, sig_elements
5756

@@ -104,10 +103,8 @@ def sign(
104103
sig_label = self.DEFAULT_SIGNATURE_LABEL
105104
if label is not None:
106105
sig_label = label
107-
sig_input_node = http_sfv.Dictionary({sig_label: sig_params_node})
108-
message.headers["Signature-Input"] = str(sig_input_node)
109-
sig_node = http_sfv.Dictionary({sig_label: signature})
110-
message.headers["Signature"] = str(sig_node)
106+
message.headers["Signature-Input"] = http_sf.ser({sig_label: sig_params_node})
107+
message.headers["Signature"] = http_sf.ser({sig_label: signature})
111108

112109

113110
class HTTPMessageVerifier(HTTPSignatureHandler):
@@ -118,8 +115,7 @@ def _parse_dict_header(self, header_name, headers):
118115
if header_name not in headers:
119116
raise InvalidSignature(f'Expected "{header_name}" header field to be present')
120117
try:
121-
dict_header_node = http_sfv.Dictionary()
122-
dict_header_node.parse(headers[header_name].encode())
118+
dict_header_node = http_sf.parse(headers[header_name].encode(), tltype="dictionary")
123119
except Exception as e:
124120
raise InvalidSignature(f'Malformed structured header field "{header_name}"') from e
125121
return dict_header_node

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
license="Apache Software License",
99
author="Andrey Kislyuk",
1010
author_email="[email protected]",
11-
description="An implementation of the IETF HTTP Message Signatures draft standard",
11+
description="An implementation of RFC 9421, the IETF HTTP Message Signatures standard",
1212
long_description=open("README.rst").read(),
1313
use_scm_version={
1414
"write_to": "http_message_signatures/version.py",
1515
},
1616
setup_requires=["setuptools_scm >= 3.4.3"],
17-
install_requires=["http-sfv >= 0.9.3", "cryptography >= 36.0.2"],
17+
install_requires=["http-sf >= 1.0.1", "cryptography >= 36.0.2"],
1818
extras_require={
1919
"tests": [
2020
"flake8",

0 commit comments

Comments
 (0)