1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Switch to using base64 encoding of the auth tokens

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2021-11-09 11:44:29 -05:00
parent 076cf9e1c5
commit e92304b92e
2 changed files with 2 additions and 10 deletions

View File

@ -63,15 +63,7 @@ export class ShellRequestAuthenticator extends Singleton {
}
const authToken = clusterTokens.get(tabId);
const buf = Uint8Array.from(token.split(",").map(ar => {
const res = +ar;
if (isNaN(res)) {
throw new TypeError("Token must be a CSV list of digits");
}
return res;
}));
const buf = Uint8Array.from(Buffer.from(token, "base64"));
if (authToken instanceof Uint8Array && crypto.timingSafeEqual(authToken, buf)) {
// remove the token because it is a single use token

View File

@ -89,7 +89,7 @@ export class TerminalApi extends WebSocketApi {
pathname: "/api",
query: {
...this.query,
shellToken: authTokenArray.toString(),
shellToken: Buffer.from(authTokenArray).toString("base64"),
},
slashes: true,
});