Merge pull request #367 from ejsadiarin/dev

feat(monitor): add basic-auth feature for protected sites
This commit is contained in:
Svilen Markov 2025-02-22 13:30:09 +00:00 committed by GitHub
commit 4d6600b0a3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 19 additions and 0 deletions

View file

@ -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.

View file

@ -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)