From 66bd5d2f7fd84eec39d69f4a8f5c435fc978804f Mon Sep 17 00:00:00 2001 From: Leonardo Bishop Date: Thu, 19 Mar 2026 17:14:20 +0000 Subject: Add site passwords --- pkg/site/fs.go | 6 ------ pkg/site/site.go | 11 +++++++---- 2 files changed, 7 insertions(+), 10 deletions(-) (limited to 'pkg/site') diff --git a/pkg/site/fs.go b/pkg/site/fs.go index ec57318..4542344 100644 --- a/pkg/site/fs.go +++ b/pkg/site/fs.go @@ -21,12 +21,6 @@ func NewSiteFileServer(root http.FileSystem, siteConfig *config.SiteConfig) *Sit } func (fs *SiteFileServer) ServeHTTP(w http.ResponseWriter, r *http.Request) { - if fs.siteConfig.Flags&config.FlagDisable != 0 { - w.WriteHeader(http.StatusForbidden) - html.ForbiddenDisabledPage(fs.siteConfig.Host).Render(w) - return - } - path := filepath.Clean(r.URL.Path) var info os.FileInfo diff --git a/pkg/site/site.go b/pkg/site/site.go index 8b7af41..e15480f 100644 --- a/pkg/site/site.go +++ b/pkg/site/site.go @@ -12,6 +12,7 @@ import ( "strings" "time" + "github.com/LMBishop/scrapbook/pkg/auth" "github.com/LMBishop/scrapbook/pkg/config" ) @@ -19,10 +20,11 @@ const versionRegex = "[0-9]{4}_[0-9]{2}_[0-9]{2}_[0-9]{2}_[0-9]{2}_[0-9]{2}" const timeFormat = "2006_01_02_15_04_05" type Site struct { - Name string - Path string - Handler http.Handler - SiteConfig *config.SiteConfig + Name string + Path string + Handler http.Handler + Authenticator *auth.Authenticator + SiteConfig *config.SiteConfig } func NewSite(name string, dir string, config *config.SiteConfig) *Site { @@ -30,6 +32,7 @@ func NewSite(name string, dir string, config *config.SiteConfig) *Site { site.Name = name site.Path = dir site.SiteConfig = config + site.Authenticator = auth.NewAuthenticator() site.Handler = NewSiteFileServer(http.Dir(path.Join(dir, "default")), config) return &site } -- cgit v1.2.3-70-g09d2