Skip to content

Commit 8b1b16e

Browse files
authored
Allow https container-credentials endpoints (#9988)
1 parent 238026d commit 8b1b16e

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"type": "enhancement",
3+
"category": "ContainerProvider",
4+
"description": "The ContainerProvider now works with arbitray HTTPS URLs for `AWS_CONTAINER_CREDENTIALS_FULL_URI`."
5+
}

awscli/botocore/utils.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2919,6 +2919,9 @@ def retrieve_full_uri(self, full_url, headers=None):
29192919

29202920
def _validate_allowed_url(self, full_url):
29212921
parsed = botocore.compat.urlparse(full_url)
2922+
2923+
if parsed.scheme == 'https':
2924+
return
29222925
if self._is_loopback_address(parsed.hostname):
29232926
return
29242927
is_whitelisted_host = self._check_if_whitelisted_host(parsed.hostname)
@@ -4181,7 +4184,9 @@ def build_dpop_header(private_key, uri, uid=None, ts=None):
41814184
)
41824185
signing_input = f"{header_b64}.{payload_b64}".encode()
41834186
signature = private_key.sign(hashlib.sha256(signing_input).digest())
4184-
signature_bytes = EC.decode_der_signature_to_padded_pair(signature, pad_to=32)
4187+
signature_bytes = EC.decode_der_signature_to_padded_pair(
4188+
signature, pad_to=32
4189+
)
41854190
signature_b64 = base64_url_encode_no_padding(signature_bytes)
41864191

41874192
return f"{header_b64}.{payload_b64}.{signature_b64}"

tests/unit/botocore/test_utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2719,17 +2719,17 @@ def test_can_use_loopback_v6_uri(self):
27192719
def test_link_local_http_is_not_allowed(self):
27202720
self.assert_host_is_not_allowed('http://169.254.0.1/foo')
27212721

2722-
def test_link_local_https_is_not_allowed(self):
2723-
self.assert_host_is_not_allowed('https://169.254.0.1/foo')
2722+
def test_can_use_link_local_https(self):
2723+
self.assert_can_retrieve_metadata_from('https://169.254.0.1/foo')
27242724

27252725
def test_non_link_local_nonallowed_url(self):
27262726
self.assert_host_is_not_allowed('http://169.1.2.3/foo')
27272727

27282728
def test_error_raised_on_nonallowed_url(self):
27292729
self.assert_host_is_not_allowed('http://somewhere.com/foo')
27302730

2731-
def test_external_host_not_allowed_if_https(self):
2732-
self.assert_host_is_not_allowed('https://somewhere.com/foo')
2731+
def test_can_use_external_host_if_https(self):
2732+
self.assert_can_retrieve_metadata_from('https://somewhere.com/foo')
27332733

27342734

27352735
class TestUnsigned(unittest.TestCase):

0 commit comments

Comments
 (0)