fix: correct OAuth service health check URL#3185
Merged
Umang01-hash merged 5 commits intogofr-dev:developmentfrom Mar 24, 2026
Merged
fix: correct OAuth service health check URL#3185Umang01-hash merged 5 commits intogofr-dev:developmentfrom
Umang01-hash merged 5 commits intogofr-dev:developmentfrom
Conversation
EnableOAuth was passing the full JWKS endpoint URL as the HTTP service address, causing the health check to append /.well-known/alive to the JWKS path instead of the host root. Parse the URL to separate base URL from JWKS path, so health checks hit the correct endpoint. Fixes gofr-dev#3179
Adds TestEnableOAuth_HealthCheckEndpoint that passes a full JWKS URL with a path and asserts the health check hits /.well-known/alive on the host root, not on the JWKS path.
The service layer constructs URLs as h.url + "/" + path, so passing a path with a leading slash creates a double-slash (e.g., http://host//.well-known/jwks.json). Strip the leading slash to match the convention used by HealthCheck. Also strengthens the test to verify JWKS fetching returns 200, ensuring the path is correctly constructed without double slashes.
url.Parse is very permissive and rarely returns errors. Inputs like empty strings, relative paths, or non-HTTP schemes would silently produce a bogus base URL, misconfiguring OAuth without any error. Add explicit validation that scheme is http/https and host is non-empty. Add TestEnableOAuth_InvalidEndpoints covering these edge cases.
Umang01-hash
approved these changes
Mar 24, 2026
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.
Summary
EnableOAuthpassed the full JWKS endpoint URL (e.g.,https://auth.example.com/.well-known/jwks.json) as the HTTP service address, causing health checks to hithttps://auth.example.com/.well-known/jwks.json/.well-known/alive— an invalid URL that always fails and degrades application health status.scheme://host) for HTTP service registration, and pass the JWKS path separately viaOauthConfigs.Path(already supported but never populated).https://auth.example.com/.well-known/alivePathfield inOauthConfigsTest plan
All existing tests pass (
go test ./pkg/gofr/...)Linter passes with 0 issues (
golangci-lint run ./pkg/gofr/)Manual verification: call
EnableOAuthwith a full JWKS URL and confirm health check hits the host rootCloses Incorrect service health check status when using EnableOAuth #3179