Updated signup URL to include default port.

This commit is contained in:
Russell Jones 2018-02-21 20:14:19 +00:00
parent c54bec2d26
commit c38dd8a8c8
2 changed files with 23 additions and 3 deletions

View file

@ -2024,8 +2024,28 @@ func ok() interface{} {
// CreateSignupLink generates and returns a URL which is given to a new
// user to complete registration with Teleport via Web UI
func CreateSignupLink(token string) string {
return "https://<proxyhost>/web/newuser/" + token
func CreateSignupLink(client auth.ClientI, token string) string {
proxyHost := "<proxyhost>:3080"
proxies, err := client.GetProxies()
if err != nil {
log.Errorf("Unable to retrieve proxy list: %v", err)
}
if len(proxies) > 0 {
proxyHost = proxies[0].GetPublicAddr()
if proxyHost == "" {
proxyHost = fmt.Sprintf("%v:%v", proxies[0].GetHostname(), defaults.HTTPListenPort)
log.Debugf("public_address not set for proxy, returning proxyHost: %q", proxyHost)
}
}
u := &url.URL{
Scheme: "https",
Host: proxyHost,
Path: "web/newuser/" + token,
}
return u.String()
}
type responseData struct {

View file

@ -113,7 +113,7 @@ func (u *UserCommand) Add(client auth.ClientI) error {
}
func (u *UserCommand) PrintSignupURL(client auth.ClientI, token string, ttl time.Duration) {
url := web.CreateSignupLink(token)
url := web.CreateSignupLink(client, token)
fmt.Printf("Signup token has been created and is valid for %v hours. Share this URL with the user:\n%v\n\n",
int(ttl/time.Hour), url)