Skip to content

Commit

Permalink
Merge pull request #1689 from gravitational/rjones/fix-proxy-url
Browse files Browse the repository at this point in the history
Update Signup URL
  • Loading branch information
russjones authored Feb 16, 2018
2 parents 5e75ac6 + 2cf7656 commit 03377b7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 21 deletions.
4 changes: 2 additions & 2 deletions lib/web/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -2024,8 +2024,8 @@ 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(hostPort string, token string) string {
return "https://" + hostPort + "/web/newuser/" + token
func CreateSignupLink(token string) string {
return "https://<proxyhost>/web/newuser/" + token
}

type responseData struct {
Expand Down
24 changes: 5 additions & 19 deletions tool/tctl/common/user_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ package common

import (
"fmt"
"net"
"strconv"
"strings"
"time"

Expand Down Expand Up @@ -115,23 +113,11 @@ func (u *UserCommand) Add(client auth.ClientI) error {
}

func (u *UserCommand) PrintSignupURL(client auth.ClientI, token string, ttl time.Duration) {
hostname := "your.teleport.proxy"

proxies, err := client.GetProxies()
if err == nil {
if len(proxies) == 0 {
fmt.Printf("\x1b[1mWARNING\x1b[0m: this Teleport cluster does not have any proxy servers online.\nYou need to start some to be able to login.\n\n")
} else {
hostname = proxies[0].GetHostname()
}
}
_, proxyPort, err := net.SplitHostPort(u.config.Proxy.WebAddr.Addr)
if err != nil {
proxyPort = strconv.Itoa(defaults.HTTPListenPort)
}
url := web.CreateSignupLink(net.JoinHostPort(hostname, proxyPort), token)
fmt.Printf("Signup token has been created and is valid for %v hours. Share this URL with the user:\n%v\n\nNOTE: make sure '%s' is accessible!\n",
int(ttl/time.Hour), url, hostname)
url := web.CreateSignupLink(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)
fmt.Printf("NOTE: Make sure <proxyhost> points at a Teleport proxy which users can access.\n")
}

// Update updates existing user
Expand Down

0 comments on commit 03377b7

Please sign in to comment.