mirror of
https://github.com/keeweb/keeweb.git
synced 2024-06-26 07:39:04 +02:00
fixed saved yubikeys
This commit is contained in:
parent
b4fe0af53a
commit
51bd80faf4
|
@ -17,19 +17,35 @@ const ChalRespCalculator = {
|
||||||
challenge = Buffer.from(challenge);
|
challenge = Buffer.from(challenge);
|
||||||
const hexChallenge = challenge.toString('hex');
|
const hexChallenge = challenge.toString('hex');
|
||||||
|
|
||||||
const key = `${params.vid}:${params.pid}:${params.serial}:${hexChallenge}`;
|
const deviceCacheKey = `${params.vid}:${params.pid}:${params.serial}`;
|
||||||
if (this.cache[key]) {
|
const respFromCache = this.cache[deviceCacheKey]?.[hexChallenge];
|
||||||
|
if (respFromCache) {
|
||||||
logger.debug('Found ChalResp in cache');
|
logger.debug('Found ChalResp in cache');
|
||||||
return resolve(Buffer.from(this.cache[key], 'hex'));
|
return resolve(Buffer.from(respFromCache, 'hex'));
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.debug('Calculating ChalResp using a YubiKey');
|
logger.debug('Calculating ChalResp using a YubiKey', params);
|
||||||
|
|
||||||
YubiKey.calculateChalResp(params, challenge, (err, response) => {
|
YubiKey.calculateChalResp(params, challenge, (err, response) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
if (err.noKey) {
|
||||||
|
logger.debug('No YubiKey');
|
||||||
|
// TODO
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (err.touchRequested) {
|
||||||
|
logger.debug('YubiKey touch requested');
|
||||||
|
// TODO
|
||||||
|
return;
|
||||||
|
}
|
||||||
return reject(err);
|
return reject(err);
|
||||||
}
|
}
|
||||||
this.cache[key] = response.toString('hex');
|
|
||||||
|
if (!this.cache[deviceCacheKey]) {
|
||||||
|
this.cache[deviceCacheKey] = {};
|
||||||
|
}
|
||||||
|
this.cache[deviceCacheKey][hexChallenge] = response.toString('hex');
|
||||||
|
|
||||||
logger.info('Calculated ChalResp', logger.ts(ts));
|
logger.info('Calculated ChalResp', logger.ts(ts));
|
||||||
resolve(response);
|
resolve(response);
|
||||||
});
|
});
|
||||||
|
|
|
@ -252,10 +252,9 @@ const YubiKey = {
|
||||||
const yubiKey = { vid, pid, serial };
|
const yubiKey = { vid, pid, serial };
|
||||||
this.ykChalResp.challengeResponse(yubiKey, challenge, slot, (err, response) => {
|
this.ykChalResp.challengeResponse(yubiKey, challenge, slot, (err, response) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
if (err.touchRequested) {
|
if (err.code === this.ykChalResp.YK_ENOKEY) {
|
||||||
return;
|
err.noKey = true;
|
||||||
}
|
}
|
||||||
// TODO: handle touch and missing YubiKeys
|
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
callback(null, response);
|
callback(null, response);
|
||||||
|
|
|
@ -252,7 +252,8 @@
|
||||||
|
|
||||||
&-yubikey {
|
&-yubikey {
|
||||||
display: none;
|
display: none;
|
||||||
&--present {
|
&--present,
|
||||||
|
&--active {
|
||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
&__text {
|
&__text {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user