Skip to content

Commit

Permalink
Handle root path better (than nothing)
Browse files Browse the repository at this point in the history
Signed-off-by: maksim.nabokikh <max.nabokih@gmail,com>
  • Loading branch information
maksim.nabokikh committed Sep 13, 2024
1 parent 20f240c commit 46244c5
Showing 1 changed file with 14 additions and 0 deletions.
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

0 comments on commit 46244c5

Please sign in to comment.