From 4bb97c73a96ce541157a87e57611136a37436c2d Mon Sep 17 00:00:00 2001 From: Maksim Nabokikh Date: Wed, 16 Oct 2024 12:23:09 +0200 Subject: [PATCH] Handle root path better (than nothing) (#3747) Signed-off-by: maksim.nabokikh Signed-off-by: maksim.nabokikh --- server/server.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/server/server.go b/server/server.go index e299e32f7d..5c5faa3003 100644 --- a/server/server.go +++ b/server/server.go @@ -443,6 +443,20 @@ func newServer(ctx context.Context, c Config, rotationStrategy rotationStrategy) return nil, err } handleWithCORS("/.well-known/openid-configuration", discoveryHandler) + // Handle the root path for the better user experience. + handleWithCORS("/", func(w http.ResponseWriter, r *http.Request) { + _, err := fmt.Fprintf(w, ` + Dex +

Dex IdP

+

A Federated OpenID Connect Provider

+

Discovery

`, + s.issuerURL.String()+"/.well-known/openid-configuration") + if err != nil { + s.logger.Error("failed to write response", "err", err) + s.renderError(r, w, http.StatusInternalServerError, "Handling the / path error.") + return + } + }) // TODO(ericchiang): rate limit certain paths based on IP. handleWithCORS("/token", s.handleToken)