aboutsummaryrefslogtreecommitdiff
path: root/weed/server/filer_server.go
diff options
context:
space:
mode:
authorjerebear12 <72420925+jerebear12@users.noreply.github.com>2023-12-20 18:21:11 -0600
committerGitHub <noreply@github.com>2023-12-20 16:21:11 -0800
commit06343f897645c4650f8f65e9a7ecd9b255820cfd (patch)
treeff6053af3bb23025a8d66f4275a460aa3ce1fbdf /weed/server/filer_server.go
parent3c9bcfb864b6c06cdc8ca189655a896feab9d343 (diff)
downloadseaweedfs-06343f897645c4650f8f65e9a7ecd9b255820cfd.tar.xz
seaweedfs-06343f897645c4650f8f65e9a7ecd9b255820cfd.zip
Set allowed origins in config (#5109)
* Add a way to use a JWT in an HTTP only cookie If a JWT is not included in the Authorization header or a query string, attempt to get a JWT from an HTTP only cookie. * Added a way to specify allowed origins header from config * Removed unecessary log * Check list of domains from config or command flag * Handle default wildcard and change name of config value to cors
Diffstat (limited to 'weed/server/filer_server.go')
-rw-r--r--weed/server/filer_server.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/weed/server/filer_server.go b/weed/server/filer_server.go
index 1b50d47c7..20b5151cd 100644
--- a/weed/server/filer_server.go
+++ b/weed/server/filer_server.go
@@ -5,6 +5,7 @@ import (
"fmt"
"net/http"
"os"
+ "strings"
"sync"
"time"
@@ -70,6 +71,7 @@ type FilerOption struct {
ShowUIDirectoryDelete bool
DownloadMaxBytesPs int64
DiskType string
+ AllowedOrigins []string
}
type FilerServer struct {
@@ -107,6 +109,14 @@ func NewFilerServer(defaultMux, readonlyMux *http.ServeMux, option *FilerOption)
v.SetDefault("jwt.filer_signing.read.expires_after_seconds", 60)
readExpiresAfterSec := v.GetInt("jwt.filer_signing.read.expires_after_seconds")
+ v.SetDefault("cors.allowed_origins.values", "*")
+
+ if (option.AllowedOrigins == nil) || (len(option.AllowedOrigins) == 0) {
+ allowedOrigins := v.GetString("cors.allowed_origins.values")
+ domains := strings.Split(allowedOrigins, ",")
+ option.AllowedOrigins = domains
+ }
+
fs = &FilerServer{
option: option,
grpcDialOption: security.LoadClientTLS(util.GetViper(), "grpc.filer"),