diff --git a/docs/configuration.md b/docs/configuration.md index 844d34d..b14c568 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -1476,6 +1476,7 @@ Properties for each site: | allow-insecure | boolean | no | false | | same-tab | boolean | no | false | | alt-status-codes | array | no | | +| basic-auth | object | no | | `title` @@ -1524,6 +1525,16 @@ alt-status-codes: - 403 ``` +`basic-auth` + +HTTP Basic Authentication credentials for protected sites. + +```yaml +basic-auth: + usename: your-username + password: your-password +``` + ### Releases Display a list of latest releases for specific repositories on Github, GitLab, Codeberg or Docker Hub. diff --git a/internal/glance/widget-monitor.go b/internal/glance/widget-monitor.go index 76f0d45..e42a710 100644 --- a/internal/glance/widget-monitor.go +++ b/internal/glance/widget-monitor.go @@ -118,6 +118,10 @@ type SiteStatusRequest struct { DefaultURL string `yaml:"url"` CheckURL string `yaml:"check-url"` AllowInsecure bool `yaml:"allow-insecure"` + BasicAuth struct { + Username string `yaml:"username"` + Password string `yaml:"password"` + } `yaml:"basic-auth"` } type siteStatus struct { @@ -141,6 +145,10 @@ func fetchSiteStatusTask(statusRequest *SiteStatusRequest) (siteStatus, error) { }, nil } + if statusRequest.BasicAuth.Username != "" || statusRequest.BasicAuth.Password != "" { + request.SetBasicAuth(statusRequest.BasicAuth.Username, statusRequest.BasicAuth.Password) + } + ctx, cancel := context.WithTimeout(context.Background(), time.Second*3) defer cancel() request = request.WithContext(ctx)