From 6c94173ca1b979af2bc2417da806ab2379ccbb98 Mon Sep 17 00:00:00 2001 From: Nicola Murino Date: Mon, 27 May 2024 18:43:44 +0200 Subject: [PATCH] WebUI branding: remove unused login_image_path from config Signed-off-by: Nicola Murino --- internal/config/config.go | 6 ------ internal/config/config_test.go | 3 --- internal/httpd/httpd.go | 7 ------- internal/httpd/internal_test.go | 7 ++----- sftpgo.json | 2 -- 5 files changed, 2 insertions(+), 23 deletions(-) diff --git a/internal/config/config.go b/internal/config/config.go index 051f18ba..285ebf3d 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -1650,12 +1650,6 @@ func getHTTPDUIBrandingFromEnv(prefix string, branding httpd.UIBranding) (httpd. isSet = true } - loginImagePath, ok := os.LookupEnv(fmt.Sprintf("%s__LOGIN_IMAGE_PATH", prefix)) - if ok { - branding.LoginImagePath = loginImagePath - isSet = true - } - disclaimerName, ok := os.LookupEnv(fmt.Sprintf("%s__DISCLAIMER_NAME", prefix)) if ok { branding.DisclaimerName = disclaimerName diff --git a/internal/config/config_test.go b/internal/config/config_test.go index 17fc4702..fc6d9f98 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -1207,7 +1207,6 @@ func TestHTTPDBindingsFromEnv(t *testing.T) { os.Setenv("SFTPGO_HTTPD__BINDINGS__2__EXTRA_CSS__1__PATH", "path2") os.Setenv("SFTPGO_HTTPD__BINDINGS__2__BRANDING__WEB_ADMIN__FAVICON_PATH", "favicon.ico") os.Setenv("SFTPGO_HTTPD__BINDINGS__2__BRANDING__WEB_CLIENT__LOGO_PATH", "logo.png") - os.Setenv("SFTPGO_HTTPD__BINDINGS__2__BRANDING__WEB_ADMIN__LOGIN_IMAGE_PATH", "login_image.png") os.Setenv("SFTPGO_HTTPD__BINDINGS__2__BRANDING__WEB_CLIENT__DISCLAIMER_NAME", "disclaimer") os.Setenv("SFTPGO_HTTPD__BINDINGS__2__BRANDING__WEB_ADMIN__DISCLAIMER_PATH", "disclaimer.html") os.Setenv("SFTPGO_HTTPD__BINDINGS__2__BRANDING__WEB_CLIENT__DEFAULT_CSS", "default.css") @@ -1272,7 +1271,6 @@ func TestHTTPDBindingsFromEnv(t *testing.T) { os.Unsetenv("SFTPGO_HTTPD__BINDINGS__2__EXTRA_CSS__1__PATH") os.Unsetenv("SFTPGO_HTTPD__BINDINGS__2__BRANDING__WEB_ADMIN__FAVICON_PATH") os.Unsetenv("SFTPGO_HTTPD__BINDINGS__2__BRANDING__WEB_CLIENT__LOGO_PATH") - os.Unsetenv("SFTPGO_HTTPD__BINDINGS__2__BRANDING__WEB_ADMIN__LOGIN_IMAGE_PATH") os.Unsetenv("SFTPGO_HTTPD__BINDINGS__2__BRANDING__WEB_CLIENT__DISCLAIMER_NAME") os.Unsetenv("SFTPGO_HTTPD__BINDINGS__2__BRANDING__WEB_ADMIN__DISCLAIMER_PATH") os.Unsetenv("SFTPGO_HTTPD__BINDINGS__2__BRANDING__WEB_CLIENT__DEFAULT_CSS") @@ -1380,7 +1378,6 @@ func TestHTTPDBindingsFromEnv(t *testing.T) { require.Equal(t, "same-origin", bindings[2].Security.CrossOriginOpenerPolicy) require.Equal(t, "favicon.ico", bindings[2].Branding.WebAdmin.FaviconPath) require.Equal(t, "logo.png", bindings[2].Branding.WebClient.LogoPath) - require.Equal(t, "login_image.png", bindings[2].Branding.WebAdmin.LoginImagePath) require.Equal(t, "disclaimer", bindings[2].Branding.WebClient.DisclaimerName) require.Equal(t, "disclaimer.html", bindings[2].Branding.WebAdmin.DisclaimerPath) require.Equal(t, []string{"default.css"}, bindings[2].Branding.WebClient.DefaultCSS) diff --git a/internal/httpd/httpd.go b/internal/httpd/httpd.go index 62a4cdfb..1d001e25 100644 --- a/internal/httpd/httpd.go +++ b/internal/httpd/httpd.go @@ -398,8 +398,6 @@ type UIBranding struct { // For example, if you create a directory named "branding" inside the static dir and // put the "mylogo.png" file in it, you must set "/branding/mylogo.png" as logo path. LogoPath string `json:"logo_path" mapstructure:"logo_path"` - // Path to the image to show on the login screen relative to "static_files_path" - LoginImagePath string `json:"login_image_path" mapstructure:"login_image_path"` // Path to your favicon relative to "static_files_path" FaviconPath string `json:"favicon_path" mapstructure:"favicon_path"` // DisclaimerName defines the name for the link to your optional disclaimer @@ -420,11 +418,6 @@ func (b *UIBranding) check() { } else { b.LogoPath = "/img/logo.png" } - if b.LoginImagePath != "" { - b.LoginImagePath = util.CleanPath(b.LoginImagePath) - } else { - b.LoginImagePath = "/img/login_image.png" - } if b.FaviconPath != "" { b.FaviconPath = util.CleanPath(b.FaviconPath) } else { diff --git a/internal/httpd/internal_test.go b/internal/httpd/internal_test.go index 4bc2399f..ea48eb9c 100644 --- a/internal/httpd/internal_test.go +++ b/internal/httpd/internal_test.go @@ -330,9 +330,8 @@ func TestBrandingValidation(t *testing.T) { b := Binding{ Branding: Branding{ WebAdmin: UIBranding{ - LogoPath: "path1", - LoginImagePath: "login1.png", - DefaultCSS: []string{"my.css"}, + LogoPath: "path1", + DefaultCSS: []string{"my.css"}, }, WebClient: UIBranding{ FaviconPath: "favicon1.ico", @@ -344,12 +343,10 @@ func TestBrandingValidation(t *testing.T) { b.checkBranding() assert.Equal(t, "/favicon.ico", b.Branding.WebAdmin.FaviconPath) assert.Equal(t, "/path1", b.Branding.WebAdmin.LogoPath) - assert.Equal(t, "/login1.png", b.Branding.WebAdmin.LoginImagePath) assert.Equal(t, []string{"/my.css"}, b.Branding.WebAdmin.DefaultCSS) assert.Len(t, b.Branding.WebAdmin.ExtraCSS, 0) assert.Equal(t, "/favicon1.ico", b.Branding.WebClient.FaviconPath) assert.Equal(t, path.Join(webStaticFilesPath, "/path2"), b.Branding.WebClient.DisclaimerPath) - assert.Equal(t, "/img/login_image.png", b.Branding.WebClient.LoginImagePath) if assert.Len(t, b.Branding.WebClient.ExtraCSS, 1) { assert.Equal(t, "/1.css", b.Branding.WebClient.ExtraCSS[0]) } diff --git a/sftpgo.json b/sftpgo.json index 4309307d..e634fedf 100644 --- a/sftpgo.json +++ b/sftpgo.json @@ -319,7 +319,6 @@ "short_name": "", "favicon_path": "", "logo_path": "", - "login_image_path": "", "disclaimer_name": "", "disclaimer_path": "", "default_css": [], @@ -330,7 +329,6 @@ "short_name": "", "favicon_path": "", "logo_path": "", - "login_image_path": "", "disclaimer_name": "", "disclaimer_path": "", "default_css": [],