Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: allow basic authentication using headers for monitors #87

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ You can either deploy with **Cloudflare Deploy Button** using GitHub Actions or
expectStatus: 200 # operational status, default=200
followRedirect: false # should fetch follow redirects, default=false
linkable: false # should the titles be links to the service, default=true
withCredentials: false # specify if authentication is needed, set as false when not required
bearer: 'dXNlcjpwYXNz' # base64 encoded string of `username:password`, required if authentication is supported
```

5. Push to `main` branch to trigger the deployment
Expand Down
2 changes: 2 additions & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ monitors:
expectStatus: 200 # operational status, default=200
followRedirect: false # should fetch follow redirects, default=false
linkable: false # allows the title to be a link, default=true
withCredentials: false # specify if authentication is needed, set as false when not required
bearer: 'dXNlcjpwYXNz' # base64 encoded string of `username:password`, required if authentication is supported

- id: www-cloudflare-com
name: www.cloudflare.com
Expand Down
2 changes: 2 additions & 0 deletions src/functions/cronTrigger.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ export async function processCronTrigger(event) {
const init = {
method: monitor.method || 'GET',
redirect: monitor.followRedirect ? 'follow' : 'manual',
withCredentials: monitor.withCredentials,
headers: {
'User-Agent': config.settings.user_agent || 'cf-worker-status-page',
'Authorization': monitor.withCredentials ? ('Basic ' + monitor.bearer) : '',
},
}

Expand Down