Skip to content
Open
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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/k8shell-io/ssh-proxy
go 1.24.5

require (
github.com/k8shell-io/common v0.35.0
github.com/k8shell-io/common v0.36.0
github.com/nats-io/nats.go v1.47.0
github.com/rs/zerolog v1.34.0
golang.org/x/crypto v0.43.0
Expand Down
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,8 @@ github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/k8shell-io/common v0.34.3 h1:wTwCHjPSH4T8Mj4GIwXlekXVQwyt0jw5a7ZE4Vw5KtY=
github.com/k8shell-io/common v0.34.3/go.mod h1:40c5GkpS7Y0/aOFa37Lq8z/mLUn3k3GV/AHtFJFL28k=
github.com/k8shell-io/common v0.35.0 h1:9D7BIjYulE8TA27UjIEukBvYWJkF2V9+cFLqWWK0R1w=
github.com/k8shell-io/common v0.35.0/go.mod h1:E8dsb9ta4v3ne61AJgtRyTTbTkMMmKeCMAcXD+/9+cY=
github.com/k8shell-io/common v0.36.0 h1:fkMH1XfYRLzDxqhIq5/luHusWWPGnCGJUXSTEIhEDzI=
github.com/k8shell-io/common v0.36.0/go.mod h1:E8dsb9ta4v3ne61AJgtRyTTbTkMMmKeCMAcXD+/9+cY=
github.com/k8shell-io/crypto v0.41.1-ssh-proxy h1:8+q6Ofc2ky23Oc9iNyiq8aeiQBIP+y3+O6zzHqe1f48=
github.com/k8shell-io/crypto v0.41.1-ssh-proxy/go.mod h1:RVZeOJCpqtogniULztSXQESKJCfcI8WCxsS0FagMA8U=
github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo=
Expand Down
8 changes: 1 addition & 7 deletions internal/server/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -524,13 +524,7 @@ func (c *Connection) Handshake(writer io.Writer, writerOptions *workspace.InfoWr
c.log.Debug().Msgf("Connecting to k8shelld at %s:%d for user %s, version: %s",
status.ServerName, status.Port, c.user.Username, status.AppVersion)

userToken, err := c.GetUserToken()
if err != nil {
infoWriter.WriteSystemError("Failed to obtain access token.")
return nil, fmt.Errorf("failed to get user token for user %s: %w", c.user.Username, err)
}

handshake, err := k8shelld.Handshake(c.ctx, userToken)
handshake, err := k8shelld.Handshake(c.ctx)
if err != nil {
msg := grpcClientMessage(err)
if s, ok := grpcstatus.FromError(err); ok && s.Code() == grpccodes.Unavailable {
Expand Down
2 changes: 1 addition & 1 deletion internal/server/directstream.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (s *Server) handleDirectStreamLocal(_ *ssh.ServerConn, connInfo *Connection
return
}

if err := k8shelld.RunUnixSocket(connInfo.ctx, userToken, &workspace.ChannelAdapter{Channel: ch},
if err := k8shelld.RunUnixSocket(connInfo.ctx, &workspace.ChannelAdapter{Channel: ch},
streamLocal.streamLocalId, streamLocal.destPath, "UNIX_SOCKET_MODE_DIAL"); err != nil {
s.log.Error().Err(err).Msg("unix socket connect failed")
return
Expand Down
12 changes: 2 additions & 10 deletions internal/server/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,7 @@ func (s *Server) handleSessionRequests(requests <-chan *ssh.Request, connInfo *C
session.termWidth = width
session.termHeight = height

if userToken, err := connInfo.GetUserToken(); err != nil {
s.log.Error().Msgf("Failed to get user token for resize: %v", err)
} else if err := k8shelld.ResizeTerminal(connInfo.ctx, userToken, session.sessionId, width, height); err != nil {
if err := k8shelld.ResizeTerminal(connInfo.ctx, session.sessionId, width, height); err != nil {
s.log.Error().Msgf("Failed to resize terminal: %v", err)
}
} else {
Expand Down Expand Up @@ -560,13 +558,7 @@ func (s *Server) handleAgent(sshConn *ssh.ServerConn, connInfo *Connection) (ssh
s.log.Debug().Msgf("Starting agent forwarding for user %s, unix socket id: %s",
connInfo.userStr.Username(), connInfo.session.agentUnixID)

userToken, err := connInfo.GetUserToken()
if err != nil {
s.log.Error().Msgf("Failed to get user token for user %s: %v", connInfo.user.Username, err)
return
}

err = k8shelld.RunUnixSocket(connInfo.ctx, userToken, &workspace.ChannelAdapter{Channel: channel},
err := k8shelld.RunUnixSocket(connInfo.ctx, &workspace.ChannelAdapter{Channel: channel},
connInfo.session.agentUnixID, connInfo.session.sshAuthSock, "UNIX_SOCKET_MODE_LISTEN")
if err != nil {
if statusErr, ok := status.FromError(err); ok && statusErr.Code() == codes.Canceled {
Expand Down
6 changes: 3 additions & 3 deletions internal/workspace/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ import (
)

type K8shelldClient interface {
Handshake(ctx context.Context, userToken string) (*k8shelldv1.HandshakeResponse, error)
Handshake(ctx context.Context) (*k8shelldv1.HandshakeResponse, error)
RunShell(ctx context.Context, userToken string, asUser string, upstream k8shelldClient.BufferedReadWriter, sessionId string, envVars []string,
width, height uint32, usePty bool, lockId string, detachOnClose bool, showInitScriptsStatus bool, enableRecording bool,
notifyPtyName k8shelld.NotifyPtyNameFunc) error
ResizeTerminal(ctx context.Context, userToken string, sessionId string, width, height uint32) error
RunUnixSocket(ctx context.Context, userToken string, upstream k8shelldClient.BufferedReadWriter, unixSocketId, socketPath, mode string) error
ResizeTerminal(ctx context.Context, sessionId string, width, height uint32) error
RunUnixSocket(ctx context.Context, upstream k8shelldClient.BufferedReadWriter, unixSocketId, socketPath, mode string) error
RunPortForward(ctx context.Context, userToken string, upstream k8shelldClient.BufferedReadWriter, portForwardID, sourceIP string,
sourcePort uint32, destinationIP string, destinationPort uint32, enableRecording bool) error
RunExec(ctx context.Context, userToken string, asUser string, upstream k8shelldClient.BufferedReadWriter,
Expand Down
Loading