Skip to content

Commit

Permalink
Merge #58662
Browse files Browse the repository at this point in the history
58662: cli/demo: avoid login URL if insecure r=otan a=knz

Fixes #58661  

NB: insecure is deprecated anyway  #53404 

Co-authored-by: Raphael 'kena' Poss <[email protected]>
  • Loading branch information
craig[bot] and knz committed Jan 11, 2021
2 parents 93f85b6 + 434f654 commit 23c9843
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions pkg/cli/demo_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,11 +292,12 @@ func (c *transientCluster) start(
if err := runInitialSQL(ctx, c.s.Server, demoCtx.nodes < 3, demoUsername, demoPassword); err != nil {
return err
}
c.adminUser = security.MakeSQLUsernameFromPreNormalizedString(demoUsername)
c.adminPassword = demoPassword
if demoCtx.insecure {
c.adminUser = security.RootUserName()
c.adminPassword = "unused"
} else {
c.adminUser = security.MakeSQLUsernameFromPreNormalizedString(demoUsername)
c.adminPassword = demoPassword
}

// Prepare the URL for use by the SQL shell.
Expand Down Expand Up @@ -885,14 +886,18 @@ func (c *transientCluster) listDemoNodes(w io.Writer, justOne bool) {
// the demo.
fmt.Fprintf(w, "node %d:\n", nodeID)
}
// Print node ID and console URL. Embed the autologin feature inside the URL.
pwauth := url.Values{
"username": []string{c.adminUser.Normalized()},
"password": []string{c.adminPassword},
}
serverURL := s.Cfg.AdminURL()
serverURL.Path = server.DemoLoginPath
serverURL.RawQuery = pwauth.Encode()
if !demoCtx.insecure {
// Print node ID and console URL. Embed the autologin feature inside the URL.
// We avoid printing those when insecure, as the autologin path is not available
// in that case.
pwauth := url.Values{
"username": []string{c.adminUser.Normalized()},
"password": []string{c.adminPassword},
}
serverURL.Path = server.DemoLoginPath
serverURL.RawQuery = pwauth.Encode()
}
fmt.Fprintf(w, " (console) %s\n", serverURL)
// Print unix socket if defined.
if c.useSockets {
Expand Down

0 comments on commit 23c9843

Please sign in to comment.