Skip to content

Commit

Permalink
Expose tunnel public addr to config.js (#10514)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcbattirola authored Feb 23, 2022
1 parent 4a439ac commit 7f3a215
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
18 changes: 15 additions & 3 deletions lib/web/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -894,10 +894,22 @@ func (h *Handler) getWebConfig(w http.ResponseWriter, r *http.Request, p httprou
PreferredLocalMFA: cap.GetPreferredLocalMFA(),
}

// get tunnel address to display on cloud instances
tunnelPublicAddr := ""
if h.ClusterFeatures.GetCloud() {
proxyConfig, err := h.cfg.ProxySettings.GetProxySettings(r.Context())
if err != nil {
h.log.WithError(err).Warn("Cannot retrieve ProxySettings, tunnel address won't be set in Web UI.")
} else {
tunnelPublicAddr = proxyConfig.SSH.TunnelPublicAddr
}
}

webCfg := ui.WebConfig{
Auth: authSettings,
CanJoinSessions: canJoinSessions,
IsCloud: h.ClusterFeatures.GetCloud(),
Auth: authSettings,
CanJoinSessions: canJoinSessions,
IsCloud: h.ClusterFeatures.GetCloud(),
TunnelPublicAddress: tunnelPublicAddr,
}

resource, err := h.cfg.ProxyClient.GetClusterName()
Expand Down
2 changes: 2 additions & 0 deletions lib/web/ui/webconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ type WebConfig struct {
ProxyClusterName string `json:"proxyCluster,omitempty"`
// IsCloud is a flag that determines if cloud features are enabled.
IsCloud bool `json:"isCloud,omitempty"`
// TunnelPublicAddress is the public ssh tunnel address
TunnelPublicAddress string `json:"tunnelPublicAddress,omitempty"`
}

// WebConfigAuthProvider describes auth. provider
Expand Down

0 comments on commit 7f3a215

Please sign in to comment.