Skip to content

Commit 3e5922d

Browse files
jensensclaude
andcommitted
fix: pass PGTHUMBOR_S3_ACCESS_KEY/SECRET_KEY credentials to boto3
Without explicit credentials, boto3 only uses its default chain (AWS_ACCESS_KEY_ID etc.), ignoring the pgthumbor-specific env vars. Fixes #2. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 607673b commit 3e5922d

3 files changed

Lines changed: 15 additions & 0 deletions

File tree

CHANGES.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## 0.4.2 (2026-04-02)
4+
5+
- Fix: S3 loader now reads `PGTHUMBOR_S3_ACCESS_KEY` and `PGTHUMBOR_S3_SECRET_KEY`
6+
env vars and passes them to boto3. Previously credentials were only picked up
7+
via boto3's default chain (`AWS_ACCESS_KEY_ID`/`AWS_SECRET_ACCESS_KEY`).
8+
Fixes [#2](https://github.com/bluedynamics/zodb-pgjsonb-thumborblobloader/issues/2).
9+
310
## 0.4.1 (2026-04-02)
411

512
- Fix: Docker image missing `boto3` — S3 blob loading failed with

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ The image is automatically rebuilt weekly when a new Thumbor version appears on
9797
| `PGTHUMBOR_S3_BUCKET` | `""` | S3 bucket for blob fallback (empty = disabled) |
9898
| `PGTHUMBOR_S3_REGION` | `us-east-1` | S3 region |
9999
| `PGTHUMBOR_S3_ENDPOINT` | `""` | S3 endpoint for MinIO/Ceph (empty = AWS) |
100+
| `PGTHUMBOR_S3_ACCESS_KEY` | `""` | S3 access key (empty = boto3 default chain) |
101+
| `PGTHUMBOR_S3_SECRET_KEY` | `""` | S3 secret key (empty = boto3 default chain) |
100102
| `THUMBOR_AUTO_WEBP` | `"true"` | Auto-convert to WebP when browser supports it |
101103
| `THUMBOR_AUTO_AVIF` | `"false"` | Auto-convert to AVIF when browser supports it |
102104
| `THUMBOR_DETECTORS` | `""` | Comma-separated Thumbor detector modules for `/smart/` URLs (empty = disabled) |

src/zodb_pgjsonb_thumborblobloader/s3.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import asyncio
1212
import logging
13+
import os
1314

1415

1516
logger = logging.getLogger(__name__)
@@ -30,6 +31,11 @@ def _get_s3_client(bucket: str, region: str, endpoint: str = ""):
3031
kwargs: dict = {"region_name": region}
3132
if endpoint:
3233
kwargs["endpoint_url"] = endpoint
34+
access_key = os.environ.get("PGTHUMBOR_S3_ACCESS_KEY", "")
35+
secret_key = os.environ.get("PGTHUMBOR_S3_SECRET_KEY", "")
36+
if access_key and secret_key:
37+
kwargs["aws_access_key_id"] = access_key
38+
kwargs["aws_secret_access_key"] = secret_key
3339
_s3_client = boto3.client("s3", **kwargs)
3440
_s3_config = key
3541
return _s3_client

0 commit comments

Comments
 (0)