Skip to content

lib/api: Add /rest/noauth/health health-check (fixes #8430) - #8585

Merged
calmh merged 4 commits into
syncthing:mainfrom
er-pa:dev/healthcheck
Oct 6, 2022
Merged

calmh merged 4 commits into
syncthing:mainfrom
er-pa:dev/healthcheck

Conversation

@er-pa

@er-pa er-pa commented Oct 6, 2022

Copy link
Copy Markdown
Member

Purpose

Added a status page to the REST API which can act as a health-check, this allows third-party services and devices to check the status of Syncthing without having to use an API-key or plain-texted credentials.

To accomplish this two things were adjusted:

  • Exception for /rest/status to the CSRF-token-requirement
  • Exception for /rest/status to the otherwise required authentication

And obviously the /rest/status functionality was added, which is a simple return of a JSON object. Since, if you reach that point - it all goes well anyways. If not, you'll get another kind of error before reaching this point.

Testing

Two parts:
1.) Functional; visit the url and call the url in several ways, browser/curl/wget/...
2.) Security: Since we made an exception in the security-layer; hack-and-slash the URL a little to see if we don't unexpectedly reach other pages from this status-page while being unauthenticated.

Documentation

The API documentation will have to be updated to cover this addition.

Eric P added 2 commits October 6, 2022 11:03
Added /rest/status as exception to the CSRF-token requirement and added a simple function to return a simple JSON object. The HTTP status gets send with per default
@er-pa
er-pa requested a review from calmh October 6, 2022 09:56
Comment thread lib/api/api.go Resolved
@calmh
calmh merged commit 7a40240 into syncthing:main Oct 6, 2022
@acolomb

acolomb commented Oct 6, 2022

Copy link
Copy Markdown
Member

Please do provide an appropriate documentation PR for the API endpoint. We put in quite some work to get caught up and have them all documented, let's try to keep it complete.

@acolomb acolomb changed the title lib/api: Add /rest/status health-check (#8430) lib/api: Add /rest/noauth/health health-check (fixes #8430) Oct 6, 2022
@acolomb acolomb mentioned this pull request Oct 6, 2022
7 of 11 tasks
@er-pa

er-pa commented Oct 6, 2022

Copy link
Copy Markdown
Member Author

Please do provide an appropriate documentation PR for the API endpoint. We put in quite some work to get caught up and have them all documented, let's try to keep it complete.

I will adjust the documentation and file a PR accordingly tomorrow.

@bt90

bt90 commented Nov 3, 2022

Copy link
Copy Markdown
Contributor

Our docker healthcheck is now using this endpoint #8640

emlun added a commit to emlun/syncthing that referenced this pull request Jan 7, 2023
With the no-auth API exception added in commit 7a40240 (PR syncthing#8585), we can
extend that with a few more exceptions instead of restructuring the routing
muxes and moving the static assets.
@er-pa
er-pa deleted the dev/healthcheck branch March 10, 2023 19:09
@st-review st-review added the frozen-due-to-age Issues closed and untouched for a long time, together with being locked for discussion label Oct 12, 2023
@syncthing syncthing locked and limited conversation to collaborators Oct 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

frozen-due-to-age Issues closed and untouched for a long time, together with being locked for discussion

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants