WeKnora deployment source with the reviewed wiki identity, summary and recovery fixes
Anydoc / anydoc parser engine (push) Canceled after 0s
App / Format, vet, test, and build (push) Canceled after 0s
CLI / test (macos-latest / go 1.26) (push) Canceled after 0s
CLI / test (ubuntu-latest / go 1.26) (push) Canceled after 0s
CLI / test (windows-latest / go 1.26) (push) Canceled after 0s
Build and Push Docker Image / build-ui (push) Canceled after 0s
Build and Push Docker Image / build-docreader (push) Canceled after 0s
Build and Push Docker Image / build-sandbox (push) Canceled after 0s
Build and Push Docker Image / build-app (amd64, linux/amd64, ubuntu-latest) (push) Canceled after 0s
Build and Push Docker Image / build-app (arm64, linux/arm64, ubuntu-24.04-arm) (push) Canceled after 0s
DocReader / Python tests and Go client tests (push) Canceled after 0s
Build & Publish (dsh-weknora) / Typecheck, test, pack (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (pinned) (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (latest, advisory) (push) Canceled after 0s
Frontend / Test, type-check, and build (push) Canceled after 0s
Go Lint Cache / warm lint cache (.) (push) Canceled after 0s
Go Lint Cache / warm lint cache (cli) (push) Canceled after 0s
Go Lint Cache / warm lint cache (client) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.10) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.11) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.12) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.13) (push) Canceled after 0s
Build and Push Docker Image / merge (push) Canceled after 0s
Build & Publish (dsh-weknora) / Publish to npm (push) Canceled after 0s
Build & Publish (mcp-server) / Build sdist + wheel (push) Canceled after 0s
Build & Publish (mcp-server) / Publish to PyPI (push) Canceled after 0s
Anydoc / anydoc parser engine (push) Canceled after 0s
App / Format, vet, test, and build (push) Canceled after 0s
CLI / test (macos-latest / go 1.26) (push) Canceled after 0s
CLI / test (ubuntu-latest / go 1.26) (push) Canceled after 0s
CLI / test (windows-latest / go 1.26) (push) Canceled after 0s
Build and Push Docker Image / build-ui (push) Canceled after 0s
Build and Push Docker Image / build-docreader (push) Canceled after 0s
Build and Push Docker Image / build-sandbox (push) Canceled after 0s
Build and Push Docker Image / build-app (amd64, linux/amd64, ubuntu-latest) (push) Canceled after 0s
Build and Push Docker Image / build-app (arm64, linux/arm64, ubuntu-24.04-arm) (push) Canceled after 0s
DocReader / Python tests and Go client tests (push) Canceled after 0s
Build & Publish (dsh-weknora) / Typecheck, test, pack (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (pinned) (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (latest, advisory) (push) Canceled after 0s
Frontend / Test, type-check, and build (push) Canceled after 0s
Go Lint Cache / warm lint cache (.) (push) Canceled after 0s
Go Lint Cache / warm lint cache (cli) (push) Canceled after 0s
Go Lint Cache / warm lint cache (client) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.10) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.11) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.12) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.13) (push) Canceled after 0s
Build and Push Docker Image / merge (push) Canceled after 0s
Build & Publish (dsh-weknora) / Publish to npm (push) Canceled after 0s
Build & Publish (mcp-server) / Build sdist + wheel (push) Canceled after 0s
Build & Publish (mcp-server) / Publish to PyPI (push) Canceled after 0s
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
package storageallowlist
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const AllowListEnv = "STORAGE_ALLOW_LIST"
|
||||
|
||||
var supported = []string{"local", "minio", "cos", "tos", "s3", "oss", "ks3", "obs"}
|
||||
|
||||
// Supported returns the canonical storage provider names in display order.
|
||||
func Supported() []string {
|
||||
providers := make([]string, len(supported))
|
||||
copy(providers, supported)
|
||||
return providers
|
||||
}
|
||||
|
||||
// AllowedMap returns which providers are permitted by STORAGE_ALLOW_LIST.
|
||||
func AllowedMap() map[string]bool {
|
||||
raw := strings.TrimSpace(os.Getenv(AllowListEnv))
|
||||
allowed := make(map[string]bool, len(supported))
|
||||
|
||||
if raw == "" {
|
||||
for _, provider := range supported {
|
||||
allowed[provider] = true
|
||||
}
|
||||
return allowed
|
||||
}
|
||||
|
||||
for _, item := range strings.FieldsFunc(raw, func(r rune) bool {
|
||||
switch r {
|
||||
case ',', ';', '|', '\n', '\t', ' ':
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}) {
|
||||
provider := strings.ToLower(strings.TrimSpace(item))
|
||||
if provider == "" {
|
||||
continue
|
||||
}
|
||||
for _, name := range supported {
|
||||
if provider == name {
|
||||
allowed[provider] = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return allowed
|
||||
}
|
||||
|
||||
// IsAllowed reports whether provider is permitted. Empty provider is treated as allowed.
|
||||
func IsAllowed(provider string) bool {
|
||||
provider = strings.ToLower(strings.TrimSpace(provider))
|
||||
if provider == "" {
|
||||
return true
|
||||
}
|
||||
return AllowedMap()[provider]
|
||||
}
|
||||
|
||||
// FirstAllowed returns the first supported provider allowed by STORAGE_ALLOW_LIST.
|
||||
func FirstAllowed() string {
|
||||
allowed := AllowedMap()
|
||||
for _, provider := range supported {
|
||||
if allowed[provider] {
|
||||
return provider
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// AllowedList returns allowed providers in canonical order.
|
||||
func AllowedList() []string {
|
||||
allowed := AllowedMap()
|
||||
out := make([]string, 0, len(supported))
|
||||
for _, provider := range supported {
|
||||
if allowed[provider] {
|
||||
out = append(out, provider)
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
Reference in New Issue
Block a user