Skip to content

Commit

Permalink
fixup! Make backend workspace requests directly rather than proxying
Browse files Browse the repository at this point in the history
  • Loading branch information
sleshchenko committed May 27, 2020
1 parent 08f3171 commit 0a18759
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/terminal/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,10 @@ func (p *Proxy) HandleProxy(user *auth.User, w http.ResponseWriter, r *http.Requ
http.NotFound(w, r)
return
}

if path != WorkspaceInitEndpoint && path != WorkspaceActivityEndpoint {
http.Error(w, "Unsupported path", http.StatusForbidden)
return
}

client, err := p.createDynamicClient(user.Token)
Expand Down Expand Up @@ -130,6 +132,7 @@ func (p *Proxy) HandleProxy(user *auth.User, w http.ResponseWriter, r *http.Requ
}
if terminalHost.Scheme != "https" {
http.Error(w, "Workspace is not served over https", http.StatusForbidden)
return
}

terminalHost.Path = path
Expand Down Expand Up @@ -157,13 +160,13 @@ func (p *Proxy) HandleProxyEnabled(w http.ResponseWriter, r *http.Request) {
return
}
w.WriteHeader(http.StatusNoContent)
return
}

func (p *Proxy) handleExecInit(host *url.URL, token string, r *http.Request, w http.ResponseWriter) {
body, err := ioutil.ReadAll(r.Body)
if err != nil {
http.Error(w, "Failed to read body of request: "+err.Error(), http.StatusInternalServerError)
return
}

wkspReq, err := http.NewRequest(http.MethodPost, host.String(), ioutil.NopCloser(bytes.NewReader(body)))
Expand Down

0 comments on commit 0a18759

Please sign in to comment.