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

Handle root path better (than nothing) #3747

Merged
merged 1 commit into from
Oct 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Handle root path better (than nothing)
Signed-off-by: maksim.nabokikh <max.nabokih@gmail,com>
Signed-off-by: maksim.nabokikh <max.nabokih@gmail.com>
  • Loading branch information
maksim.nabokikh authored and nabokihms committed Sep 13, 2024
commit 84bb0a9e21f1ea91cbc604ec6aec2e1d6f356c55
14 changes: 14 additions & 0 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,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, `<!DOCTYPE html>
<title>Dex</title>
<h1>Dex IdP</h1>
<h3>A Federated OpenID Connect Provider</h3>
<p><a href=%q>Discovery</a></p>`,
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)
Expand Down