Preserve path bases in Member Center endpoint configuration

This commit is contained in:
Warren Chen 2026-07-30 14:35:32 +09:00
parent bb219fcbb3
commit ea6507c9eb
5 changed files with 14 additions and 6 deletions

View File

@ -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`

View File

@ -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"

View File

@ -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";

View File

@ -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)
{

View File

@ -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";
}