@@ -130,6 +130,7 @@ ensure_bucket() {
130130 local bucket=" $1 "
131131 local location=" $2 "
132132 local cors_file=" $3 "
133+ local allow_public_policy=" ${4:- false} "
133134 local bucket_info
134135 local expected_location
135136 local actual_location
@@ -160,7 +161,7 @@ ensure_bucket() {
160161 --bucket " $bucket " \
161162 --query ' PolicyStatus.IsPublic' \
162163 --output text) "
163- if [[ " $public_policy " != " False" && " $public_policy " != " false" ]]; then
164+ if [[ " $allow_public_policy " != " true " && " $ public_policy" != " False" && " $public_policy " != " false" ]]; then
164165 echo " Tigris policy is public for bucket $bucket " >&2
165166 exit 1
166167 fi
@@ -183,7 +184,35 @@ ensure_bucket() {
183184}
184185
185186ensure_bucket " $TIGRIS_SOURCE_BUCKET " " $TIGRIS_SOURCE_LOCATION " " $work_dir /source-cors.json"
186- ensure_bucket " $TIGRIS_MEDIA_BUCKET " " $TIGRIS_MEDIA_LOCATION " " $work_dir /media-cors.json"
187+ ensure_bucket " $TIGRIS_MEDIA_BUCKET " " $TIGRIS_MEDIA_LOCATION " " $work_dir /media-cors.json" true
188+
189+ # Only immutable playback aliases are anonymously readable. Canonical media,
190+ # processing attempts, and source objects remain private. Asset identifiers are
191+ # unguessable UUIDs and the public API already grants playback by asset ID, so
192+ # signed cookies add no authorization boundary while preventing credentialed
193+ # browser playback on Tigris's S3-compatible CORS responses.
194+ jq -n --arg bucket " $TIGRIS_MEDIA_BUCKET " ' {
195+ Version: "2012-10-17",
196+ Statement: [{
197+ Sid: "PublicReadPlaybackAliases",
198+ Effect: "Allow",
199+ Principal: "*",
200+ Action: ["s3:GetObject"],
201+ Resource: ["arn:aws:s3:::" + $bucket + "/v/*"]
202+ }]
203+ }' > " $work_dir /media-policy.json"
204+ tigris_s3api put-bucket-policy \
205+ --bucket " $TIGRIS_MEDIA_BUCKET " \
206+ --policy " file://$work_dir /media-policy.json" > /dev/null
207+
208+ media_public_policy=" $( tigris_s3api get-bucket-policy-status \
209+ --bucket " $TIGRIS_MEDIA_BUCKET " \
210+ --query ' PolicyStatus.IsPublic' \
211+ --output text) "
212+ if [[ " $media_public_policy " != " True" && " $media_public_policy " != " true" ]]; then
213+ echo " Tigris playback alias policy is not public for bucket $TIGRIS_MEDIA_BUCKET " >&2
214+ exit 1
215+ fi
187216
188217playback_public_key_pem=" $( printf ' %s' " $TIGRIS_PLAYBACK_PUBLIC_KEY_PEM_B64 " | base64 --decode) "
189218if [[ " $playback_public_key_pem " != " -----BEGIN PUBLIC KEY-----" * ]]; then
@@ -234,4 +263,4 @@ aws ssm put-parameter \
234263 --overwrite \
235264 --no-cli-pager > /dev/null
236265
237- echo " Tigris source and media bucket contracts, private playback key , and custom playback domain are reconciled."
266+ echo " Tigris private source/canonical media, public playback aliases , and custom playback domain are reconciled."
0 commit comments