mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-02-08 00:21:23 +01:00
add jwt token back to wsl connections (#1841)
Co-authored-by: Evan Simkowitz <esimkowitz@users.noreply.github.com>
This commit is contained in:
parent
3c7f4d2060
commit
bba94a62d0
@ -140,7 +140,7 @@ func setBgRun(cmd *cobra.Command, args []string) (rtnErr error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create URL-safe path
|
// Create URL-safe path
|
||||||
escapedPath := strings.ReplaceAll(absPath, "\\", "\\\\")
|
escapedPath := filepath.ToSlash(absPath)
|
||||||
escapedPath = strings.ReplaceAll(escapedPath, "'", "\\'")
|
escapedPath = strings.ReplaceAll(escapedPath, "'", "\\'")
|
||||||
bgStyle = fmt.Sprintf("url('%s')", escapedPath)
|
bgStyle = fmt.Sprintf("url('%s')", escapedPath)
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ function processBackgroundUrls(cssText: string): string {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// allow absolute paths
|
// allow absolute paths
|
||||||
if (originalUrl.startsWith("/") || originalUrl.startsWith("~/")) {
|
if (originalUrl.startsWith("/") || originalUrl.startsWith("~/") || /^[a-zA-Z]:(\/|\\)/.test(originalUrl)) {
|
||||||
const newUrl = encodeFileURL(originalUrl);
|
const newUrl = encodeFileURL(originalUrl);
|
||||||
node.value = newUrl;
|
node.value = newUrl;
|
||||||
return;
|
return;
|
||||||
|
@ -23,6 +23,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var windowsDriveRegex = regexp.MustCompile(`^[a-zA-Z]:`)
|
var windowsDriveRegex = regexp.MustCompile(`^[a-zA-Z]:`)
|
||||||
|
var wslConnRegex = regexp.MustCompile(`^wsl://[^/]+`)
|
||||||
|
|
||||||
type Connection struct {
|
type Connection struct {
|
||||||
Scheme string
|
Scheme string
|
||||||
@ -117,12 +118,17 @@ func ParseURI(uri string) (*Connection, error) {
|
|||||||
remotePath = rest
|
remotePath = rest
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
split = strings.SplitN(rest, "/", 2)
|
if strings.HasPrefix(rest, "wsl://") {
|
||||||
host = split[0]
|
host = wslConnRegex.FindString(rest)
|
||||||
if len(split) > 1 {
|
remotePath = strings.TrimPrefix(rest, host)
|
||||||
remotePath = split[1]
|
|
||||||
} else {
|
} else {
|
||||||
remotePath = "/"
|
split = strings.SplitN(rest, "/", 2)
|
||||||
|
host = split[0]
|
||||||
|
if len(split) > 1 {
|
||||||
|
remotePath = split[1]
|
||||||
|
} else {
|
||||||
|
remotePath = "/"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,6 +262,10 @@ func StartWslShellProc(ctx context.Context, termSize waveobj.TermSize, cmdStr st
|
|||||||
conn.Debugf(ctx, "packed swaptoken %s\n", packedToken)
|
conn.Debugf(ctx, "packed swaptoken %s\n", packedToken)
|
||||||
cmdCombined = fmt.Sprintf(`%s=%s %s`, wavebase.WaveSwapTokenVarName, packedToken, cmdCombined)
|
cmdCombined = fmt.Sprintf(`%s=%s %s`, wavebase.WaveSwapTokenVarName, packedToken, cmdCombined)
|
||||||
}
|
}
|
||||||
|
jwtToken := cmdOpts.SwapToken.Env[wavebase.WaveJwtTokenVarName]
|
||||||
|
if jwtToken != "" {
|
||||||
|
cmdCombined = fmt.Sprintf(`%s=%s %s`, wavebase.WaveJwtTokenVarName, jwtToken, cmdCombined)
|
||||||
|
}
|
||||||
log.Printf("full combined command: %s", cmdCombined)
|
log.Printf("full combined command: %s", cmdCombined)
|
||||||
ecmd := exec.Command("wsl.exe", "~", "-d", client.Name(), "--", "sh", "-c", cmdCombined)
|
ecmd := exec.Command("wsl.exe", "~", "-d", client.Name(), "--", "sh", "-c", cmdCombined)
|
||||||
if termSize.Rows == 0 || termSize.Cols == 0 {
|
if termSize.Rows == 0 || termSize.Cols == 0 {
|
||||||
|
@ -20,7 +20,6 @@ type TokenSwapEntry struct {
|
|||||||
Token string `json:"token"`
|
Token string `json:"token"`
|
||||||
SockName string `json:"sockname,omitempty"`
|
SockName string `json:"sockname,omitempty"`
|
||||||
RpcContext *wshrpc.RpcContext `json:"rpccontext,omitempty"`
|
RpcContext *wshrpc.RpcContext `json:"rpccontext,omitempty"`
|
||||||
JwtToken string `json:"jwttoken,omitempty"`
|
|
||||||
Env map[string]string `json:"env,omitempty"`
|
Env map[string]string `json:"env,omitempty"`
|
||||||
ScriptText string `json:"scripttext,omitempty"`
|
ScriptText string `json:"scripttext,omitempty"`
|
||||||
Exp time.Time `json:"-"`
|
Exp time.Time `json:"-"`
|
||||||
|
@ -28,6 +28,7 @@ import (
|
|||||||
"github.com/wavetermdev/waveterm/pkg/remote/fileshare"
|
"github.com/wavetermdev/waveterm/pkg/remote/fileshare"
|
||||||
"github.com/wavetermdev/waveterm/pkg/telemetry"
|
"github.com/wavetermdev/waveterm/pkg/telemetry"
|
||||||
"github.com/wavetermdev/waveterm/pkg/util/envutil"
|
"github.com/wavetermdev/waveterm/pkg/util/envutil"
|
||||||
|
"github.com/wavetermdev/waveterm/pkg/util/shellutil"
|
||||||
"github.com/wavetermdev/waveterm/pkg/util/utilfn"
|
"github.com/wavetermdev/waveterm/pkg/util/utilfn"
|
||||||
"github.com/wavetermdev/waveterm/pkg/util/wavefileutil"
|
"github.com/wavetermdev/waveterm/pkg/util/wavefileutil"
|
||||||
"github.com/wavetermdev/waveterm/pkg/waveai"
|
"github.com/wavetermdev/waveterm/pkg/waveai"
|
||||||
@ -51,6 +52,19 @@ func (*WshServer) WshServerImpl() {}
|
|||||||
|
|
||||||
var WshServerImpl = WshServer{}
|
var WshServerImpl = WshServer{}
|
||||||
|
|
||||||
|
// TODO remove this after implementing in multiproxy, just for wsl
|
||||||
|
func (ws *WshServer) AuthenticateTokenCommand(ctx context.Context, data wshrpc.CommandAuthenticateTokenData) (wshrpc.CommandAuthenticateRtnData, error) {
|
||||||
|
entry := shellutil.GetAndRemoveTokenSwapEntry(data.Token)
|
||||||
|
if entry == nil {
|
||||||
|
return wshrpc.CommandAuthenticateRtnData{}, fmt.Errorf("invalid token")
|
||||||
|
}
|
||||||
|
rtn := wshrpc.CommandAuthenticateRtnData{
|
||||||
|
Env: entry.Env,
|
||||||
|
InitScriptText: entry.ScriptText,
|
||||||
|
}
|
||||||
|
return rtn, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (ws *WshServer) TestCommand(ctx context.Context, data string) error {
|
func (ws *WshServer) TestCommand(ctx context.Context, data string) error {
|
||||||
defer func() {
|
defer func() {
|
||||||
panichandler.PanicHandler("TestCommand", recover())
|
panichandler.PanicHandler("TestCommand", recover())
|
||||||
|
Loading…
Reference in New Issue
Block a user