fix: block vpn tailnet endpoint when --browser-only is set (#16647)

The work on CoderVPN required a new user-scoped `/tailnet` endpoint for
coordinating with multiple workspace agents, and receiving workspace
updates. Much like the `/coordinate` endpoint, this needs to respect the
`CODER_BROWSER_ONLY`/`--browser-only` deployment config value.
This commit is contained in:
Ethan
2025-02-21 12:21:20 +11:00
committed by GitHub
parent 44499315ed
commit d50e846747
+11
View File
@@ -906,6 +906,7 @@ func (api *API) workspaceAgentClientCoordinate(rw http.ResponseWriter, r *http.R
}
// This is used by Enterprise code to control the functionality of this route.
// Namely, disabling the route using `CODER_BROWSER_ONLY`.
override := api.WorkspaceClientCoordinateOverride.Load()
if override != nil {
overrideFunc := *override
@@ -1576,6 +1577,16 @@ func (api *API) workspaceAgentsExternalAuthListen(ctx context.Context, rw http.R
func (api *API) tailnetRPCConn(rw http.ResponseWriter, r *http.Request) {
ctx := r.Context()
// This is used by Enterprise code to control the functionality of this route.
// Namely, disabling the route using `CODER_BROWSER_ONLY`.
override := api.WorkspaceClientCoordinateOverride.Load()
if override != nil {
overrideFunc := *override
if overrideFunc != nil && overrideFunc(rw) {
return
}
}
version := "2.0"
qv := r.URL.Query().Get("version")
if qv != "" {