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

fix: expose healthcheck API as public endpoint #381

Merged
merged 1 commit into from
Jun 3, 2021
Merged

fix: expose healthcheck API as public endpoint #381

merged 1 commit into from
Jun 3, 2021

Conversation

mr-karan
Copy link
Collaborator

@mr-karan mr-karan commented Jun 2, 2021

Fixes #380

If basic auth is enabled, the endpoint will still respond with 200.

curl -i localhost:9000/api/health
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
Date: Wed, 02 Jun 2021 14:38:47 GMT
Content-Length: 14

{"data":true}

@knadh
Copy link
Owner

knadh commented Jun 3, 2021

hm, this would make /api/health an exception to the /api/* path which is meant to be private, complicating writing firewall and proxy rules.

How about we retain the old /api/health for backwards compatibility (and deprecate it) and add a new public handler, /health?

- Adds `/health` as a public facing healthcheck endpoint.
- `/api/health` is meant for internal healthchecks. This endpoint in
  future can serve sensitive information about Listmonk *or* can be
deprecated if there's not enough usecase.

Closes #380
@mr-karan
Copy link
Collaborator Author

mr-karan commented Jun 3, 2021

path which is meant to be private, complicating writing firewall and proxy rules.

Makes sense.

How about we retain the old /api/health for backwards compatibility (and deprecate it) and add a new public handler, /health?

Made the changes.

❯ curl -i localhost:9999/health localhost:9999/api/health
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
Date: Thu, 03 Jun 2021 05:53:27 GMT
Content-Length: 14

{"data":true}
HTTP/1.1 401 Unauthorized
Content-Type: application/json; charset=UTF-8
Www-Authenticate: basic realm=Restricted
Date: Thu, 03 Jun 2021 05:53:27 GMT
Content-Length: 27

{"message":"Unauthorized"}

@knadh knadh merged commit baca95e into knadh:master Jun 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Health Check returns 401 when authentication is enabled
2 participants