From ea7539ee439cf9e040e3767ca91164b7e630e3c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=84=B1=EA=B2=BD?= Date: Wed, 11 Nov 2026 16:06:45 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EC=9E=AC=EC=83=9D=20URL=EC=97=90=20?= =?UTF-8?q?=EC=9D=BD=EA=B8=B0=20=EC=A0=84=EC=9A=A9=20SAS=20=ED=86=A0?= =?UTF-8?q?=ED=81=B0=20=EC=82=AC=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 3 ++- app/utils/upload_blob_as_request.py | 8 ++++++-- config.py | 6 +++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 119d80c..9649ba5 100644 --- a/README.md +++ b/README.md @@ -101,7 +101,8 @@ CORS_MAX_AGE=600 # Preflight 요청 캐시 시간 (초) # ================================ # Azure Blob Storage 설정 # ================================ -AZURE_BLOB_SAS_TOKEN=your_sas_token # Azure Blob Storage SAS 토큰 +AZURE_BLOB_SAS_TOKEN=your_sas_token # 업로드·삭제용 SAS 토큰 (서버 내부 전용) +AZURE_BLOB_PLAYBACK_SAS_TOKEN=your_readonly_sas_token # 재생 URL에 붙는 읽기 전용(sp=r) SAS 토큰 AZURE_BLOB_BASE_URL=https://... # Azure Blob Storage 기본 URL # ================================ diff --git a/app/utils/upload_blob_as_request.py b/app/utils/upload_blob_as_request.py index 6a03e75..3e37679 100644 --- a/app/utils/upload_blob_as_request.py +++ b/app/utils/upload_blob_as_request.py @@ -91,16 +91,20 @@ async def close_shared_blob_client() -> None: def to_playback_url(blob_url: str | None) -> str | None: - """DB에 저장된 SAS 미포함 공개 URL에 읽기용 SAS 토큰을 붙여 반환합니다. + """DB에 저장된 SAS 미포함 공개 URL에 읽기 전용 SAS 토큰을 붙여 반환합니다. Azure Blob 익명(공개) 접근은 x-ms-version 헤더가 없어 Range 요청을 지원하지 않는 구버전 API로 처리되어 브라우저에서 영상/오디오 seek이 동작하지 않는다. SAS 토큰(sv= 포함)을 붙이면 최신 API 버전으로 처리되어 Range/Accept-Ranges가 정상 동작한다. DB에는 SAS 없는 URL을 그대로 저장하고, 응답 시점에만 붙인다. + + 이 URL은 API 응답으로 나가므로 재생용 토큰(AZURE_BLOB_PLAYBACK_SAS_TOKEN)만 + 쓴다. 미설정이어도 쓰기 권한이 있는 업로드용 토큰으로 대체하지 않고 SAS 없는 + URL을 그대로 반환한다. """ if not blob_url: return blob_url - sas_token = azure_blob_settings.AZURE_BLOB_SAS_TOKEN.strip("?'\"") + sas_token = azure_blob_settings.AZURE_BLOB_PLAYBACK_SAS_TOKEN.strip("?'\"") if not sas_token: return blob_url separator = "&" if "?" in blob_url else "?" diff --git a/config.py b/config.py index a70870d..7a69792 100644 --- a/config.py +++ b/config.py @@ -158,7 +158,11 @@ class AzureBlobSettings(BaseSettings): AZURE_BLOB_SAS_TOKEN: str = Field( default="", - description="Azure Blob Storage SAS 토큰", + description="Azure Blob Storage 업로드·삭제용 SAS 토큰 (서버 내부 전용, 응답에 노출 금지)", + ) + AZURE_BLOB_PLAYBACK_SAS_TOKEN: str = Field( + default="", + description="재생 URL에 붙여 응답으로 내보내는 읽기 전용(sp=r) SAS 토큰", ) AZURE_BLOB_BASE_URL: str = Field( default="https://ado2mediastoragepublic.blob.core.windows.net/ado2-media-public-access/ado2-media-original",