Merge pull request #367 from ejsadiarin/dev
feat(monitor): add basic-auth feature for protected sites
This commit is contained in:
commit
4d6600b0a3
2 changed files with 19 additions and 0 deletions
|
@ -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.
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue