Skip to content

Commit 4d6600b

Browse files
authored
Merge pull request #367 from ejsadiarin/dev
feat(monitor): add basic-auth feature for protected sites
2 parents c33fe45 + dac0d15 commit 4d6600b

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

docs/configuration.md

+11
Original file line numberDiff line numberDiff line change
@@ -1476,6 +1476,7 @@ Properties for each site:
14761476
| allow-insecure | boolean | no | false |
14771477
| same-tab | boolean | no | false |
14781478
| alt-status-codes | array | no | |
1479+
| basic-auth | object | no | |
14791480

14801481
`title`
14811482

@@ -1524,6 +1525,16 @@ alt-status-codes:
15241525
- 403
15251526
```
15261527

1528+
`basic-auth`
1529+
1530+
HTTP Basic Authentication credentials for protected sites.
1531+
1532+
```yaml
1533+
basic-auth:
1534+
usename: your-username
1535+
password: your-password
1536+
```
1537+
15271538
### Releases
15281539
Display a list of latest releases for specific repositories on Github, GitLab, Codeberg or Docker Hub.
15291540

internal/glance/widget-monitor.go

+8
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ type SiteStatusRequest struct {
118118
DefaultURL string `yaml:"url"`
119119
CheckURL string `yaml:"check-url"`
120120
AllowInsecure bool `yaml:"allow-insecure"`
121+
BasicAuth struct {
122+
Username string `yaml:"username"`
123+
Password string `yaml:"password"`
124+
} `yaml:"basic-auth"`
121125
}
122126

123127
type siteStatus struct {
@@ -141,6 +145,10 @@ func fetchSiteStatusTask(statusRequest *SiteStatusRequest) (siteStatus, error) {
141145
}, nil
142146
}
143147

148+
if statusRequest.BasicAuth.Username != "" || statusRequest.BasicAuth.Password != "" {
149+
request.SetBasicAuth(statusRequest.BasicAuth.Username, statusRequest.BasicAuth.Password)
150+
}
151+
144152
ctx, cancel := context.WithTimeout(context.Background(), time.Second*3)
145153
defer cancel()
146154
request = request.WithContext(ctx)

0 commit comments

Comments
 (0)