Skip to content

Commit d1b7cf9

Browse files
authored
Add option to bypass authenticating to S3 (gorilla-co#86)
1 parent 405890a commit d1b7cf9

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

s3pypi/__main__.py

+5
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ def get_arg_parser():
6262
action="store_true",
6363
help="Write a root index that lists all available package names.",
6464
)
65+
p.add_argument(
66+
"--no-sign-request",
67+
action="store_true",
68+
help="Don't use authentication when communicating with S3.",
69+
)
6570
p.add_argument("-f", "--force", action="store_true", help="Overwrite files.")
6671
p.add_argument("-v", "--verbose", action="store_true", help="Verbose output.")
6772
p.add_argument("-V", "--version", action="version", version=__version__)

s3pypi/storage.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import boto3
55
import botocore
6+
from botocore.config import Config
67

78
from s3pypi.index import Index
89

@@ -20,8 +21,13 @@ def __init__(
2021
s3_endpoint_url: Optional[str] = None,
2122
s3_put_args: Optional[dict] = None,
2223
unsafe_s3_website: bool = False,
24+
no_sign_request: bool = False,
2325
):
24-
self.s3 = session.resource("s3", endpoint_url=s3_endpoint_url)
26+
_config = None
27+
if no_sign_request:
28+
_config = Config(signature_version=botocore.session.UNSIGNED)
29+
30+
self.s3 = session.resource("s3", endpoint_url=s3_endpoint_url, config=_config)
2531
self.bucket = bucket
2632
self.prefix = prefix
2733
self.index_name = self._index if unsafe_s3_website else ""

0 commit comments

Comments
 (0)