Skip to content

Commit

Permalink
fix: enable request limiter on healthcheck route
Browse files Browse the repository at this point in the history
Healthchecks need protection too!
  • Loading branch information
jamestelfer committed Oct 4, 2024
1 parent 788592e commit b8dfa09
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func configureServerRoutes(ctx context.Context, cfg config.Config) (http.Handler
requestLimiter := maxRequestSize(requestLimitBytes)

authorizedRouteMiddleware := alice.New(requestLimiter, auditor, authorizer)
standardRouteMiddleware := alice.New(requestLimiter)

// setup token handler and dependencies
bk, err := buildkite.New(cfg.Buildkite)
Expand All @@ -64,8 +65,8 @@ func configureServerRoutes(ctx context.Context, cfg config.Config) (http.Handler
mux.Handle("POST /token", authorizedRouteMiddleware.Then(handlePostToken(tokenVendor)))
mux.Handle("POST /git-credentials", authorizedRouteMiddleware.Then(handlePostGitCredentials(tokenVendor)))

// healthchecks are not included in telemetry
muxWithoutTelemetry.Handle("GET /healthcheck", handleHealthCheck())
// healthchecks are not included in telemetry or authorization
muxWithoutTelemetry.Handle("GET /healthcheck", standardRouteMiddleware.Then(handleHealthCheck()))

return mux, nil
}
Expand Down

0 comments on commit b8dfa09

Please sign in to comment.