diff --git a/client/index.html b/client/index.html index ef770094..e0fad971 100644 --- a/client/index.html +++ b/client/index.html @@ -8,6 +8,7 @@ + diff --git a/server/common/config.go b/server/common/config.go index 4cdaf48c..92015154 100644 --- a/server/common/config.go +++ b/server/common/config.go @@ -78,6 +78,7 @@ func NewConfiguration() Configuration { FormElement{Name: "auto_connect", Type: "boolean", Default: false, Description: "User don't have to click on the login button if an admin is prefilling a unique backend"}, FormElement{Name: "remember_me", Type: "boolean", Default: true, Description: "Visiblity of the remember me button on the login screen"}, FormElement{Name: "upload_button", Type: "boolean", Default: false, Description: "Display the upload button on any device"}, + FormElement{Name: "custom_css", Type: "long_text", Default: "", Description: "Set custom css code for your instance"}, }, }, Form{ diff --git a/server/ctrl/static.go b/server/ctrl/static.go index 6801bf24..b5b2c681 100644 --- a/server/ctrl/static.go +++ b/server/ctrl/static.go @@ -91,6 +91,11 @@ func AboutHandler(ctx App, res http.ResponseWriter, req *http.Request) { }}) } +func CustomCssHandler(ctx App, res http.ResponseWriter, req *http.Request) { + res.Header().Set("Content-Type", "text/css"); + io.WriteString(res, Config.Get("general.custom_css").String()); +} + func ServeFile(res http.ResponseWriter, req *http.Request, filePath string) { zFilePath := filePath + ".gz" bFilePath := filePath + ".br" diff --git a/server/main.go b/server/main.go index 0d325c2e..593b98a2 100644 --- a/server/main.go +++ b/server/main.go @@ -101,6 +101,7 @@ func Init(a *App) { }) r.HandleFunc("/.well-known/security.txt", NewMiddlewareChain(WellKnownSecurityHandler, []Middleware{}, *a)).Methods("GET") r.HandleFunc("/healthz", NewMiddlewareChain(HealthHandler, []Middleware{}, *a)).Methods("GET") + r.HandleFunc("/custom.css", NewMiddlewareChain(CustomCssHandler, []Middleware{}, *a)).Methods("GET") if os.Getenv("DEBUG") == "true" { initDebugRoutes(r) diff --git a/server/middleware/http.go b/server/middleware/http.go index dfba1b5a..83583af8 100644 --- a/server/middleware/http.go +++ b/server/middleware/http.go @@ -48,7 +48,7 @@ func IndexHeaders(fn func(App, http.ResponseWriter, *http.Request)) func(ctx App header.Set("X-Powered-By", fmt.Sprintf("Filestash/%s.%s ", APP_VERSION, BUILD_DATE)) cspHeader := "default-src 'none'; " - cspHeader += "style-src 'unsafe-inline'; " + cspHeader += "style-src 'self' 'unsafe-inline'; " cspHeader += "font-src 'self' data:; " cspHeader += "manifest-src 'self'; " cspHeader += "script-src 'self' 'sha256-JNAde5CZQqXtYRLUk8CGgyJXo6C7Zs1lXPPClLM1YM4=' 'sha256-9/gQeQaAmVkFStl6tfCbHXn8mr6PgtxlH+hEp685lzY=' 'sha256-ER9LZCe8unYk8AJJ2qopE+rFh7OUv8QG5q3h6jZeoSk='; "