Skip to content

Commit 502e3aa

Browse files
authored
Merge pull request #919 from planetscale/dbussink/use-caching-sha2-password
Switch shell / connect to use caching_sha2_password by default
2 parents 0733e5b + d68bc44 commit 502e3aa

File tree

12 files changed

+104
-25
lines changed

12 files changed

+104
-25
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.23.1 as build
1+
FROM golang:1.23.2 as build
22
WORKDIR /app
33
COPY . .
44

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ endif
1111
REPO=planetscale
1212
NAME=pscale
1313
BUILD_PKG=github.com/planetscale/cli/cmd/pscale
14-
GORELEASE_CROSS_VERSION ?= v1.23.1
14+
GORELEASE_CROSS_VERSION ?= v1.23.2
1515
SYFT_VERSION ?= 1.9.0
1616

1717
.PHONY: all

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ version: '2'
22

33
services:
44
app:
5-
image: golang:1.23.1
5+
image: golang:1.23.2
66
volumes:
77
- .:/work
88
working_dir: /work

docker/Dockerfile.goreleaser

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ARG GORELEASE_CROSS_VERSION=v1.23.1
1+
ARG GORELEASE_CROSS_VERSION=v1.23.2
22
FROM ghcr.io/goreleaser/goreleaser-cross:${GORELEASE_CROSS_VERSION}
33

44
RUN apt-get update && apt-get install -y openssh-client

go.mod

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/planetscale/cli
22

3-
go 1.23.1
3+
go 1.23.2
44

