mirror of
https://github.com/DrizzleTime/Foxel.git
synced 2026-06-26 01:31:42 +08:00
feat(S3): update region handling to allow blank input and improve user guidance
This commit is contained in:
@@ -69,7 +69,7 @@ async def _ensure_enabled() -> Optional[Response]:
|
||||
|
||||
async def _get_settings() -> Tuple[Optional[S3Settings], Optional[Response]]:
|
||||
bucket = (await ConfigService.get("S3_MAPPING_BUCKET", "foxel")) or "foxel"
|
||||
region = (await ConfigService.get("S3_MAPPING_REGION", "us-east-1")) or "us-east-1"
|
||||
region = ((await ConfigService.get("S3_MAPPING_REGION", "")) or "").strip()
|
||||
base_path = (await ConfigService.get("S3_MAPPING_BASE_PATH", "/")) or "/"
|
||||
access_key = (await ConfigService.get("S3_MAPPING_ACCESS_KEY")) or ""
|
||||
secret_key = (await ConfigService.get("S3_MAPPING_SECRET_KEY")) or ""
|
||||
@@ -145,7 +145,7 @@ async def _authorize_sigv4(request: Request, settings: S3Settings) -> Optional[R
|
||||
return _s3_error("InvalidAccessKeyId", "The AWS Access Key Id you provided does not exist in our records.", status=403)
|
||||
if service != "s3":
|
||||
return _s3_error("InvalidRequest", "Only service 's3' is supported", status=400)
|
||||
if region != settings["region"]:
|
||||
if settings.get("region") and region != settings["region"]:
|
||||
return _s3_error("AuthorizationHeaderMalformed", f"Region '{region}' is invalid", status=400)
|
||||
|
||||
amz_date = request.headers.get("x-amz-date")
|
||||
|
||||
@@ -319,6 +319,7 @@
|
||||
"File Domain": "File Domain",
|
||||
"Configure Access Key and Secret to enable S3 mapping.": "Configure Access Key and Secret to enable S3 mapping.",
|
||||
"Mount point inside the virtual file system (e.g. / or /workspace).": "Mount point inside the virtual file system (e.g. / or /workspace).",
|
||||
"Leave blank to accept any region.": "Leave blank to accept any region.",
|
||||
"Please input bucket name": "Please input bucket name",
|
||||
"Please input region": "Please input region",
|
||||
"Please input access key": "Please input access key",
|
||||
|
||||
@@ -338,6 +338,7 @@
|
||||
"File Domain": "文件域名",
|
||||
"Configure Access Key and Secret to enable S3 mapping.": "配置 Access Key 与 Secret 后才能启用 S3 映射。",
|
||||
"Mount point inside the virtual file system (e.g. / or /workspace).": "虚拟文件系统中的挂载路径,例如 / 或 /workspace。",
|
||||
"Leave blank to accept any region.": "留空表示接受任意 Region。",
|
||||
"Please input bucket name": "请输入 Bucket 名",
|
||||
"Please input region": "请输入 Region",
|
||||
"Please input access key": "请输入 Access Key",
|
||||
|
||||
@@ -39,7 +39,7 @@ export default function ProtocolMappingsTab({ config, loading, onSave }: Protoco
|
||||
setS3Enabled(truthy.has((config[S3_KEYS.ENABLED] ?? '1').toLowerCase()));
|
||||
s3Form.setFieldsValue({
|
||||
bucket: config[S3_KEYS.BUCKET] ?? 'foxel',
|
||||
region: config[S3_KEYS.REGION] ?? 'us-east-1',
|
||||
region: config[S3_KEYS.REGION] ?? '',
|
||||
basePath: config[S3_KEYS.BASE_PATH] ?? '/',
|
||||
accessKey: config[S3_KEYS.ACCESS_KEY] ?? '',
|
||||
secretKey: config[S3_KEYS.SECRET_KEY] ?? '',
|
||||
@@ -97,7 +97,7 @@ export default function ProtocolMappingsTab({ config, loading, onSave }: Protoco
|
||||
return trimmed.replace(/\/+$/, '') || '/';
|
||||
};
|
||||
|
||||
const regionValue = (watchRegion ?? config[S3_KEYS.REGION] ?? 'us-east-1').trim() || 'us-east-1';
|
||||
const regionValue = (watchRegion ?? config[S3_KEYS.REGION] ?? '').trim();
|
||||
const basePathValue = normalizeBasePath(watchBasePath ?? config[S3_KEYS.BASE_PATH] ?? '/');
|
||||
const accessKeyValue = (watchAccessKey ?? config[S3_KEYS.ACCESS_KEY] ?? '').trim();
|
||||
const secretValue = (watchSecretKey ?? config[S3_KEYS.SECRET_KEY] ?? '').trim();
|
||||
@@ -108,7 +108,7 @@ export default function ProtocolMappingsTab({ config, loading, onSave }: Protoco
|
||||
try {
|
||||
await onSave({
|
||||
[S3_KEYS.BUCKET]: values.bucket?.trim() || 'foxel',
|
||||
[S3_KEYS.REGION]: values.region?.trim() || 'us-east-1',
|
||||
[S3_KEYS.REGION]: values.region?.trim() || '',
|
||||
[S3_KEYS.BASE_PATH]: normalizeBasePath(values.basePath),
|
||||
[S3_KEYS.ACCESS_KEY]: values.accessKey?.trim() || '',
|
||||
[S3_KEYS.SECRET_KEY]: values.secretKey?.trim() || '',
|
||||
@@ -229,7 +229,7 @@ export default function ProtocolMappingsTab({ config, loading, onSave }: Protoco
|
||||
{
|
||||
key: 'region',
|
||||
label: t('Region'),
|
||||
children: regionValue,
|
||||
children: regionValue || t('Not set'),
|
||||
},
|
||||
{
|
||||
key: 'base-path',
|
||||
@@ -262,9 +262,9 @@ export default function ProtocolMappingsTab({ config, loading, onSave }: Protoco
|
||||
<Form.Item
|
||||
name="region"
|
||||
label={t('Region')}
|
||||
rules={[{ required: true, message: t('Please input region') }]}
|
||||
extra={t('Leave blank to accept any region.')}
|
||||
>
|
||||
<Input disabled={!s3Enabled || loading} />
|
||||
<Input disabled={!s3Enabled || loading} placeholder="us-east-1" />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="basePath"
|
||||
|
||||
Reference in New Issue
Block a user