Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

server, executor: allow showing session_states without TLS #38529

Merged
merged 4 commits into from
Oct 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions executor/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -2023,10 +2023,8 @@ func (e *ShowExec) fetchShowSessionStates(ctx context.Context) error {
var token *sessionstates.SessionToken
// In testing, user may be nil.
if user := e.ctx.GetSessionVars().User; user != nil {
// The token may be leaked without secure transport, so we enforce secure transport (TLS or Unix Socket).
if !e.ctx.GetSessionVars().ConnectionInfo.IsSecureTransport() {
return sessionstates.ErrCannotMigrateSession.GenWithStackByArgs("the token must be queried with secure transport")
}
// The token may be leaked without secure transport, but the cloud can ensure security in some situations,
// so we don't enforce secure connections.
if token, err = sessionstates.CreateSessionToken(user.Username); err != nil {
return err
}
Expand Down
3 changes: 1 addition & 2 deletions server/conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1442,8 +1442,7 @@ func TestAuthTokenPlugin(t *testing.T) {
tk1 := testkit.NewTestKitWithSession(t, store, tc.Session)
tc.Session.GetSessionVars().ConnectionInfo = cc.connectInfo()
tk1.Session().Auth(&auth.UserIdentity{Username: "auth_session_token", Hostname: "localhost"}, nil, nil)
err = tk1.QueryToErr("show session_states")
require.ErrorContains(t, err, "secure transport")
tk1.MustQuery("show session_states")

// create a token with TLS
cc.tlsConn = &tls.Conn{}
Expand Down