File tree Expand file tree Collapse file tree 2 files changed +15
-7
lines changed Expand file tree Collapse file tree 2 files changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -102,19 +102,19 @@ def _load_auth(self, hostname: str) -> bool:
102
102
return False
103
103
self ._basic_auth = auth
104
104
return True
105
- # Check for credsStore:
106
- if self ._auth_config .get ("credsStore" ):
105
+ # Check for credHelper
106
+ if self ._auth_config .get ("credHelpers" , {}). get ( hostname ):
107
107
auth = self ._get_auth_from_creds_store (
108
- self ._auth_config ["credsStore" ], hostname
108
+ self ._auth_config ["credHelpers" ][ hostname ], hostname
109
109
)
110
110
if auth is not None :
111
111
self ._basic_auth = auth
112
112
auths [hostname ] = {"auth" : auth }
113
113
return True
114
- # Check for credHelper
115
- if self ._auth_config .get ("credHelpers" , {}). get ( hostname ):
114
+ # Check for credsStore:
115
+ if self ._auth_config .get ("credsStore" ):
116
116
auth = self ._get_auth_from_creds_store (
117
- self ._auth_config ["credHelpers" ][ hostname ], hostname
117
+ self ._auth_config ["credsStore" ], hostname
118
118
)
119
119
if auth is not None :
120
120
self ._basic_auth = auth
Original file line number Diff line number Diff line change 3
3
__license__ = "Apache-2.0"
4
4
5
5
import re
6
+ from typing import Optional
6
7
7
8
import requests
8
9
9
10
import oras .auth .utils as auth_utils
10
11
from oras .auth .token import TokenAuth
11
12
from oras .logger import logger
13
+ from oras .types import container_type
12
14
13
15
14
16
class EcrAuth (TokenAuth ):
15
17
"""
16
18
Auth backend for AWS ECR (Elastic Container Registry) using token-based authentication.
17
19
"""
20
+ AWS_ECR_PATTERN = re .compile (r"(?P<account_id>\d{12})\.dkr\.ecr\.(?P<region>[^.]+)\.amazonaws\.com" )
21
+ AWS_ECR_REALM_PATTERN = re .compile (r"https://(?P<account_id>\d{12})\.dkr\.ecr\.(?P<region>[^.]+)\.amazonaws\.com/" )
18
22
19
23
def __init__ (self ):
20
24
super ().__init__ ()
21
25
self ._tokens = {}
22
26
27
+ def load_configs (self , container : container_type , configs : Optional [list ] = None ) -> None :
28
+ if not self .AWS_ECR_PATTERN .fullmatch (container .registry ):
29
+ super ().load_configs (container , configs )
30
+
23
31
def authenticate_request (
24
32
self , original : requests .Response , headers : dict , refresh = False
25
33
):
@@ -46,7 +54,7 @@ def authenticate_request(
46
54
token = self ._tokens .get (h .realm )
47
55
if not token or refresh :
48
56
m = re .fullmatch (
49
- r"https://(?P<account_id>\d{12})\.dkr\.ecr\.(?P<region>[^.]+)\.amazonaws\.com/" ,
57
+ self . AWS_ECR_REALM_PATTERN ,
50
58
h .realm ,
51
59
)
52
60
if not m :
You can’t perform that action at this time.
0 commit comments