Skip to content
Closed
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
1 change: 1 addition & 0 deletions pkg/portforward/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type SessionMessage struct {
MessageType MessageType `json:"messageType"`
Data interface{} `json:"data"`
Timestamp time.Time `json:"timestamp"`
JWT string `json:"jwt"`
}

func (m *SessionMessage) UnmarshalJSON(b []byte) error {
Expand Down
15 changes: 7 additions & 8 deletions pkg/portforward/ws.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@ import (
"encoding/base64"
"encoding/json"
"fmt"
"github.com/google/uuid"
"github.com/gorilla/websocket"
cmap "github.com/orcaman/concurrent-map/v2"
log "github.com/sirupsen/logrus"
"io"
"net"
"net/http"
"os"
"strings"
"sync"
"time"

"github.com/google/uuid"
"github.com/gorilla/websocket"
cmap "github.com/orcaman/concurrent-map/v2"
log "github.com/sirupsen/logrus"
)

const DefaultWSAddress = "wss://app.komodor.com"
Expand Down Expand Up @@ -58,10 +59,7 @@ func (ws *WSConnectionWrapper) Run() error {
hdr := http.Header{}
url := fmt.Sprintf("%s/ws/client/%s", base, ws.agentId)

if os.Getenv("KOMOCLI_DEV") == "" {
c := http.Cookie{Name: "JWT_TOKEN", Value: ws.jwt}
hdr.Set("Cookie", c.String())
} else {
if os.Getenv("KOMOCLI_DEV") != "" {
url += "?authorization=" + ws.jwt
}

Expand Down Expand Up @@ -111,6 +109,7 @@ func (ws *WSConnectionWrapper) init() error {
// write initial msg
ws.initMsg.MessageId = uuid.New().String()
ws.initMsg.Timestamp = time.Now()
ws.initMsg.JWT = ws.jwt

return ws.sendWS(ws.initMsg, true)
}
Expand Down
Loading