55
require (
66
github.com/99designs/keyring v1.2.2
@@ -23,9 +23,9 @@ require (
2323
github.com/mitchellh/go-homedir v1.1.0
2424
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c
2525
github.com/pkg/errors v0.9.1
26-
github.com/planetscale/planetscale-go v0.108.0
26+
github.com/planetscale/planetscale-go v0.110.0
2727
github.com/planetscale/psdb v0.0.0-20240109164348-6848e728f6e7
28-
github.com/planetscale/psdbproxy v0.0.0-20240927190836-61feaf3c8bdb
28+
github.com/planetscale/psdbproxy v0.0.0-20241009145102-7fdfa92ae3ca
2929
github.com/spf13/cobra v1.8.1
3030
github.com/spf13/pflag v1.0.5
3131
github.com/spf13/viper v1.19.0
@@ -39,6 +39,7 @@ require (
3939
golang.org/x/sys v0.26.0
4040
golang.org/x/text v0.19.0
4141
gopkg.in/yaml.v2 v2.4.0
42+
vitess.io/vitess v0.10.3-0.20240927074858-3e5371377b43
4243
)
4344

4445
require (
@@ -91,7 +92,6 @@ require (
9192
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
9293
gopkg.in/ini.v1 v1.67.0 // indirect
9394
gopkg.in/yaml.v3 v3.0.1 // indirect
94-
vitess.io/vitess v0.10.3-0.20240927074858-3e5371377b43 // indirect
9595
)
9696

9797
replace github.com/golang/glog => github.com/planetscale/noglog v0.2.1-0.20210421230640-bea75fcd2e8e

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,12 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
114114
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
115115
github.com/planetscale/noglog v0.2.1-0.20210421230640-bea75fcd2e8e h1:MZ8D+Z3m2vvqGZLvoQfpaGg/j1fNDr4j03s3PRz4rVY=
116116
github.com/planetscale/noglog v0.2.1-0.20210421230640-bea75fcd2e8e/go.mod h1:hwAsSPQdvPa3WcfKfzTXxtEq/HlqwLjQasfO6QbGo4Q=
117-
github.com/planetscale/planetscale-go v0.108.0 h1:KwLhKsntOO2yokjYxfBtUwHN9/n+c6PnYPbsibZ8jmE=
118-
github.com/planetscale/planetscale-go v0.108.0/go.mod h1:2s0/iqbBEBEL5k+3t0+eNztAU3bYxUynLQs4yLrKNDI=
117+
github.com/planetscale/planetscale-go v0.110.0 h1:iaS/4pbP/efBmLtzr+cH8gjhLy1OjAovOgSqL+Gbobk=
118+
github.com/planetscale/planetscale-go v0.110.0/go.mod h1:ldGffCLckkR8fjGDjDFs4WcjlDr8uqg2qRUZhRYBEMI=
119119
github.com/planetscale/psdb v0.0.0-20240109164348-6848e728f6e7 h1:dxdoFKWVDlV1gq8UQC8NWCofLjCEjEHw47gfeojgs28=
120120
github.com/planetscale/psdb v0.0.0-20240109164348-6848e728f6e7/go.mod h1:WZmi4gw3rOK+ryd1inGxgfKwoFV04O7xBCqzWzv0/0U=
121-
github.com/planetscale/psdbproxy v0.0.0-20240927190836-61feaf3c8bdb h1:eJqW2GfcbKOkUCNHBmHOIWrX4sIaYUJ9xljnlNYtVPQ=
122-
github.com/planetscale/psdbproxy v0.0.0-20240927190836-61feaf3c8bdb/go.mod h1:qxC4twwQwRjHb9lt2DB/Ny0CuhJs1rrxskPbBLDljgo=
121+
github.com/planetscale/psdbproxy v0.0.0-20241009145102-7fdfa92ae3ca h1:E5E1yyZ03FzA/6styZr5C2L3DdqhnkZsKSJy5q4JnuU=
122+
github.com/planetscale/psdbproxy v0.0.0-20241009145102-7fdfa92ae3ca/go.mod h1:qxC4twwQwRjHb9lt2DB/Ny0CuhJs1rrxskPbBLDljgo=
123123
github.com/planetscale/vitess-types v0.0.0-20231211191709-770e14433716 h1:FD6vnHCirVPeyn+E6Z0HyXoAqXzjfTcRpgss/63im6w=
124124
github.com/planetscale/vitess-types v0.0.0-20231211191709-770e14433716/go.mod h1:8KWsIjuUBs+xlbfn9wBCxicFZqV8BCPIFoqlOSs+60I=
125125
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 h1:GFCKgmp0tecUJ0sJuv4pzYCqS9+RGSn52M3FUwPs+uo=

internal/cmd/connect/connect.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import (
2121

2222
"github.com/mattn/go-shellwords"
2323
"github.com/spf13/cobra"
24+
25+
"vitess.io/vitess/go/mysql"
2426
)
2527

2628
func ConnectCmd(ch *cmdutil.Helper) *cobra.Command {
@@ -34,6 +36,7 @@ func ConnectCmd(ch *cmdutil.Helper) *cobra.Command {
3436
role string
3537
noRandom bool
3638
replica bool
39+
authMethod string
3740
}
3841

3942
cmd := &cobra.Command{
@@ -95,6 +98,18 @@ argument:
9598
role = cmdutil.ReaderRole
9699
}
97100

101+
authMethod := mysql.CachingSha2Password
102+
if flags.authMethod != "" {
103+
switch flags.authMethod {
104+
case "caching_sha2_password":
105+
authMethod = mysql.CachingSha2Password
106+
case "mysql_native_password":
107+
authMethod = mysql.MysqlNativePassword
108+
default:
109+
return fmt.Errorf("unsupported auth method: %s", flags.authMethod)
110+
}
111+
}
112+
98113
// check whether database and branch exist
99114
dbBranch, err := client.DatabaseBranches.Get(ctx, &planetscale.GetDatabaseBranchRequest{
100115
Organization: ch.Config.Organization,
@@ -156,7 +171,7 @@ argument:
156171

157172
errCh := make(chan error, 1)
158173
go func() {
159-
errCh <- proxy.Serve(l)
174+
errCh <- proxy.Serve(l, authMethod)
160175
}()
161176

162177
go func() {
@@ -215,6 +230,8 @@ argument:
215230
cmd.PersistentFlags().StringVar(&flags.role, "role",
216231
"", "Role defines the access level, allowed values are: reader, writer, readwriter, admin. Defaults to 'reader' for replica passwords, otherwise defaults to 'admin'.")
217232
cmd.Flags().BoolVar(&flags.replica, "replica", false, "When enabled, the password will route all reads to the branch's primary replicas and all read-only regions.")
233+
cmd.PersistentFlags().StringVar(&flags.authMethod, "mysql-auth-method",
234+
"", "MySQL auth method defines the authentication method returned for the MySQL protocol. Allowed values are: caching_sha2_password, mysql_native_password. Defaults to 'caching_sha2_password'.")
218235

219236
return cmd
220237
}

internal/cmd/database/dump.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import (
2121
_ "github.com/go-sql-driver/mysql"
2222

2323
"github.com/spf13/cobra"
24+
25+
"vitess.io/vitess/go/mysql"
2426
)
2527

2628
type dumpFlags struct {
@@ -173,7 +175,10 @@ func dump(ch *cmdutil.Helper, cmd *cobra.Command, flags *dumpFlags, args []strin
173175
defer l.Close()
174176

175177
go func() {
176-
if err := proxy.Serve(l); err != nil {
178+
// We have to use mysql.MysqlNativePassword here because we still end
179+
// up using https://github.com/xelabs/go-mysqlstack which is unmaintained
180+
// and doesn't support caching_sha2_password.
181+
if err := proxy.Serve(l, mysql.MysqlNativePassword); err != nil {
177182
ch.Printer.Println("proxy error: ", err)
178183
}
179184
}()

internal/cmd/database/restore.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import (
1515
ps "github.com/planetscale/planetscale-go/planetscale"
1616

1717
"github.com/spf13/cobra"
18+
19+
"vitess.io/vitess/go/mysql"
1820
)
1921

2022
type restoreFlags struct {
@@ -127,7 +129,7 @@ func restore(ch *cmdutil.Helper, cmd *cobra.Command, flags *restoreFlags, args [
127129
defer l.Close()
128130

129131
go func() {
130-
if err := proxy.Serve(l); err != nil {
132+
if err := proxy.Serve(l, mysql.MysqlNativePassword); err != nil {
131133
ch.Printer.Println("proxy error: ", err)
132134
}
133135
}()

internal/cmd/shell/shell.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ second argument:
6363
runForeground = false
6464
}
6565

66-
mysqlPath, err := cmdutil.MySQLClientPath()
66+
mysqlPath, authMethod, err := cmdutil.MySQLClientPath()
6767
if err != nil {
6868
return err
6969
}
@@ -210,7 +210,7 @@ second argument:
210210

211211
errCh := make(chan error, 1)
212212
go func() {
213-
errCh <- proxy.Serve(l)
213+
errCh <- proxy.Serve(l, authMethod)
214214
}()
215215

216216
go func() {

0 commit comments

Comments
 (0)