Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix Docker Healthcheck with Authentication & TLS
Closes #15
Fixed
/api/healthendpoint was behind the authentication middleware, causing Docker health probes to receive401 UnauthorizedwhenAUTH_ENABLED=true. The health endpoint is now exempt from authentication, following industry best practices for container orchestration.http://, causing TLS handshake errors when HTTPS was configured. A newhealthcheck.shscript auto-detects TLS configuration from environment variables and uses the correct scheme.Changed
Backend
ExcludePathssupport to the authentication middleware (internal/middleware/auth.go) - allows specific paths to bypass authentication/api/healthas an excluded path in route setup (internal/server/server.go)Docker
scripts/healthcheck.sh- TLS-aware healthcheck script that readsWEBCLI_TLS_CERT_PATH/TLS_CERT_PATHenvironment variables to determinehttpvshttpsschemeDockerfileto copy and usehealthcheck.shinstead of inlinecurlcommanddocker-compose.ymlto use/app/healthcheck.shfor health checksDocumentation
API.md- health endpoint now documented as not requiring authenticationdocs/SECURITY.md- added "Unauthenticated Endpoints" section listing exempt pathsdocs/swagger.json,docs/swagger.yaml) with health endpointTesting
TestBasicAuth_ExcludedPaths- verifies excluded paths bypass authTestBasicAuth_ExcludedPathsEmpty- verifies nil exclusions still require authTestBasicAuth_ExcludedPathsMultiple- verifies multiple paths can be excludedTestHandleHealth- basic health handler response testTestHandleHealth_NoAuthRequired- full routing integration test with auth middlewarehealthywithAUTH_ENABLED=truego test -race ./...)healthcheck.shSecurity Notes
/api/healthendpoint is exempt from authentication{"status":"ok"}- no sensitive information is exposedAUTH_ENABLED=trueExcludePathsmechanism uses exact path matching (no wildcards) to prevent accidental bypasses