mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
kube-auth-proxy: accept only target cluster hostname (#1466)
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> Co-authored-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
parent
6a815edecd
commit
0eeb53aa2b
@ -4,6 +4,7 @@ import { broadcastIpc } from "../common/ipc";
|
|||||||
import type { Cluster } from "./cluster"
|
import type { Cluster } from "./cluster"
|
||||||
import { bundledKubectl, Kubectl } from "./kubectl"
|
import { bundledKubectl, Kubectl } from "./kubectl"
|
||||||
import logger from "./logger"
|
import logger from "./logger"
|
||||||
|
import * as url from "url"
|
||||||
|
|
||||||
export interface KubeAuthProxyLog {
|
export interface KubeAuthProxyLog {
|
||||||
data: string;
|
data: string;
|
||||||
@ -26,17 +27,22 @@ export class KubeAuthProxy {
|
|||||||
this.kubectl = bundledKubectl
|
this.kubectl = bundledKubectl
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get acceptHosts() {
|
||||||
|
return url.parse(this.cluster.apiUrl).hostname;
|
||||||
|
}
|
||||||
|
|
||||||
public async run(): Promise<void> {
|
public async run(): Promise<void> {
|
||||||
if (this.proxyProcess) {
|
if (this.proxyProcess) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const proxyBin = await this.kubectl.getPath()
|
const proxyBin = await this.kubectl.getPath()
|
||||||
const args = [
|
const args = [
|
||||||
"proxy",
|
"proxy",
|
||||||
"-p", `${this.port}`,
|
"-p", `${this.port}`,
|
||||||
"--kubeconfig", `${this.cluster.kubeConfigPath}`,
|
"--kubeconfig", `${this.cluster.kubeConfigPath}`,
|
||||||
"--context", `${this.cluster.contextName}`,
|
"--context", `${this.cluster.contextName}`,
|
||||||
"--accept-hosts", ".*",
|
"--accept-hosts", this.acceptHosts,
|
||||||
"--reject-paths", "^[^/]"
|
"--reject-paths", "^[^/]"
|
||||||
]
|
]
|
||||||
if (process.env.DEBUG_PROXY === "true") {
|
if (process.env.DEBUG_PROXY === "true") {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user