From ea6507c9ebf3d264949305ff21195012e59f2697 Mon Sep 17 00:00:00 2001 From: Warren Chen Date: Thu, 30 Jul 2026 14:35:32 +0900 Subject: [PATCH] Preserve path bases in Member Center endpoint configuration --- README.md | 4 ++++ src/FileAccessAgent.Api/appsettings.json | 4 ++-- .../Configuration/MemberCenterOptions.cs | 4 ++-- src/FileAccessAgent.TestSite/Controllers/HomeController.cs | 5 ++++- src/FileAccessAgent.TestSite/Models/TestSiteAuthOptions.cs | 3 ++- 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 830c45c..225b512 100644 --- a/README.md +++ b/README.md @@ -184,6 +184,8 @@ docker run --rm -p 8080:8080 \ `MemberCenter__BaseUrl` 則是 Agent 呼叫 `/oauth/token` 與 delegated download token validation endpoint 的 server-to-server base URL,可依部署網路使用內網位址。 +若 `MemberCenter__BaseUrl` 含有 path base(例如 `https://member.example.com/api/`),`MemberCenter__TokenEndpointPath` 與 `MemberCenter__DownloadTokenValidationPath` 請使用不以 `/` 開頭的相對路徑,例如 `oauth/token`、`file-access/download-tokens/validate`,避免 HttpClient 組 URL 時把 `/api/` 丟掉。 + 若使用 local storage,建議掛載 volume,避免 container 移除後檔案遺失: ```bash @@ -247,6 +249,8 @@ docker run --rm -p 8080:8080 \ - `MemberCenter:ServiceClientId`(file_api) - `MemberCenter:ServiceClientSecret`(file_api) - `MemberCenter:ServiceScopes`(至少 `files:upload.write files:metadata.read files:delete files:download.delegate`) +- `MemberCenter:ServiceTokenEndpointPath`(預設 `oauth/token`;若 `Authority` 含 `/api/` 這類 path base,請使用不以 `/` 開頭的相對路徑) +- `MemberCenter:DelegatedDownloadTokenEndpointPath`(預設 `file-access/download-tokens`;同上,建議使用相對路徑) - `FileAccessAgent:BaseUrl` - `FileAccessAgent:TenantId` diff --git a/src/FileAccessAgent.Api/appsettings.json b/src/FileAccessAgent.Api/appsettings.json index 3a50357..4af6fe0 100644 --- a/src/FileAccessAgent.Api/appsettings.json +++ b/src/FileAccessAgent.Api/appsettings.json @@ -28,8 +28,8 @@ }, "MemberCenter": { "BaseUrl": "http://localhost:7850/", - "TokenEndpointPath": "/oauth/token", - "DownloadTokenValidationPath": "/file-access/download-tokens/validate", + "TokenEndpointPath": "oauth/token", + "DownloadTokenValidationPath": "file-access/download-tokens/validate", "ClientId": "f3806ab779d2440d8ff8f26aa01e995d", "ClientSecret": "P5myv2PmFlKBNR7ke+zrmjmTpV+ob/53VBtOHRMfXTU=", "Scope": "files:download.read" diff --git a/src/FileAccessAgent.Infrastructure/Configuration/MemberCenterOptions.cs b/src/FileAccessAgent.Infrastructure/Configuration/MemberCenterOptions.cs index 85169c9..d5a912f 100644 --- a/src/FileAccessAgent.Infrastructure/Configuration/MemberCenterOptions.cs +++ b/src/FileAccessAgent.Infrastructure/Configuration/MemberCenterOptions.cs @@ -5,8 +5,8 @@ public sealed class MemberCenterOptions public const string SectionName = "MemberCenter"; public string BaseUrl { get; set; } = "http://localhost:7850"; - public string TokenEndpointPath { get; set; } = "/oauth/token"; - public string DownloadTokenValidationPath { get; set; } = "/file-access/download-tokens/validate"; + public string TokenEndpointPath { get; set; } = "oauth/token"; + public string DownloadTokenValidationPath { get; set; } = "file-access/download-tokens/validate"; public string ClientId { get; set; } = string.Empty; public string ClientSecret { get; set; } = string.Empty; public string Scope { get; set; } = "files:download.read"; diff --git a/src/FileAccessAgent.TestSite/Controllers/HomeController.cs b/src/FileAccessAgent.TestSite/Controllers/HomeController.cs index eaf86ba..a6531bf 100644 --- a/src/FileAccessAgent.TestSite/Controllers/HomeController.cs +++ b/src/FileAccessAgent.TestSite/Controllers/HomeController.cs @@ -445,7 +445,10 @@ public class HomeController : Controller try { - using var response = await client.PostAsJsonAsync("/file-access/download-tokens", payload, HttpContext.RequestAborted); + using var response = await client.PostAsJsonAsync( + _authOptions.DelegatedDownloadTokenEndpointPath, + payload, + HttpContext.RequestAborted); var body = await response.Content.ReadAsStringAsync(HttpContext.RequestAborted); if (!response.IsSuccessStatusCode) { diff --git a/src/FileAccessAgent.TestSite/Models/TestSiteAuthOptions.cs b/src/FileAccessAgent.TestSite/Models/TestSiteAuthOptions.cs index b69455f..1691f53 100644 --- a/src/FileAccessAgent.TestSite/Models/TestSiteAuthOptions.cs +++ b/src/FileAccessAgent.TestSite/Models/TestSiteAuthOptions.cs @@ -17,5 +17,6 @@ public sealed class TestSiteAuthOptions public string ServiceClientId { get; set; } = string.Empty; // file_api client public string ServiceClientSecret { get; set; } = string.Empty; public string ServiceScopes { get; set; } = "files:upload.write files:metadata.read files:delete files:download.delegate"; - public string ServiceTokenEndpointPath { get; set; } = "/oauth/token"; + public string ServiceTokenEndpointPath { get; set; } = "oauth/token"; + public string DelegatedDownloadTokenEndpointPath { get; set; } = "file-access/download-tokens"; }