Merge pull request #1057 from dgrah50/add-chalice-verify-ssl-option

(feat): Chalice - Allow option to set ssl verification to false
This commit is contained in:
Kraiem Taha Yassine 2023-03-28 09:19:58 +01:00 committed by GitHub
commit faa0683f9b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 4 deletions

View file

@ -16,7 +16,8 @@ else:
aws_access_key_id=config("S3_KEY"),
aws_secret_access_key=config("S3_SECRET"),
config=Config(signature_version='s3v4'),
region_name=config("sessions_region"))
region_name=config("sessions_region"),
verify=not config("S3_DISABLE_SSL_VERIFY", default=False, cast=bool))
def __get_s3_resource():
@ -26,7 +27,8 @@ def __get_s3_resource():
aws_access_key_id=config("S3_KEY"),
aws_secret_access_key=config("S3_SECRET"),
config=Config(signature_version='s3v4'),
region_name=config("sessions_region"))
region_name=config("sessions_region"),
verify=not config("S3_DISABLE_SSL_VERIFY", default=False, cast=bool))
def exists(bucket, key):
@ -81,7 +83,8 @@ def get_presigned_url_for_upload_secure(bucket, expires_in, key, conditions=None
Conditions=conditions,
)
req = PreparedRequest()
req.prepare_url(f"{url_parts['url']}/{url_parts['fields']['key']}", url_parts['fields'])
req.prepare_url(
f"{url_parts['url']}/{url_parts['fields']['key']}", url_parts['fields'])
return req.url
@ -101,7 +104,8 @@ def get_file(source_bucket, source_key):
def rename(source_bucket, source_key, target_bucket, target_key):
s3 = __get_s3_resource()
s3.Object(target_bucket, target_key).copy_from(CopySource=f'{source_bucket}/{source_key}')
s3.Object(target_bucket, target_key).copy_from(
CopySource=f'{source_bucket}/{source_key}')
s3.Object(source_bucket, source_key).delete()

View file

@ -10,6 +10,7 @@ EMAIL_USE_TLS=true
S3_HOST=
S3_KEY=
S3_SECRET=
S3_DISABLE_SSL_VERIFY=
SITE_URL=
announcement_url=
captcha_key=

View file

@ -11,6 +11,7 @@ LICENSE_KEY=
S3_HOST=
S3_KEY=
S3_SECRET=
S3_DISABLE_SSL_VERIFY=
SAML2_MD_URL=
SITE_URL=
announcement_url=