diff --git a/modules/openapi-generator/src/main/resources/python/signing.mustache b/modules/openapi-generator/src/main/resources/python/signing.mustache index 4d00424ea48f..7c3100351bb9 100644 --- a/modules/openapi-generator/src/main/resources/python/signing.mustache +++ b/modules/openapi-generator/src/main/resources/python/signing.mustache @@ -12,7 +12,7 @@ from email.utils import formatdate import os import re from time import time -from typing import List, Optional, Union +from typing import Final, List, Literal, Optional, Union, cast from urllib.parse import urlencode, urlparse # The constants below define a subset of HTTP headers that can be included in the @@ -47,8 +47,8 @@ SCHEME_RSA_SHA512 = 'rsa-sha512' ALGORITHM_RSASSA_PSS = 'RSASSA-PSS' ALGORITHM_RSASSA_PKCS1v15 = 'RSASSA-PKCS1-v1_5' -ALGORITHM_ECDSA_MODE_FIPS_186_3 = 'fips-186-3' -ALGORITHM_ECDSA_MODE_DETERMINISTIC_RFC6979 = 'deterministic-rfc6979' +ALGORITHM_ECDSA_MODE_FIPS_186_3: Final = 'fips-186-3' +ALGORITHM_ECDSA_MODE_DETERMINISTIC_RFC6979: Final = 'deterministic-rfc6979' ALGORITHM_ECDSA_KEY_SIGNING_ALGORITHMS = { ALGORITHM_ECDSA_MODE_FIPS_186_3, ALGORITHM_ECDSA_MODE_DETERMINISTIC_RFC6979 @@ -383,7 +383,8 @@ class HttpSigningConfiguration: if sig_alg in ALGORITHM_ECDSA_KEY_SIGNING_ALGORITHMS: # draft-ietf-httpbis-message-signatures-00 does not specify the ECDSA encoding. # Issue: https://github.com/w3c-ccg/http-signatures/issues/107 - signature = DSS.new(key=self.private_key, mode=sig_alg, + mode = cast(Literal['fips-186-3', 'deterministic-rfc6979'], sig_alg) + signature = DSS.new(key=self.private_key, mode=mode, encoding='der').sign(digest) else: raise Exception("Unsupported signature algorithm: {0}".format(sig_alg)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/signing.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/signing.py index e0ef058f4677..2e7185b3ebde 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/signing.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/signing.py @@ -22,7 +22,7 @@ import os import re from time import time -from typing import List, Optional, Union +from typing import Final, List, Literal, Optional, Union, cast from urllib.parse import urlencode, urlparse # The constants below define a subset of HTTP headers that can be included in the @@ -57,8 +57,8 @@ ALGORITHM_RSASSA_PSS = 'RSASSA-PSS' ALGORITHM_RSASSA_PKCS1v15 = 'RSASSA-PKCS1-v1_5' -ALGORITHM_ECDSA_MODE_FIPS_186_3 = 'fips-186-3' -ALGORITHM_ECDSA_MODE_DETERMINISTIC_RFC6979 = 'deterministic-rfc6979' +ALGORITHM_ECDSA_MODE_FIPS_186_3: Final = 'fips-186-3' +ALGORITHM_ECDSA_MODE_DETERMINISTIC_RFC6979: Final = 'deterministic-rfc6979' ALGORITHM_ECDSA_KEY_SIGNING_ALGORITHMS = { ALGORITHM_ECDSA_MODE_FIPS_186_3, ALGORITHM_ECDSA_MODE_DETERMINISTIC_RFC6979 @@ -393,7 +393,8 @@ def _sign_digest(self, digest): if sig_alg in ALGORITHM_ECDSA_KEY_SIGNING_ALGORITHMS: # draft-ietf-httpbis-message-signatures-00 does not specify the ECDSA encoding. # Issue: https://github.com/w3c-ccg/http-signatures/issues/107 - signature = DSS.new(key=self.private_key, mode=sig_alg, + mode = cast(Literal['fips-186-3', 'deterministic-rfc6979'], sig_alg) + signature = DSS.new(key=self.private_key, mode=mode, encoding='der').sign(digest) else: raise Exception("Unsupported signature algorithm: {0}".format(sig_alg)) diff --git a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/signing.py b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/signing.py index e0ef058f4677..2e7185b3ebde 100644 --- a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/signing.py +++ b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/signing.py @@ -22,7 +22,7 @@ import os import re from time import time -from typing import List, Optional, Union +from typing import Final, List, Literal, Optional, Union, cast from urllib.parse import urlencode, urlparse # The constants below define a subset of HTTP headers that can be included in the @@ -57,8 +57,8 @@ ALGORITHM_RSASSA_PSS = 'RSASSA-PSS' ALGORITHM_RSASSA_PKCS1v15 = 'RSASSA-PKCS1-v1_5' -ALGORITHM_ECDSA_MODE_FIPS_186_3 = 'fips-186-3' -ALGORITHM_ECDSA_MODE_DETERMINISTIC_RFC6979 = 'deterministic-rfc6979' +ALGORITHM_ECDSA_MODE_FIPS_186_3: Final = 'fips-186-3' +ALGORITHM_ECDSA_MODE_DETERMINISTIC_RFC6979: Final = 'deterministic-rfc6979' ALGORITHM_ECDSA_KEY_SIGNING_ALGORITHMS = { ALGORITHM_ECDSA_MODE_FIPS_186_3, ALGORITHM_ECDSA_MODE_DETERMINISTIC_RFC6979 @@ -393,7 +393,8 @@ def _sign_digest(self, digest): if sig_alg in ALGORITHM_ECDSA_KEY_SIGNING_ALGORITHMS: # draft-ietf-httpbis-message-signatures-00 does not specify the ECDSA encoding. # Issue: https://github.com/w3c-ccg/http-signatures/issues/107 - signature = DSS.new(key=self.private_key, mode=sig_alg, + mode = cast(Literal['fips-186-3', 'deterministic-rfc6979'], sig_alg) + signature = DSS.new(key=self.private_key, mode=mode, encoding='der').sign(digest) else: raise Exception("Unsupported signature algorithm: {0}".format(sig_alg)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/signing.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/signing.py index e0ef058f4677..2e7185b3ebde 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/signing.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/signing.py @@ -22,7 +22,7 @@ import os import re from time import time -from typing import List, Optional, Union +from typing import Final, List, Literal, Optional, Union, cast from urllib.parse import urlencode, urlparse # The constants below define a subset of HTTP headers that can be included in the @@ -57,8 +57,8 @@ ALGORITHM_RSASSA_PSS = 'RSASSA-PSS' ALGORITHM_RSASSA_PKCS1v15 = 'RSASSA-PKCS1-v1_5' -ALGORITHM_ECDSA_MODE_FIPS_186_3 = 'fips-186-3' -ALGORITHM_ECDSA_MODE_DETERMINISTIC_RFC6979 = 'deterministic-rfc6979' +ALGORITHM_ECDSA_MODE_FIPS_186_3: Final = 'fips-186-3' +ALGORITHM_ECDSA_MODE_DETERMINISTIC_RFC6979: Final = 'deterministic-rfc6979' ALGORITHM_ECDSA_KEY_SIGNING_ALGORITHMS = { ALGORITHM_ECDSA_MODE_FIPS_186_3, ALGORITHM_ECDSA_MODE_DETERMINISTIC_RFC6979 @@ -393,7 +393,8 @@ def _sign_digest(self, digest): if sig_alg in ALGORITHM_ECDSA_KEY_SIGNING_ALGORITHMS: # draft-ietf-httpbis-message-signatures-00 does not specify the ECDSA encoding. # Issue: https://github.com/w3c-ccg/http-signatures/issues/107 - signature = DSS.new(key=self.private_key, mode=sig_alg, + mode = cast(Literal['fips-186-3', 'deterministic-rfc6979'], sig_alg) + signature = DSS.new(key=self.private_key, mode=mode, encoding='der').sign(digest) else: raise Exception("Unsupported signature algorithm: {0}".format(sig_alg)) diff --git a/samples/openapi3/client/petstore/python-httpx2-sync/petstore_api/signing.py b/samples/openapi3/client/petstore/python-httpx2-sync/petstore_api/signing.py index e0ef058f4677..2e7185b3ebde 100644 --- a/samples/openapi3/client/petstore/python-httpx2-sync/petstore_api/signing.py +++ b/samples/openapi3/client/petstore/python-httpx2-sync/petstore_api/signing.py @@ -22,7 +22,7 @@ import os import re from time import time -from typing import List, Optional, Union +from typing import Final, List, Literal, Optional, Union, cast from urllib.parse import urlencode, urlparse # The constants below define a subset of HTTP headers that can be included in the @@ -57,8 +57,8 @@ ALGORITHM_RSASSA_PSS = 'RSASSA-PSS' ALGORITHM_RSASSA_PKCS1v15 = 'RSASSA-PKCS1-v1_5' -ALGORITHM_ECDSA_MODE_FIPS_186_3 = 'fips-186-3' -ALGORITHM_ECDSA_MODE_DETERMINISTIC_RFC6979 = 'deterministic-rfc6979' +ALGORITHM_ECDSA_MODE_FIPS_186_3: Final = 'fips-186-3' +ALGORITHM_ECDSA_MODE_DETERMINISTIC_RFC6979: Final = 'deterministic-rfc6979' ALGORITHM_ECDSA_KEY_SIGNING_ALGORITHMS = { ALGORITHM_ECDSA_MODE_FIPS_186_3, ALGORITHM_ECDSA_MODE_DETERMINISTIC_RFC6979 @@ -393,7 +393,8 @@ def _sign_digest(self, digest): if sig_alg in ALGORITHM_ECDSA_KEY_SIGNING_ALGORITHMS: # draft-ietf-httpbis-message-signatures-00 does not specify the ECDSA encoding. # Issue: https://github.com/w3c-ccg/http-signatures/issues/107 - signature = DSS.new(key=self.private_key, mode=sig_alg, + mode = cast(Literal['fips-186-3', 'deterministic-rfc6979'], sig_alg) + signature = DSS.new(key=self.private_key, mode=mode, encoding='der').sign(digest) else: raise Exception("Unsupported signature algorithm: {0}".format(sig_alg)) diff --git a/samples/openapi3/client/petstore/python-httpx2/petstore_api/signing.py b/samples/openapi3/client/petstore/python-httpx2/petstore_api/signing.py index e0ef058f4677..2e7185b3ebde 100644 --- a/samples/openapi3/client/petstore/python-httpx2/petstore_api/signing.py +++ b/samples/openapi3/client/petstore/python-httpx2/petstore_api/signing.py @@ -22,7 +22,7 @@ import os import re from time import time -from typing import List, Optional, Union +from typing import Final, List, Literal, Optional, Union, cast from urllib.parse import urlencode, urlparse # The constants below define a subset of HTTP headers that can be included in the @@ -57,8 +57,8 @@ ALGORITHM_RSASSA_PSS = 'RSASSA-PSS' ALGORITHM_RSASSA_PKCS1v15 = 'RSASSA-PKCS1-v1_5' -ALGORITHM_ECDSA_MODE_FIPS_186_3 = 'fips-186-3' -ALGORITHM_ECDSA_MODE_DETERMINISTIC_RFC6979 = 'deterministic-rfc6979' +ALGORITHM_ECDSA_MODE_FIPS_186_3: Final = 'fips-186-3' +ALGORITHM_ECDSA_MODE_DETERMINISTIC_RFC6979: Final = 'deterministic-rfc6979' ALGORITHM_ECDSA_KEY_SIGNING_ALGORITHMS = { ALGORITHM_ECDSA_MODE_FIPS_186_3, ALGORITHM_ECDSA_MODE_DETERMINISTIC_RFC6979 @@ -393,7 +393,8 @@ def _sign_digest(self, digest): if sig_alg in ALGORITHM_ECDSA_KEY_SIGNING_ALGORITHMS: # draft-ietf-httpbis-message-signatures-00 does not specify the ECDSA encoding. # Issue: https://github.com/w3c-ccg/http-signatures/issues/107 - signature = DSS.new(key=self.private_key, mode=sig_alg, + mode = cast(Literal['fips-186-3', 'deterministic-rfc6979'], sig_alg) + signature = DSS.new(key=self.private_key, mode=mode, encoding='der').sign(digest) else: raise Exception("Unsupported signature algorithm: {0}".format(sig_alg)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/signing.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/signing.py index e0ef058f4677..2e7185b3ebde 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/signing.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/signing.py @@ -22,7 +22,7 @@ import os import re from time import time -from typing import List, Optional, Union +from typing import Final, List, Literal, Optional, Union, cast from urllib.parse import urlencode, urlparse # The constants below define a subset of HTTP headers that can be included in the @@ -57,8 +57,8 @@ ALGORITHM_RSASSA_PSS = 'RSASSA-PSS' ALGORITHM_RSASSA_PKCS1v15 = 'RSASSA-PKCS1-v1_5' -ALGORITHM_ECDSA_MODE_FIPS_186_3 = 'fips-186-3' -ALGORITHM_ECDSA_MODE_DETERMINISTIC_RFC6979 = 'deterministic-rfc6979' +ALGORITHM_ECDSA_MODE_FIPS_186_3: Final = 'fips-186-3' +ALGORITHM_ECDSA_MODE_DETERMINISTIC_RFC6979: Final = 'deterministic-rfc6979' ALGORITHM_ECDSA_KEY_SIGNING_ALGORITHMS = { ALGORITHM_ECDSA_MODE_FIPS_186_3, ALGORITHM_ECDSA_MODE_DETERMINISTIC_RFC6979 @@ -393,7 +393,8 @@ def _sign_digest(self, digest): if sig_alg in ALGORITHM_ECDSA_KEY_SIGNING_ALGORITHMS: # draft-ietf-httpbis-message-signatures-00 does not specify the ECDSA encoding. # Issue: https://github.com/w3c-ccg/http-signatures/issues/107 - signature = DSS.new(key=self.private_key, mode=sig_alg, + mode = cast(Literal['fips-186-3', 'deterministic-rfc6979'], sig_alg) + signature = DSS.new(key=self.private_key, mode=mode, encoding='der').sign(digest) else: raise Exception("Unsupported signature algorithm: {0}".format(sig_alg)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/signing.py b/samples/openapi3/client/petstore/python/petstore_api/signing.py index e0ef058f4677..2e7185b3ebde 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/signing.py +++ b/samples/openapi3/client/petstore/python/petstore_api/signing.py @@ -22,7 +22,7 @@ import os import re from time import time -from typing import List, Optional, Union +from typing import Final, List, Literal, Optional, Union, cast from urllib.parse import urlencode, urlparse # The constants below define a subset of HTTP headers that can be included in the @@ -57,8 +57,8 @@ ALGORITHM_RSASSA_PSS = 'RSASSA-PSS' ALGORITHM_RSASSA_PKCS1v15 = 'RSASSA-PKCS1-v1_5' -ALGORITHM_ECDSA_MODE_FIPS_186_3 = 'fips-186-3' -ALGORITHM_ECDSA_MODE_DETERMINISTIC_RFC6979 = 'deterministic-rfc6979' +ALGORITHM_ECDSA_MODE_FIPS_186_3: Final = 'fips-186-3' +ALGORITHM_ECDSA_MODE_DETERMINISTIC_RFC6979: Final = 'deterministic-rfc6979' ALGORITHM_ECDSA_KEY_SIGNING_ALGORITHMS = { ALGORITHM_ECDSA_MODE_FIPS_186_3, ALGORITHM_ECDSA_MODE_DETERMINISTIC_RFC6979 @@ -393,7 +393,8 @@ def _sign_digest(self, digest): if sig_alg in ALGORITHM_ECDSA_KEY_SIGNING_ALGORITHMS: # draft-ietf-httpbis-message-signatures-00 does not specify the ECDSA encoding. # Issue: https://github.com/w3c-ccg/http-signatures/issues/107 - signature = DSS.new(key=self.private_key, mode=sig_alg, + mode = cast(Literal['fips-186-3', 'deterministic-rfc6979'], sig_alg) + signature = DSS.new(key=self.private_key, mode=mode, encoding='der').sign(digest) else: raise Exception("Unsupported signature algorithm: {0}".format(sig_alg))