Skip to content

Commit

Permalink
block some unauthenticated routes in kurl-proxy (#4108)
Browse files Browse the repository at this point in the history
* block some unauthenticated routes in kurl-proxy

* do not block troubleshoot routes
  • Loading branch information
laverya authored Nov 3, 2023
1 parent e048c7b commit 5c2bb44
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
8 changes: 8 additions & 0 deletions kurl_proxy/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,14 @@ func getHttpsServer(upstream, dexUpstream *url.URL, tlsSecretName string, secret
}()
})

// these paths should not be exposed outside the cluster
r.GET("/license/v1/license", func(c *gin.Context) {
c.AbortWithStatus(http.StatusForbidden)
})
r.POST("/api/v1/app/custom-metrics", func(c *gin.Context) {
c.AbortWithStatus(http.StatusForbidden)
})

if dexUpstream != nil {
r.Any("/dex/*path", gin.WrapH(httputil.NewSingleHostReverseProxy(dexUpstream)))
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/handlers/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,9 @@ func RegisterTokenAuthRoutes(handler *Handler, debugRouter *mux.Router, loggingR
}

func RegisterUnauthenticatedRoutes(handler *Handler, kotsStore store.Store, debugRouter *mux.Router, loggingRouter *mux.Router) {
// These routes are not authenticated
// if the route does not need to be accessed from outside the cluster, it should be blocked in kurl-proxy

debugRouter.HandleFunc("/healthz", handler.Healthz)
loggingRouter.HandleFunc("/api/v1/login", handler.Login)
loggingRouter.HandleFunc("/api/v1/login/info", handler.GetLoginInfo)
Expand Down

0 comments on commit 5c2bb44

Please sign in to comment.