Make authentication process more reliable
This commit is contained in:
@@ -216,11 +216,13 @@ func (s socket) mixerKey(r *http.Request) []byte {
|
|||||||
r.UserAgent(), s.commonCfg.SharedKey+"+"+s.commonCfg.HostName)
|
r.UserAgent(), s.commonCfg.SharedKey+"+"+s.commonCfg.HostName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const keyTimeTruncater = 100
|
||||||
|
|
||||||
func (s socket) buildCipherKey(r *http.Request) [16]byte {
|
func (s socket) buildCipherKey(r *http.Request) [16]byte {
|
||||||
key := [16]byte{}
|
key := [16]byte{}
|
||||||
|
|
||||||
copy(key[:], hashCombineSocketKeys(
|
copy(key[:], hashCombineSocketKeys(
|
||||||
strconv.FormatInt(time.Now().Unix()/100, 10),
|
strconv.FormatInt(time.Now().Unix()/keyTimeTruncater, 10),
|
||||||
string(s.mixerKey(r))+"+"+s.commonCfg.SharedKey,
|
string(s.mixerKey(r))+"+"+s.commonCfg.SharedKey,
|
||||||
))
|
))
|
||||||
|
|
||||||
|
|||||||
19
ui/app.js
19
ui/app.js
@@ -67,6 +67,7 @@ const mainTemplate = `
|
|||||||
|
|
||||||
const socksInterface = "/sshwifty/socket";
|
const socksInterface = "/sshwifty/socket";
|
||||||
const socksVerificationInterface = socksInterface + "/verify";
|
const socksVerificationInterface = socksInterface + "/verify";
|
||||||
|
const socksKeyTimeTruncater = 100 * 1000;
|
||||||
|
|
||||||
function startApp(rootEl) {
|
function startApp(rootEl) {
|
||||||
const pageTitle = document.title;
|
const pageTitle = document.title;
|
||||||
@@ -74,7 +75,9 @@ function startApp(rootEl) {
|
|||||||
let uiControlColor = new ControlColor();
|
let uiControlColor = new ControlColor();
|
||||||
|
|
||||||
function getCurrentKeyMixer() {
|
function getCurrentKeyMixer() {
|
||||||
return Number(Math.trunc(new Date().getTime() / 100000)).toString();
|
return Number(
|
||||||
|
Math.trunc(new Date().getTime() / socksKeyTimeTruncater)
|
||||||
|
).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function buildSocketKey(privateKey) {
|
async function buildSocketKey(privateKey) {
|
||||||
@@ -299,14 +302,7 @@ function startApp(rootEl) {
|
|||||||
switch (result.result) {
|
switch (result.result) {
|
||||||
case 200:
|
case 200:
|
||||||
this.executeHomeApp(result, {
|
this.executeHomeApp(result, {
|
||||||
data: await buildSocketKey(atob(result.key) + "+"),
|
|
||||||
async fetch() {
|
async fetch() {
|
||||||
if (this.data) {
|
|
||||||
let dKey = this.data;
|
|
||||||
this.data = null;
|
|
||||||
return dKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
let result = await self.doAuth("");
|
let result = await self.doAuth("");
|
||||||
|
|
||||||
if (result.result !== 200) {
|
if (result.result !== 200) {
|
||||||
@@ -349,14 +345,7 @@ function startApp(rootEl) {
|
|||||||
switch (result.result) {
|
switch (result.result) {
|
||||||
case 200:
|
case 200:
|
||||||
this.executeHomeApp(result, {
|
this.executeHomeApp(result, {
|
||||||
data: await buildSocketKey(atob(result.key) + "+" + passphrase),
|
|
||||||
async fetch() {
|
async fetch() {
|
||||||
if (this.data) {
|
|
||||||
let dKey = this.data;
|
|
||||||
this.data = null;
|
|
||||||
return dKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
let result = await self.doAuth(passphrase);
|
let result = await self.doAuth(passphrase);
|
||||||
|
|
||||||
if (result.result !== 200) {
|
if (result.result !== 200) {
|
||||||
|
|||||||
@@ -640,6 +640,22 @@ export const consoleScreenKeys = [
|
|||||||
which: 81,
|
which: 81,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
"Ctrl+X",
|
||||||
|
{
|
||||||
|
altKey: false,
|
||||||
|
charCode: 0,
|
||||||
|
code: "KeyX",
|
||||||
|
ctrlKey: true,
|
||||||
|
key: "x",
|
||||||
|
keyCode: 88,
|
||||||
|
location: 0,
|
||||||
|
metaKey: false,
|
||||||
|
repeat: false,
|
||||||
|
shiftKey: false,
|
||||||
|
which: 88,
|
||||||
|
},
|
||||||
|
],
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
Reference in New Issue
Block a user