mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-31 07:35:24 +00:00
fix: trust devices by a server-issued token, not a client header (GHSA-6gr3-r7jx-wfmh)
This commit is contained in:
1 parent
ad3a18224f
commit
8a45d952fd
8 files changed
+130
-131
No files matched your search
@@ -135,6 +135,8 @@ type ElectronWindow = Window &
|
||||
|
||||
export { isElectron };
|
||||
|
||||
export const TRUST_TOKEN_KEY = "termixTrustToken";
|
||||
|
||||
function getLoggerForService(serviceName: string) {
|
||||
if (serviceName.includes("SSH") || serviceName.includes("ssh")) {
|
||||
return sshLogger;
|
||||
@@ -370,6 +372,19 @@ function createApiInstance(
|
||||
config.headers["Authorization"] = `Bearer ${jwt}`;
|
||||
}
|
||||
}
|
||||
// The desktop app has no cookies with the server, so it carries the
|
||||
// remember-this-device token itself, and only to login.
|
||||
const trustToken = localStorage.getItem(TRUST_TOKEN_KEY);
|
||||
const isLogin =
|
||||
config.url?.includes("/users/login") ||
|
||||
/\/users\/auth\/[^/]+\/verify$/.test(config.url ?? "");
|
||||
if (trustToken && isLogin) {
|
||||
if (config.headers.set) {
|
||||
config.headers.set("X-Termix-Trust-Token", trustToken);
|
||||
} else {
|
||||
config.headers["X-Termix-Trust-Token"] = trustToken;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
|
||||
Reference in new issue
Block a user