Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix app access regression when the app is on a leaf cluster #47778

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions lib/web/app/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -617,11 +617,14 @@ const (
//
// The URL's are formed this way to help isolate the path params reserved for the app
// launchers route, where order and existence of previous params matter for this route.
func makeAppRedirectURL(r *http.Request, proxyPublicAddr, hostname string, req launcherURLParams) string {
func makeAppRedirectURL(r *http.Request, proxyPublicAddr, addr string, req launcherURLParams) string {
if req.requiresAppRedirect {
addr = req.publicAddr
}
u := url.URL{
Scheme: "https",
Host: proxyPublicAddr,
Path: fmt.Sprintf("/web/launch/%s", hostname),
Path: fmt.Sprintf("/web/launch/%s", addr),
}

// Presence of a stateToken means we are beginning an app auth exchange.
Expand All @@ -634,7 +637,7 @@ func makeAppRedirectURL(r *http.Request, proxyPublicAddr, hostname string, req l
v.Add("required-apps", req.requiredAppFQDNs)
u.RawQuery = v.Encode()

urlPath := []string{"web", "launch", hostname}
urlPath := []string{"web", "launch", addr}

// The order and existence of previous params matter.
//
Expand Down
6 changes: 1 addition & 5 deletions lib/web/app/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,8 @@ func (h *Handler) redirectToLauncher(w http.ResponseWriter, r *http.Request, p l
"https://goteleport.com/docs/application-access/guides/connecting-apps/#start-authproxy-service.")
return trace.BadParameter("public address of the proxy is not set")
}
host := p.publicAddr
if host == "" {
host = r.Host
}

addr, err := utils.ParseAddr(host)
addr, err := utils.ParseAddr(r.Host)
if err != nil {
return trace.Wrap(err)
}
Expand Down
Loading