keyrings.codeartifact 2.0.0__py3-none-any.whl → 2.1.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- keyrings/codeartifact.py +64 -16
- {keyrings.codeartifact-2.0.0.dist-info → keyrings_codeartifact-2.1.1.dist-info}/METADATA +3 -26
- keyrings_codeartifact-2.1.1.dist-info/RECORD +8 -0
- {keyrings.codeartifact-2.0.0.dist-info → keyrings_codeartifact-2.1.1.dist-info}/WHEEL +1 -1
- keyrings.codeartifact-2.0.0.dist-info/RECORD +0 -8
- {keyrings.codeartifact-2.0.0.dist-info → keyrings_codeartifact-2.1.1.dist-info}/entry_points.txt +0 -0
- {keyrings.codeartifact-2.0.0.dist-info → keyrings_codeartifact-2.1.1.dist-info/licenses}/LICENSE +0 -0
- {keyrings.codeartifact-2.0.0.dist-info → keyrings_codeartifact-2.1.1.dist-info}/top_level.txt +0 -0
keyrings/codeartifact.py
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
# codeartifact.py -- keyring backend
|
2
2
|
|
3
3
|
import re
|
4
|
-
import boto3
|
5
4
|
import logging
|
6
5
|
|
6
|
+
import boto3
|
7
|
+
import boto3.session
|
8
|
+
|
7
9
|
from datetime import datetime
|
8
10
|
from urllib.parse import urlparse
|
9
11
|
|
@@ -45,7 +47,8 @@ class CodeArtifactKeyringConfig:
|
|
45
47
|
config_parser.default_section = self.DEFAULT_SECTION
|
46
48
|
|
47
49
|
# Load the configuration file.
|
48
|
-
config_parser.read(config_file)
|
50
|
+
if not config_parser.read(config_file):
|
51
|
+
logging.warning(f"{config_file} does not exist!")
|
49
52
|
|
50
53
|
# Collect the defaults before we go further.
|
51
54
|
self.defaults = config_parser.defaults()
|
@@ -103,19 +106,37 @@ class CodeArtifactKeyringConfig:
|
|
103
106
|
return self.config.get(found_key)
|
104
107
|
|
105
108
|
|
109
|
+
def make_codeartifact_client(options):
|
110
|
+
# Build a session with the provided options.
|
111
|
+
session = boto3.session.Session(
|
112
|
+
# NOTE: Only the session accepts 'profile_name'.
|
113
|
+
profile_name=options.pop("profile_name", None),
|
114
|
+
region_name=options.get("region_name"),
|
115
|
+
)
|
116
|
+
|
117
|
+
# Create a client for this new session.
|
118
|
+
return session.client("codeartifact", **options)
|
119
|
+
|
120
|
+
|
106
121
|
class CodeArtifactBackend(backend.KeyringBackend):
|
107
122
|
HOST_REGEX = r"^(.+)-(\d{12})\.d\.codeartifact\.([^\.]+)\.amazonaws\.com$"
|
108
123
|
PATH_REGEX = r"^/pypi/([^/]+)/?"
|
109
124
|
|
110
125
|
priority = 9.9
|
111
126
|
|
112
|
-
def __init__(self,
|
127
|
+
def __init__(self, /, config=None, make_client=make_codeartifact_client):
|
113
128
|
super().__init__()
|
114
129
|
|
115
|
-
if
|
130
|
+
if config:
|
131
|
+
# Use the provided configuration.
|
132
|
+
self.config = config
|
133
|
+
else:
|
134
|
+
# Use the global configuration file.
|
116
135
|
config_file = config_root() / "keyringrc.cfg"
|
136
|
+
self.config = CodeArtifactKeyringConfig(config_file)
|
117
137
|
|
118
|
-
|
138
|
+
# Use our default built-in CodeArtifact client producer.
|
139
|
+
self.make_client = make_client
|
119
140
|
|
120
141
|
def get_credential(self, service, username):
|
121
142
|
authorization_token = self.get_password(service, username)
|
@@ -134,7 +155,7 @@ class CodeArtifactBackend(backend.KeyringBackend):
|
|
134
155
|
|
135
156
|
# If it didn't match the regex, it doesn't apply to us.
|
136
157
|
if not host_match:
|
137
|
-
logging.warning("Not an AWS CodeArtifact repository URL
|
158
|
+
logging.warning(f"Not an AWS CodeArtifact repository URL: {service}")
|
138
159
|
return
|
139
160
|
|
140
161
|
# Extract the domain, account and region for this repository.
|
@@ -148,7 +169,7 @@ class CodeArtifactBackend(backend.KeyringBackend):
|
|
148
169
|
|
149
170
|
repository_name = path_match.group(1)
|
150
171
|
|
151
|
-
#
|
172
|
+
# Lookup configuration options.
|
152
173
|
config = self.config.lookup(
|
153
174
|
domain=domain,
|
154
175
|
account=account,
|
@@ -156,16 +177,43 @@ class CodeArtifactBackend(backend.KeyringBackend):
|
|
156
177
|
name=repository_name,
|
157
178
|
)
|
158
179
|
|
159
|
-
#
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
180
|
+
# Options for the client callback.
|
181
|
+
options = {
|
182
|
+
# Pass in the region name.
|
183
|
+
"region_name": region,
|
184
|
+
}
|
185
|
+
|
186
|
+
# Extract any AWS profile name we should use.
|
187
|
+
profile_name = config.get("profile_name")
|
188
|
+
if profile_name:
|
189
|
+
options.update({"profile_name": profile_name})
|
190
|
+
|
191
|
+
# Provide option to disable SSL/TLS verification.
|
192
|
+
verify = config.get("verify")
|
193
|
+
if verify:
|
194
|
+
if verify.lower() in {"1", "yes", "on", "true"}:
|
195
|
+
# Enable SSL/TLS verification explicitly.
|
196
|
+
options.update({"verify": True})
|
197
|
+
elif verify.lower() in {"0", "no", "off", "false"}:
|
198
|
+
# Disable SSL/TLS verification entirely.
|
199
|
+
options.update({"verify": False})
|
200
|
+
else:
|
201
|
+
# The SSL/TLS certificate to verify against.
|
202
|
+
options.update({"verify": verify.strip('"')})
|
203
|
+
|
204
|
+
# If static access/secret keys were provided, use them.
|
205
|
+
aws_access_key_id = config.get("aws_access_key_id")
|
206
|
+
aws_secret_access_key = config.get("aws_secret_access_key")
|
207
|
+
if aws_access_key_id and aws_secret_access_key:
|
208
|
+
options.update(
|
209
|
+
{
|
210
|
+
"aws_access_key_id": aws_access_key_id,
|
211
|
+
"aws_secret_access_key": aws_secret_access_key,
|
212
|
+
}
|
213
|
+
)
|
166
214
|
|
167
|
-
#
|
168
|
-
client =
|
215
|
+
# Generate a CodeArtifact client using the callback.
|
216
|
+
client = self.make_client(options)
|
169
217
|
|
170
218
|
# Authorization tokens should be good for an hour by default.
|
171
219
|
token_duration = int(config.get("token_duration", 3600))
|
@@ -1,37 +1,14 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.4
|
2
2
|
Name: keyrings.codeartifact
|
3
|
-
Version: 2.
|
3
|
+
Version: 2.1.1
|
4
4
|
Summary: Automatically retrieve credentials for AWS CodeArtifact.
|
5
5
|
Author-email: "Joshua M. Keyes" <joshua.michael.keyes@gmail.com>
|
6
|
-
License: MIT License
|
7
|
-
|
8
|
-
Copyright (c) 2022 Joshua M. Keyes <joshua.michael.keyes@gmail.com>
|
9
|
-
|
10
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
11
|
-
of this software and associated documentation files (the "Software"), to deal
|
12
|
-
in the Software without restriction, including without limitation the rights
|
13
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
14
|
-
copies of the Software, and to permit persons to whom the Software is
|
15
|
-
furnished to do so, subject to the following conditions:
|
16
|
-
|
17
|
-
The above copyright notice and this permission notice shall be included in all
|
18
|
-
copies or substantial portions of the Software.
|
19
|
-
|
20
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
21
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
22
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
23
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
24
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
25
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
26
|
-
SOFTWARE.
|
27
|
-
|
28
6
|
Project-URL: Homepage, https://github.com/jmkeyes/keyrings.codeartifact
|
29
7
|
Project-URL: Issues, https://github.com/jmkeyes/keyrings.codeartifact/issues
|
30
8
|
Project-URL: Repository, https://github.com/jmkeyes/keyrings.codeartifact.git
|
31
9
|
Keywords: aws,codeartifact,keyring
|
32
10
|
Classifier: Development Status :: 4 - Beta
|
33
11
|
Classifier: Intended Audience :: Developers
|
34
|
-
Classifier: License :: OSI Approved :: MIT License
|
35
12
|
Classifier: Programming Language :: Python :: 3
|
36
13
|
Classifier: Programming Language :: Python :: 3 :: Only
|
37
14
|
Requires-Python: >=3.9
|
@@ -45,6 +22,7 @@ Requires-Dist: black; extra == "devel"
|
|
45
22
|
Provides-Extra: testing
|
46
23
|
Requires-Dist: pytest>=6; extra == "testing"
|
47
24
|
Requires-Dist: pytest-cov; extra == "testing"
|
25
|
+
Dynamic: license-file
|
48
26
|
|
49
27
|
AWS CodeArtifact Keyring Backend
|
50
28
|
================================
|
@@ -103,7 +81,6 @@ profile_name=default
|
|
103
81
|
# Use the following access keys.
|
104
82
|
aws_access_key_id=xxxxxxxxx
|
105
83
|
aws_secret_access_key=xxxxxxxxx
|
106
|
-
|
107
84
|
```
|
108
85
|
|
109
86
|
### Multiple Section Configuration (EXPERIMENTAL)
|
@@ -0,0 +1,8 @@
|
|
1
|
+
keyrings/__init__.py,sha256=ED6jHcYiuYpr_0vjGz0zx2lrrmJT9sDJCzIljoDfmlM,65
|
2
|
+
keyrings/codeartifact.py,sha256=tfXlAFvgwiNHmCaJvhhWb_ZUEs_U18q58V_-cqFenqk,8516
|
3
|
+
keyrings_codeartifact-2.1.1.dist-info/licenses/LICENSE,sha256=rBKHwYBR3VuB8PVCXNYgSaJqhvpradtRbu9SEMxfRiI,1105
|
4
|
+
keyrings_codeartifact-2.1.1.dist-info/METADATA,sha256=KfcIJ5OQVrt81zNmitYIOdq5P63qV5_l67eay6gTtis,4323
|
5
|
+
keyrings_codeartifact-2.1.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
6
|
+
keyrings_codeartifact-2.1.1.dist-info/entry_points.txt,sha256=Dtin9CsXc5q4hx0zKP2PiPNqVaQIlhnIX042QMqbM6U,60
|
7
|
+
keyrings_codeartifact-2.1.1.dist-info/top_level.txt,sha256=CFU-m0Q3B8OHGUonsk82bd-w5tsD16QsqpnMH4hufJY,9
|
8
|
+
keyrings_codeartifact-2.1.1.dist-info/RECORD,,
|
@@ -1,8 +0,0 @@
|
|
1
|
-
keyrings/__init__.py,sha256=ED6jHcYiuYpr_0vjGz0zx2lrrmJT9sDJCzIljoDfmlM,65
|
2
|
-
keyrings/codeartifact.py,sha256=H7Imyz0EI8jCRUR6hq0NbsHf7ALp8dDYhfVyY1ZmXlA,6709
|
3
|
-
keyrings.codeartifact-2.0.0.dist-info/LICENSE,sha256=rBKHwYBR3VuB8PVCXNYgSaJqhvpradtRbu9SEMxfRiI,1105
|
4
|
-
keyrings.codeartifact-2.0.0.dist-info/METADATA,sha256=z07WSTKR944BWBuD954rYcjnMIj_h_zzaViSDbVlx5E,5636
|
5
|
-
keyrings.codeartifact-2.0.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
6
|
-
keyrings.codeartifact-2.0.0.dist-info/entry_points.txt,sha256=Dtin9CsXc5q4hx0zKP2PiPNqVaQIlhnIX042QMqbM6U,60
|
7
|
-
keyrings.codeartifact-2.0.0.dist-info/top_level.txt,sha256=CFU-m0Q3B8OHGUonsk82bd-w5tsD16QsqpnMH4hufJY,9
|
8
|
-
keyrings.codeartifact-2.0.0.dist-info/RECORD,,
|
{keyrings.codeartifact-2.0.0.dist-info → keyrings_codeartifact-2.1.1.dist-info}/entry_points.txt
RENAMED
File without changes
|
{keyrings.codeartifact-2.0.0.dist-info → keyrings_codeartifact-2.1.1.dist-info/licenses}/LICENSE
RENAMED
File without changes
|
{keyrings.codeartifact-2.0.0.dist-info → keyrings_codeartifact-2.1.1.dist-info}/top_level.txt
RENAMED
File without changes
|