mirror of
https://github.com/Luzifer/vault-otp-ui.git
synced 2024-11-08 16:20:06 +00:00
Support 8-digit tokens
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
769feae2ea
commit
57d3c47bb1
4 changed files with 126 additions and 68 deletions
|
@ -18,7 +18,7 @@ createOTPItem = (item) ->
|
|||
tpl = $('#tpl-otp-item').html()
|
||||
|
||||
otpItem = $(tpl)
|
||||
otpItem.find('.badge').text item.code.replace(/^(.{3})(.{3})$/, '$1 $2')
|
||||
otpItem.find('.badge').text item.code.replace(/^([0-9]{3})([0-9]{3})$/, '$1 $2').replace(/^([0-9]{2})([0-9]{3})([0-9]{3})$/, '$1 $2 $3')
|
||||
otpItem.find('.title').text item.name
|
||||
otpItem.find('i.fa').addClass "fa-#{item.icon}"
|
||||
|
||||
|
@ -134,7 +134,7 @@ updateCodes = (data) ->
|
|||
|
||||
clipboard = new Clipboard '.otp-item',
|
||||
text: (trigger) ->
|
||||
$(trigger).find('.badge').text().replace(' ', '')
|
||||
$(trigger).find('.badge').text().replace(/ /g, '')
|
||||
|
||||
clipboard.on 'success', (e) ->
|
||||
createAlert 'success', 'Success:', 'Code copied to clipboard', 1000
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Generated by CoffeeScript 1.12.4
|
||||
// Generated by CoffeeScript 2.3.1
|
||||
(function() {
|
||||
var clipboard, createAlert, createOTPItem, currentTimeout, delay, fetchCodes, fetchInProgress, filterChange, initializeApplication, iterationCurrent, iterationNext, preFetch, refreshTimerProgress, serverConnectionError, tick, timeLeft, updateCodes, updatePreFetch;
|
||||
|
||||
|
@ -16,27 +16,31 @@
|
|||
|
||||
iterationNext = 'next';
|
||||
|
||||
// document-ready function to start Javascript processing
|
||||
$(function() {
|
||||
if ($('body').hasClass('state-signedin')) {
|
||||
return initializeApplication();
|
||||
}
|
||||
});
|
||||
|
||||
// createOTPItem generates code entries from the JSON objects passed from the backend
|
||||
createOTPItem = function(item) {
|
||||
var otpItem, tpl;
|
||||
tpl = $('#tpl-otp-item').html();
|
||||
otpItem = $(tpl);
|
||||
otpItem.find('.badge').text(item.code.replace(/^(.{3})(.{3})$/, '$1 $2'));
|
||||
otpItem.find('.badge').text(item.code.replace(/^([0-9]{3})([0-9]{3})$/, '$1 $2').replace(/^([0-9]{2})([0-9]{3})([0-9]{3})$/, '$1 $2 $3'));
|
||||
otpItem.find('.title').text(item.name);
|
||||
otpItem.find('i.fa').addClass("fa-" + item.icon);
|
||||
otpItem.find('i.fa').addClass(`fa-${item.icon}`);
|
||||
return otpItem.appendTo($('#keylist'));
|
||||
};
|
||||
|
||||
// createAlert adds a colored message at the top of the list
|
||||
// type = success / info / warning / danger
|
||||
createAlert = function(type, keyword, message, timeout) {
|
||||
var alrt, tpl;
|
||||
tpl = $('#tpl-message').html();
|
||||
alrt = $(tpl);
|
||||
alrt.find('.alert').addClass("alert-" + type);
|
||||
alrt.find('.alert').addClass(`alert-${type}`);
|
||||
alrt.find('.alert').find('.keyword').text(keyword);
|
||||
alrt.find('.alert').find('.message').text(message);
|
||||
alrt.appendTo($('#messagecontainer'));
|
||||
|
@ -47,10 +51,12 @@
|
|||
}
|
||||
};
|
||||
|
||||
// delay is a convenience wrapper to swap parameters of setTimeout
|
||||
delay = function(delayMSecs, fkt) {
|
||||
return window.setTimeout(fkt, delayMSecs);
|
||||
};
|
||||
|
||||
// fetchCodes contacts the backend to receive JSON containing current codes
|
||||
fetchCodes = function(iteration) {
|
||||
var data, successFunc;
|
||||
if (fetchInProgress) {
|
||||
|
@ -69,7 +75,7 @@
|
|||
return;
|
||||
}
|
||||
return $.ajax({
|
||||
url: "codes.json?it=" + iteration,
|
||||
url: `codes.json?it=${iteration}`,
|
||||
success: successFunc,
|
||||
dataType: 'json',
|
||||
error: function() {
|
||||
|
@ -90,6 +96,10 @@
|
|||
});
|
||||
};
|
||||
|
||||
// filterChange is called when changing the filter field and matches the
|
||||
// titles of all shown entries. Those not matching the given regular expression
|
||||
// will be hidden. The filterChange function is also called after a successful
|
||||
// refresh of the shown codes to re-apply
|
||||
filterChange = function() {
|
||||
var filter;
|
||||
filter = $('#filter').val().toLowerCase();
|
||||
|
@ -102,6 +112,8 @@
|
|||
});
|
||||
};
|
||||
|
||||
// initializeApplication initializes some basic events and starts the first
|
||||
// polling for codes
|
||||
initializeApplication = function() {
|
||||
$('#keylist').empty();
|
||||
$('#filter').bind('keyup', filterChange);
|
||||
|
@ -109,25 +121,34 @@
|
|||
return fetchCodes(iterationCurrent);
|
||||
};
|
||||
|
||||
// refreshTimerProgress updates the top progressbar to display the
|
||||
// remaining time until the one-time-passwords changes
|
||||
refreshTimerProgress = function() {
|
||||
var secondsLeft;
|
||||
secondsLeft = timeLeft();
|
||||
$('#timer').css('width', (secondsLeft / 30 * 100) + "%");
|
||||
$('#timer').css('width', `${secondsLeft / 30 * 100}%`);
|
||||
if (secondsLeft < 10 && preFetch === null && !serverConnectionError) {
|
||||
// Do a pre-fetch to provide a seamless experience
|
||||
return fetchCodes(iterationNext);
|
||||
}
|
||||
};
|
||||
|
||||
// tick is a convenience wrapper to swap parameters of setInterval
|
||||
tick = function(delay, fkt) {
|
||||
return window.setInterval(fkt, delay);
|
||||
};
|
||||
|
||||
// timeLeft calculates the remaining time until codes get invalid
|
||||
timeLeft = function() {
|
||||
var now;
|
||||
now = new Date().getTime();
|
||||
return (currentTimeout - now) / 1000;
|
||||
};
|
||||
|
||||
// updateCodes is being called when the backend delivered codes. The codes
|
||||
// are then rendered and the clipboard methods are re-bound. Afterwards the
|
||||
// next fetchCodes call is timed to that moment when the codes are getting
|
||||
// invalid
|
||||
updateCodes = function(data) {
|
||||
var i, len, ref, token;
|
||||
currentTimeout = new Date(data.next_wrap).getTime();
|
||||
|
@ -143,7 +164,7 @@
|
|||
}
|
||||
clipboard = new Clipboard('.otp-item', {
|
||||
text: function(trigger) {
|
||||
return $(trigger).find('.badge').text().replace(' ', '');
|
||||
return $(trigger).find('.badge').text().replace(/ /g, '');
|
||||
}
|
||||
});
|
||||
clipboard.on('success', function(e) {
|
||||
|
|
135
assets.go
135
assets.go
|
@ -206,61 +206,82 @@ func bindataIndexhtml() (*asset, error) {
|
|||
}
|
||||
|
||||
var _bindataApplicationjs = []byte(
|
||||
"\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x94\x57\x5b\x6f\xdb\x38\x16\x7e\xcf\xaf\x38\x4d\xb3\x95\xb4\x51\x14\xa7" +
|
||||
"\x97\x97\xa4\xde\xa2\xf0\x6e\x17\x05\xda\x6d\xb0\xc9\xdb\x60\x66\x40\x4b\x47\x36\x1b\x9a\x14\xa8\xa3\x38\x9e\x22" +
|
||||
"\xff\x7d\x70\xa8\x1b\x25\xcb\x49\xfb\x92\x98\xd4\xb9\x7c\xfc\x78\x6e\x3c\x3f\x87\xff\xa2\x46\x2b\x08\x33\x58\xee" +
|
||||
"\x60\x61\xf2\x1c\xf1\x26\xb5\xb2\x20\xb8\x48\x2e\x5e\x27\x6f\x8f\xc2\xbc\xd2\x29\x49\xa3\xc3\x08\x7e\x1c\x01\xdc" +
|
||||
"\x0b\x0b\xa9\x92\xc5\xd2\x08\x9b\xc5\x90\x5a\x14\x84\x1f\x15\x5a\x6a\x17\xdf\x6e\xaf\x3f\x13\x6e\x62\x48\x2b\x6b" +
|
||||
"\x51\xd3\xad\xdc\xa0\xa9\x28\x86\x0c\x95\xd8\xc5\x90\x23\xa5\xeb\x85\xc9\xb0\x6c\x7e\x7f\xd6\xd7\xd6\xac\x2c\x96" +
|
||||
"\xbc\x21\x15\xa1\x5d\xac\x85\x5e\x61\x0c\x52\x4b\x92\x42\xc9\xbf\xf0\x63\x51\x28\x99\x0a\x06\x12\x83\x24\xc6\x2c" +
|
||||
"\x8d\x5e\xd4\x1e\xbc\x9d\xff\xe1\x03\xc5\x50\x58\xfc\xc4\x96\x63\xb0\x98\x5b\x2c\xd7\x8c\xc1\xf6\x5e\x4a\xb4\xf7" +
|
||||
"\x68\x17\x46\x6b\x74\x67\xfb\x8f\xb5\xc6\xc6\x40\x32\xbd\xe3\xbf\x1b\xfc\x82\x39\xc5\x50\x15\x99\x20\x6c\xa0\xd6" +
|
||||
"\x8b\xeb\xc6\xf2\xd5\xd1\x11\x8c\x0e\x08\x73\x98\xd5\xdb\x2d\x3d\x30\x07\x5d\x29\xe5\x36\x5b\x48\xfe\xde\xe8\xf4" +
|
||||
"\x30\x87\x5c\xa8\x12\xdd\xb7\x49\x88\x03\x89\x31\x0b\x30\x87\xa0\x41\x14\x0c\x05\x98\x14\xfe\xaa\xf1\xa1\xf9\x74" +
|
||||
"\x32\xbe\x56\x00\x99\x43\x78\x12\x06\x4b\x93\xed\x82\x28\x59\x8b\x72\xa1\x44\x59\x86\x41\x49\x82\xf0\xac\x94\x2b" +
|
||||
"\x8d\x99\xd4\x41\xd4\xca\x03\x58\xa4\xca\xea\xe9\x4b\x0a\xa3\x2b\x27\xf5\x78\x04\xf0\x18\xd5\xb4\xf8\xd1\xc1\x27" +
|
||||
"\x69\x11\x48\xc2\x4d\x6b\x95\xc3\xcb\x50\x51\x07\x10\x15\xaa\xb6\x42\x85\x82\x39\x9c\x84\xc1\x4b\x2a\xd4\x99\xa1" +
|
||||
"\xe2\x8c\x75\x18\x26\x6d\x54\xeb\xaa\x51\x73\x82\x54\xa8\xe1\x6e\x92\x4b\x9d\x85\x41\xb2\x14\xd9\x0a\x83\x28\x21" +
|
||||
"\x7c\x20\xe7\x38\x49\x4d\x86\x89\xc5\x42\x89\x14\xc3\xf3\x3f\xc2\xe4\xc7\x9b\xc7\xa8\xfe\x7b\x72\x1e\x43\x70\x72" +
|
||||
"\x01\x27\xaf\x83\x68\xda\x1c\x49\x52\x43\x73\x5a\x6c\x70\x52\x56\x26\xb9\x08\xa2\x44\x64\x59\x4d\xec\x71\x2e\xce" +
|
||||
"\x8e\xe1\x14\x9c\x96\x4c\x8d\x6e\xb4\x1a\x56\x5b\x65\x51\x14\xa8\xb3\x5b\xc3\x77\xf3\xf2\x0e\x77\x4a\x96\xd4\xa0" +
|
||||
"\x79\xf4\x68\x75\x19\xe8\x93\x4a\xbb\x02\x63\xb8\xc3\xdd\xd6\x70\x9e\x6e\xb0\x2c\x05\xa7\x14\xd5\xc1\xea\xf3\x2d" +
|
||||
"\x14\x27\xef\x01\xb2\x1b\xc5\x11\xd7\xac\x32\x22\x9a\xb7\x5a\x5a\x04\xa3\x19\x1c\xd6\xed\xb8\xf3\x32\xb0\x27\x54" +
|
||||
"\x9a\x65\x03\xbc\xa5\xb6\x59\x3e\xaf\xd7\xc3\x75\x7a\xcd\xd2\xd7\x1b\x10\xda\x7c\x4f\x8d\x26\x21\x35\xda\xee\x9e" +
|
||||
"\x39\x1b\x1a\xaa\xe0\x5f\x30\xdb\x0b\x7a\x57\xcb\x5a\x89\x18\xf6\xb2\xc9\x13\x75\x5e\x2d\x6e\xcc\x3d\xb6\xf4\xd5" +
|
||||
"\x39\xd1\xe5\x87\xbb\x47\x67\xd1\xbf\x41\xb7\xf1\xf5\x06\x53\x2e\x8b\x77\xdd\x8d\x35\x56\xb7\x52\x67\x66\x9b\x94" +
|
||||
"\xd8\x96\x9f\x30\xbf\x6b\x6b\xac\x53\xf2\x42\xa4\xaf\xb8\xa3\xb4\xab\xcb\x83\x1f\x0b\x99\x20\x11\x43\x59\xa5\x29" +
|
||||
"\x96\xe5\xa7\x4a\xa7\x3d\x1d\xa3\x6a\x35\xa6\xa4\x3f\xcf\x54\x61\x23\x5b\x61\x6f\xaa\x73\x0d\xf3\xf9\x7c\xaf\x90" +
|
||||
"\xf5\x96\x3d\x1c\x30\xf7\xcb\x71\xe3\x0c\x50\x95\xf8\xa4\x74\x5f\xaf\x7b\x74\xcf\x23\x80\x57\xaf\xfa\x82\xfd\x62" +
|
||||
"\x5e\x97\xec\x1e\x16\x93\x04\xf3\x4e\xa2\xbd\xd3\xbd\x12\xbf\x07\x2b\x64\xcd\x2e\x06\xf6\x79\x6b\xee\xf6\x24\x11" +
|
||||
"\xdf\xc5\x43\xd8\xba\xab\xac\xba\x84\x63\xae\x53\x65\xf2\xbd\x34\xfa\x83\xa4\x79\x53\x39\x6a\xd4\xf1\xd0\xd3\xa5" +
|
||||
"\xef\x32\xf6\x30\xdf\xee\x0a\xbc\x84\x80\x6d\x04\xed\x3e\x72\x5f\xb9\x9c\x0e\xe0\x83\xfd\xa9\x15\xf0\x6a\x4f\x18" +
|
||||
"\x64\xdc\xb3\x6d\x10\x43\xf0\xcd\x14\x65\xc2\x3f\x6e\x5c\x13\x83\xd4\x54\x2a\x03\x6d\x08\x96\x08\x2e\xd7\x52\xc2" +
|
||||
"\x2c\x81\xaf\x62\xb7\x44\xd8\x99\x0a\x42\x63\x81\xd6\xd8\x74\xbd\x08\x84\x45\x30\x79\xae\xa4\xc6\x0f\xf0\x7f\x54" +
|
||||
"\x46\x64\x40\x06\xc8\xee\x40\xac\x84\xd4\x6c\x7d\x16\x5d\x8d\x53\xed\x50\xd3\xec\xa3\x0f\xe0\xb1\x63\x8b\x04\x55" +
|
||||
"\x25\x87\xd3\xa5\x77\xe6\xb7\xb3\x8b\x03\x6c\x8c\x53\x4f\x99\xba\xd5\x25\xd6\xe1\x0b\x3d\x38\x9d\x0f\x80\x77\xb3" +
|
||||
"\xd9\x41\x7b\xcf\xf2\xfb\x3c\xc3\xb7\x1d\x69\x60\xb1\x2c\x8c\xce\x30\x83\xad\xa4\x35\x08\xee\xcc\x84\x56\x0b\x55" +
|
||||
"\x5f\x72\xf2\x33\x44\xfe\x12\x95\x6d\xd8\xb6\xff\x1f\xfd\x9a\xe3\x0d\x72\x7e\xd5\xf1\x8b\x4d\x2d\x53\x5b\xab\x7f" +
|
||||
"\x37\x8d\xa7\x5e\x04\x51\x72\x2f\x54\x18\x25\x64\xbe\x98\x2d\xda\x85\x28\xbb\x0a\xda\x66\x4a\x18\x24\xde\x38\x80" +
|
||||
"\x22\x5d\xf7\x93\x8d\xcc\x1e\x62\x40\x2f\x6f\xeb\x11\x07\x55\x34\xd9\xbe\x47\x7e\x92\x8d\x20\xb6\xe6\xa0\x44\xae" +
|
||||
"\x4c\x0c\xab\x80\x07\x82\x4d\xae\x65\xe6\xd7\xf7\x61\x69\x1a\xc9\x96\x6b\xb3\xf5\x64\xf7\xc8\x9b\x1c\xa9\xa6\x58" +
|
||||
"\x1c\x0c\x05\x09\x6e\x0a\xda\xb5\x76\x07\x3c\x2e\xdd\x79\xef\x70\x57\x15\xc1\x70\xc8\x6e\xa4\x79\xf4\x0d\xdf\xcd" +
|
||||
"\x66\xd3\x13\xf3\x90\xf4\xbe\x9d\x84\x7b\xa5\xbb\x3f\xc3\x94\x9d\x43\x81\x50\x72\x07\xce\x4a\x9e\xba\x6b\x4f\xde" +
|
||||
"\x06\xc7\x5c\x33\x91\xfb\x47\xe3\x3d\x3e\x59\xca\x33\xea\x56\x66\xb4\x0e\x62\x08\x7d\xbd\x73\x78\x33\x83\x7f\xc2" +
|
||||
"\xc5\x6c\x16\xc1\x29\x1c\xff\xe3\xd8\x6b\xed\xbe\xdc\x7b\xb8\x98\x0d\x0a\x7e\x7b\xd5\xbc\xf9\x62\x32\x0f\xf6\xc6" +
|
||||
"\x81\x29\x4a\x78\xea\xde\xeb\xf2\xcc\xf3\x5e\x93\x7f\xba\xbf\x7f\xe6\x2c\xe6\x44\xe8\x1b\xbc\x47\x73\xcb\xcd\x21" +
|
||||
"\x6a\xb5\xd9\xd6\x18\xb4\xd9\x72\x63\xc2\x2d\xfc\x5b\x10\xc7\xf7\xaa\x1e\x1d\x46\x19\x15\x8e\x1e\x35\x67\xac\x18" +
|
||||
"\xc1\x39\xf3\x38\xeb\xdd\x7a\xbd\x78\x70\x1c\xee\x6f\x9e\x77\x19\x83\x42\xed\x82\x2a\x06\x32\x77\xd8\xb4\xbb\xbd" +
|
||||
"\x97\x53\x87\x8b\x2d\x24\xfc\x50\xf9\x73\x6b\x45\xb1\x87\x92\x2f\xaf\x7b\x5f\xf5\xd7\xd0\x6d\x25\x19\x96\x64\xcd" +
|
||||
"\xce\x7f\x7f\xd4\x01\xc3\x39\xf5\xc5\x88\xcc\x45\x8d\x9f\xac\x4f\xe4\x90\xc5\x1c\xe6\xae\x75\x26\x0e\x7c\x33\x77" +
|
||||
"\xe4\xc6\x42\x28\xf9\xbd\xe7\x8e\x07\x73\x16\x4c\x14\xea\x15\xad\xaf\x40\xc2\x7b\xde\xbd\x02\x79\x7a\xda\x23\x74" +
|
||||
"\xfa\xb5\xe4\x6f\xf2\xf7\x36\xf5\x07\x6f\xa2\xd0\xc9\x0c\x80\x0f\x9e\x92\xb8\x85\x45\xbb\xf6\xeb\x5e\xdc\x3b\xc1" +
|
||||
"\x07\xf2\xba\x0d\x59\xb9\x5a\xa1\x9d\x2c\x59\xed\xb7\xc9\x87\x51\xd4\x3d\x88\x02\xe0\x2e\x13\x4c\xd6\x2a\x9f\x76" +
|
||||
"\xa3\xc3\xa0\x99\x3a\x02\x6f\x1c\x46\xef\x8a\xfc\x4e\xd6\x8b\x06\x37\xcd\xd0\xc2\xbf\x39\x9e\x20\x35\x85\x44\xd7" +
|
||||
"\xa5\x3a\xf3\x41\xec\xc2\x6f\x34\x39\x01\x26\x4b\x55\xd9\xee\xaa\x27\x41\xb9\xd6\x77\x00\x52\x63\xe6\xb9\x1e\xbb" +
|
||||
"\x30\xc5\x6e\x00\x07\x72\x21\x15\x32\xaa\xd7\x3d\xaa\xd6\xbd\x5f\x5c\x5b\x68\xfd\x6b\xa1\x2e\x63\x75\x59\x9a\x4d" +
|
||||
"\xbe\x1b\x7e\xb2\xc8\xf6\x0e\x7d\x85\xe9\x61\xc2\x4f\xd9\xeb\x7e\x48\x9d\xcc\x5a\x6f\x88\xe5\xed\x5f\x71\xf1\x18" +
|
||||
"\x25\xa9\x50\x2a\xa4\xb5\xe4\x8e\xf1\x77\x00\x00\x00\xff\xff\xfb\xae\x62\x71\x5e\x12\x00\x00")
|
||||
"\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x9c\x58\x51\x93\xdb\xb6\xd5\x7d\xdf\x5f\x71\x33\xd1\x17\x52\x5f\x28\x4a" +
|
||||
"\xb6\x9b\x87\xda\x51\x33\x9e\x4d\xd3\x71\xc6\x89\x3d\xf5\xbe\x65\xd2\x2e\x44\x5c\x4a\xf0\x42\x00\x07\x00\xa5\x55" +
|
||||
"\x3d\xfa\xef\x9d\x0b\x10\x24\x28\x71\xed\xa4\x2f\xf6\x0a\x04\x2e\x0e\xef\x3d\x38\xf7\x80\xcb\x25\xfc\x03\x15\x1a" +
|
||||
"\xe6\x90\xc3\xe6\x04\xb7\xba\xae\x11\x3f\x54\x46\x34\x0e\x9e\x97\x2f\xca\x67\x37\x79\xdd\xaa\xca\x09\xad\xf2\x39" +
|
||||
"\x7c\xba\x01\x38\x30\x03\x95\x14\xcd\x46\x33\xc3\x0b\xa8\x0c\x32\x87\xaf\x25\x1a\x17\x7f\xbc\xbb\x7b\xff\xc6\xe1" +
|
||||
"\xbe\x80\xaa\x35\x06\x95\xbb\x13\x7b\xd4\xad\x2b\x80\xa3\x64\xa7\x02\x6a\x74\xd5\xee\x56\x73\xb4\xdd\xdf\x6f\xd4" +
|
||||
"\x7b\xa3\xb7\x06\x2d\x0d\x08\xe9\xd0\xdc\xee\x98\xda\x62\x01\x42\x09\x27\x98\x14\xff\xc1\xd7\x4d\x23\x45\xc5\x08" +
|
||||
"\x48\x01\xc2\x11\x64\xa1\xd5\x6d\xd8\x21\x19\xf9\x15\x1f\x5d\x01\x8d\xc1\x9f\x28\x72\x01\x06\x6b\x83\x76\x47\x18" +
|
||||
"\xcc\xb0\x8b\x45\x73\x40\x73\xab\x95\x42\xff\x6e\x7f\x37\x46\x9b\x02\x9c\xa8\x1e\xe8\xdf\x3d\xbe\xc5\xda\x15\xd0" +
|
||||
"\x36\x9c\x39\xec\xa0\x86\x1f\xef\xbb\xc8\xaf\x6e\x6e\xe0\xe2\x05\x61\x0d\xab\x30\x1c\xd3\x03\x6b\x50\xad\x94\x7e" +
|
||||
"\x30\x42\x4a\xc7\x2e\xde\x1e\xd6\x50\x33\x69\xd1\x3f\x9b\x84\x38\x9a\x71\x99\x05\x58\x43\xd6\x21\xca\xc6\x13\x28" +
|
||||
"\x29\xf4\x54\xe1\x63\xf7\x68\xb9\x04\xae\xab\x76\x8f\xca\x2d\x0c\x32\x7e\x82\x58\x66\x70\x1a\xac\x63\xc6\xc1\xcf" +
|
||||
"\xec\xc0\x6c\xa0\x42\x63\x74\x85\xd6\x0a\xb5\xbd\x01\x98\x5d\x52\x02\x40\xd4\x90\xcf\xf2\x6c\xa3\xf9\x29\x9b\x97" +
|
||||
"\x3b\x66\x6f\x25\xb3\x36\xcf\xac\x63\x0e\x17\x56\x6c\x15\x72\xa1\xb2\x79\x9c\x0f\x60\xd0\xb5\x46\x4d\x17\x38\x9f" +
|
||||
"\xbf\xf2\xb3\xce\x37\x00\xe7\x79\xc4\x3b\x22\x17\x6c\x3b\xda\x5a\xa8\x34\x47\x40\xe5\x8c\x40\x0b\xb5\xd1\x7b\x70" +
|
||||
"\x3b\x84\x9f\x3f\xbc\xfb\x15\xf4\xe6\x23\x56\xce\x42\xc3\xac\x45\x3e\x3c\xdc\xb0\xea\x01\x15\xa7\x52\x8d\x82\xae" +
|
||||
"\xfb\x2c\xe4\xc2\xe1\x3e\xa2\x25\xca\x6b\xd7\x04\x52\xbb\x46\x06\x74\xae\x91\xb0\x86\x59\x9e\x7d\xed\x1a\xb9\xd0" +
|
||||
"\xae\x59\xd0\x1a\x7a\x7d\xb7\x97\xf1\x15\xba\x65\x7e\xa2\x6b\xe4\x78\xb4\xac\x85\xe2\x79\x56\x6e\x18\xdf\x62\x36" +
|
||||
"\x2f\x1d\x3e\x3a\xbf\x71\x49\xef\x54\x1a\x6c\x24\xab\x30\x5f\xfe\x2b\xff\x6d\xb5\xf8\xeb\xef\x9f\x5e\x9c\xe7\xc3" +
|
||||
"\x5f\xb3\x65\x01\xd9\xec\x19\xcc\x9e\x67\xf3\xeb\xa9\xcf\xd3\xa9\x53\x8b\x60\xf6\x22\x9b\x4f\xc3\x71\xc2\xc9\x31" +
|
||||
"\x1c\xc5\xf6\x38\x39\x57\x94\x35\xcb\xe6\x25\xe3\x3c\x14\xfc\xbe\x66\x8b\xd9\x27\xbf\x46\x54\x5a\x9d\xef\xbb\x55" +
|
||||
"\x5d\xb5\xe3\x62\xd6\x34\xa8\xf8\x9d\x26\xce\x7c\xfd\x80\x27\x29\xac\xeb\xd0\x9c\xc7\xe5\xf6\xc2\x02\x8c\x73\x0b" +
|
||||
"\x0c\x2a\x2d\xb5\x41\x0e\x7b\xb4\x96\x6d\x11\x98\xf3\xd5\x74\xba\x01\x5d\xfb\x3f\x29\x50\x58\xee\x4e\x0d\xc2\x1a" +
|
||||
"\x6c\x5b\x11\x71\x61\x09\x42\xd5\x1a\x96\x70\x64\x46\x09\xb5\x85\x25\x70\x92\x18\xd3\x73\x20\xec\x94\x30\x80\x22" +
|
||||
"\x14\xf0\x80\xa7\xa3\x26\xa1\xeb\x36\x0d\xf2\xa0\x5b\x97\x92\x83\x49\x52\xbf\x27\x98\xd1\x2d\xbc\x20\x06\x2d\xb9" +
|
||||
"\x60\x05\x0d\xc5\x1a\x30\x42\x33\xca\xac\x1f\x59\xcc\x3e\x11\xac\x3e\xaf\x53\x4b\xba\x9f\x1d\xf0\x58\xc7\xee\xe7" +
|
||||
"\x97\xd7\x0d\x70\xfd\xba\xee\x67\xba\x6e\x54\xbd\xee\x79\xa5\x95\x63\x42\xa1\xe9\x49\x45\x92\xd0\xa5\x0a\xfe\x06" +
|
||||
"\xab\xab\x93\xef\x9b\x41\x9c\x51\xc0\x95\xa4\x24\x53\xfd\xae\x06\xf7\xfa\x80\x31\x7d\x41\x18\x7a\x91\xe8\x35\x8d" +
|
||||
"\x82\x82\x08\x64\x51\x07\x54\x02\x55\x85\x70\x34\x84\xd9\x78\x69\x3b\xb2\x06\x1a\x66\xd8\x1e\x1d\x1a\x4b\xc4\xb1" +
|
||||
"\x18\x15\xfc\x06\xba\x08\x09\x0d\xfc\xc0\x2f\x1f\xb0\xa2\xe6\xf4\xd0\x97\xbd\x83\x76\x14\x8a\xeb\x63\x39\x84\xc8" +
|
||||
"\xeb\x87\xd8\xe9\xfc\xa2\x31\xa9\x87\xd6\x07\x3e\x63\x24\x4e\x89\x20\x11\x40\x83\x15\x8a\x43\x27\x60\x5d\x5a\x89" +
|
||||
"\xb0\x9d\xb2\x7b\xb9\xb3\xb1\x77\x84\x50\x63\xd9\x0a\x92\x9f\xd2\x93\x33\xc7\x8a\x78\x14\x7e\x6a\x55\x35\x54\xe8" +
|
||||
"\xa2\x03\x5d\x56\x69\x48\xf1\x54\xb3\x72\xa6\xc5\x21\x54\xbf\x35\xac\xd7\xeb\xab\xe6\x34\x44\x4e\x70\xc0\x3a\x6d" +
|
||||
"\xb1\xdd\x66\x80\xd2\xe2\x67\x67\x0f\x3d\x78\x40\xf7\x65\x04\xf0\xcd\x37\x43\x13\xfe\x6a\x1d\xda\xf0\x00\x8b\x92" +
|
||||
"\x04\xeb\x7e\x46\xa4\xd9\x55\xdb\xbe\x82\x95\xd3\xca\x9e\x96\xd7\x79\xeb\x98\x32\x2b\xd9\x47\xf6\x98\xc7\xed\x5a" +
|
||||
"\x23\x5f\xc2\xbd\x2f\x66\xf9\xd1\x6a\xf5\x83\x70\x6b\xaf\x9c\x01\xf3\xf9\xbe\x18\xef\xf4\x32\xdd\xb2\x48\x30\xdf" +
|
||||
"\x9d\x1a\x7c\x09\x19\xc5\xc8\xe2\x38\x92\x57\x78\x39\x7d\xa6\x9e\xf4\x1c\x71\x42\x22\x87\x79\x16\x44\x32\x2b\x20" +
|
||||
"\x7b\xa7\x1b\x5b\xd2\x1f\x1f\xbc\x31\x81\x4a\xb7\x92\x83\xd2\x0e\x36\x18\xc9\x8c\xbc\x84\x5f\xd8\x69\x83\x70\xd2" +
|
||||
"\x2d\xe4\xda\x78\x72\x07\x27\x33\x07\x66\x10\x74\x5d\x4b\xa1\xf0\x07\xf8\x27\x4a\xcd\x3c\xe1\x9d\x39\x01\xdb\x32" +
|
||||
"\xa1\x28\xfa\x6a\xfe\xea\xf2\xf4\x3f\x65\x84\x06\xf6\x01\x9c\xfb\x6c\x39\xe6\x5a\x4b\x74\x7a\x99\xbc\xf3\x5f\x56" +
|
||||
"\xcf\x9e\xc8\xc6\xe5\x41\x96\x3a\x58\x90\xd2\x78\x7c\x79\x02\xa7\xdf\x03\xe0\xbb\xd5\xea\xc9\x78\x5f\xcc\xef\x97" +
|
||||
"\x33\x7c\xd7\x27\x0d\x0c\xda\x46\x2b\x8e\x1c\x8e\xc2\xed\x80\x91\x63\x72\x68\x14\x93\xa1\xc8\xe5\x1f\x49\xe4\x9f" +
|
||||
"\x4a\x65\xa4\x6d\xfc\xff\x7c\xa1\x60\x89\x3f\x27\xa1\xad\x98\x94\x84\x6e\x87\x0a\x2a\x1a\x25\xad\xa2\xaa\x87\x89" +
|
||||
"\x50\x0b\x94\x1c\x98\xe2\xb0\x67\xae\xda\xa1\xd7\xbb\xae\x45\x93\xcf\xf0\x0a\xcc\xa4\x04\xbb\xd3\x47\x15\x7d\x5c" +
|
||||
"\x09\x77\x3b\x6d\xd1\xd3\xcb\xaf\x8b\x51\xb7\xe2\x80\x0a\x0c\x6e\x5b\xc9\x0c\xe0\x63\x43\x39\x16\x5a\x85\x88\x47" +
|
||||
"\x21\x25\xd1\x71\x27\x38\x47\x45\x41\x70\x0c\xb8\x37\xb9\xd4\x22\xa4\xd5\x11\x3e\xab\x09\x2b\x8b\x67\xac\x6e\x65" +
|
||||
"\x08\xd8\xdd\x1e\xa2\xbd\x08\x18\xfd\xa1\x0d\x52\xbd\x60\x4d\x23\x4f\xa4\xc6\xe9\x2e\xeb\x6b\x6e\x90\x0c\x87\x39" +
|
||||
"\x21\xcf\x5d\x76\x82\x4b\x08\x3f\xb2\x79\x79\x60\x32\x9f\x97\x4e\xbf\xd5\x47\x34\xb7\xcc\xf6\xed\x2e\x6a\x48\x9e" +
|
||||
"\x95\x89\xd1\x44\x56\xed\x06\x2f\x2e\xf8\x63\x01\x98\x28\x5a\x30\xe5\x28\xe7\x93\xc6\xee\x62\x9f\xd2\xa7\x39\x0f" +
|
||||
"\x50\xe6\x5e\x40\xc7\xfa\x98\x80\xa0\x90\x3b\xc1\xd3\x66\x3c\x16\xed\x8b\xb9\x94\xb6\x64\xee\x14\xad\x26\xef\x01" +
|
||||
"\xc9\xa8\x05\xab\xf7\xd4\x27\xad\xa8\x00\x0f\xa8\x9c\xf5\xa4\xf2\x37\x15\xdb\x11\xce\x44\xf3\xd7\x68\x29\x89\x31" +
|
||||
"\xb5\x36\x7d\xbf\x9c\xde\x61\xa2\x54\x23\x4f\x5a\xe2\xbe\x71\xa7\x08\x7e\x54\xac\x8d\x4f\xea\x03\x9e\xda\x26\x1b" +
|
||||
"\xdf\x5b\xbb\xd9\x74\x9b\xcc\xbf\x5b\xad\xa6\x2f\xa1\xe3\xca\x0e\xdd\x3c\xbf\xea\x9c\xa3\x44\x4d\x85\xea\xda\xa2" +
|
||||
"\xed\xdd\x70\xd3\x3d\xd8\x30\xef\x79\xb8\xb0\x0d\xb9\x9a\xfe\xe4\x19\xdc\x77\xae\x82\xfc\x17\xb4\xca\x09\xe9\x17" +
|
||||
"\x6b\x85\x0b\x1a\x5a\xd0\x8d\x89\xfc\xa2\x0d\x87\xda\x67\x70\x72\xeb\x27\xb8\x6e\xc9\x11\x72\x4b\xd7\xe8\xf0\x9e" +
|
||||
"\xc9\x00\x09\x4e\x77\xc5\x4e\x13\x4b\x63\x94\xd7\x8a\x2e\x8e\x47\xc1\xdd\x2e\x2b\xe0\x7e\xf6\x29\x5d\xb9\x84\x17" +
|
||||
"\x2b\xf8\x7f\x78\xb6\x5a\x9d\xff\xef\x3e\x31\x9a\xe9\x9c\xef\xe1\xd9\x6a\xd4\xeb\x23\x97\x69\xf0\xab\x49\x09\x1c" +
|
||||
"\x58\xbe\x5c\xc2\x8f\x1a\x18\x2d\x5e\xf8\x9a\x50\xfe\x1a\xa3\x0f\x82\x23\xe9\x03\xb2\xbd\xa4\xd7\xc6\xc7\x06\x8d" +
|
||||
"\x37\x97\x63\x57\x3b\x55\x47\xba\x7d\x4f\x99\x55\xe2\xc7\xff\xe0\x55\xdf\x50\x03\x38\x30\x52\x28\x1f\xe1\xd2\xab" +
|
||||
"\x7e\xde\xa6\xc6\xd5\x89\x4f\x1d\x13\x2c\x96\x86\xa4\xb1\x6a\x65\xcf\xab\x49\xce\x04\x29\xdc\xa2\x03\xa1\x0e\x4c" +
|
||||
"\x0a\xee\x41\x75\x01\x9e\xa0\x86\xd2\xc7\x90\x0c\xa5\x8f\xe4\xaa\xf0\x08\x3f\x32\x47\x12\xb4\x0d\x2e\xfa\x42\xf4" +
|
||||
"\xf2\x8b\xaf\x2c\x0b\x5a\x38\x87\x25\xb1\x60\x35\x82\x9e\x78\x49\xca\xeb\x06\xbd\x6f\x4e\x1a\x54\x6a\xb5\x39\x4a" +
|
||||
"\x71\x40\xba\x4e\x06\x13\xe6\x9b\x45\x14\x8b\xe5\xd2\xbb\x15\xb7\xf3\xcd\x46\x71\x3f\x8f\xf4\x86\x22\x0c\x9f\x77" +
|
||||
"\xf6\xe8\x76\x9a\xae\xa6\x86\xf2\xb3\xd8\xe8\x56\xf1\x12\x5e\x53\x33\x39\x32\x3a\x3c\xfd\x89\x53\xf8\xe8\x46\xee" +
|
||||
"\x9f\x5a\x9e\xb0\x3e\x59\xa1\x79\xef\x98\x83\xbd\xde\x93\x51\xed\xb1\x86\xf4\x52\xf4\x2d\x3a\x17\xbe\xbe\x78\xb1" +
|
||||
"\x8c\xb9\x4e\xdf\x38\xe5\x01\x39\xd2\x24\xe5\xa2\x00\x89\xca\xeb\x50\x01\x4e\x3f\x60\x67\x50\xaf\xbe\x5f\xf5\xc5" +
|
||||
"\xa0\x08\x25\x81\xfe\x37\xf1\xf1\xaa\x34\x74\xe6\xfa\x34\x0c\xa7\xa7\x1f\x2a\x39\x5a\x67\xf4\x29\xfd\x92\x13\x4e" +
|
||||
"\x39\xc9\xf0\x5b\xcd\xb8\x3f\xea\x69\x13\xf9\x8c\xec\x1a\xac\x61\xed\xcd\x6e\xe9\xc1\x77\x37\x05\x52\xf7\x5c\xc0" +
|
||||
"\x1a\x56\xfe\xf5\x60\x4d\x13\x4b\x89\x6a\xeb\x76\xaf\x40\xc0\xf7\x34\xfa\x0a\xc4\xb7\xdf\x0e\x08\xfd\xfa\x30\xf3" +
|
||||
"\x37\xf1\x7b\x6c\x49\xa3\xaf\x40\xb9\x9f\x33\x02\x3e\xfa\xa0\x87\x47\xb8\x8d\xbf\xd3\x7e\x5c\x0c\x9b\xe0\xa3\x4b" +
|
||||
"\xfc\xa1\x33\x62\xbb\x45\x33\xd9\x4a\xe3\xb3\xc9\x4f\x41\xc9\x77\x1d\x58\x6e\x0b\xc8\xb2\xc9\x26\x9a\xe6\x5d\xab" +
|
||||
"\x3c\xeb\x4c\x4c\x96\x5c\xaa\x31\xa9\x51\x6a\x3e\x87\xa9\xd9\x87\xee\x9e\x41\x7f\x13\xa1\xa0\xd2\x8d\x08\xdc\xec" +
|
||||
"\xc3\x67\x85\x3f\x74\x17\x97\x1d\xc0\x72\x23\x5b\xd3\xd7\x7a\x12\x94\x77\xab\x4f\x40\xea\xc2\x7c\xc9\x16\xdf\xea" +
|
||||
"\xe6\x34\x82\x03\x35\x13\x12\x09\xd5\xf3\x01\x55\xdc\x3e\x6d\xc8\x11\xda\xf0\xcd\x21\x34\x9f\xd0\x4a\x56\x93\x5f" +
|
||||
"\x1f\xfe\x60\x63\x1e\x36\x4c\x17\x4c\xfb\xff\x20\x54\xe3\x3b\xec\x53\xc7\x36\xb9\x77\xd2\xf0\x9f\xd9\xe2\x3c\x2f" +
|
||||
"\x49\x5e\x72\xb7\x13\xe4\x32\xfe\x1b\x00\x00\xff\xff\x09\xb5\x11\xf3\xe4\x17\x00\x00")
|
||||
|
||||
func bindataApplicationjsBytes() ([]byte, error) {
|
||||
return bindataRead(
|
||||
|
@ -279,10 +300,10 @@ func bindataApplicationjs() (*asset, error) {
|
|||
|
||||
info := bindataFileInfo{
|
||||
name: "application.js",
|
||||
size: 4702,
|
||||
size: 6116,
|
||||
md5checksum: "",
|
||||
mode: os.FileMode(436),
|
||||
modTime: time.Unix(1521832974, 0),
|
||||
modTime: time.Unix(1535650919, 0),
|
||||
}
|
||||
|
||||
a := &asset{bytes: bytes, info: info}
|
||||
|
|
20
token.go
20
token.go
|
@ -10,6 +10,7 @@ import (
|
|||
|
||||
log "github.com/Sirupsen/logrus"
|
||||
"github.com/hashicorp/vault/api"
|
||||
"github.com/pquerna/otp"
|
||||
"github.com/pquerna/otp/totp"
|
||||
)
|
||||
|
||||
|
@ -18,6 +19,7 @@ type token struct {
|
|||
Icon string `json:"icon"`
|
||||
Name string `json:"name"`
|
||||
Secret string `json:"-"`
|
||||
Digits string `json:"digits"`
|
||||
}
|
||||
|
||||
func (t *token) GenerateCode(in time.Time) error {
|
||||
|
@ -27,8 +29,19 @@ func (t *token) GenerateCode(in time.Time) error {
|
|||
secret = secret + strings.Repeat("=", 8-n)
|
||||
}
|
||||
|
||||
opts := totp.ValidateOpts{
|
||||
Period: 30,
|
||||
Skew: 1,
|
||||
Digits: otp.DigitsSix,
|
||||
Algorithm: otp.AlgorithmSHA1,
|
||||
}
|
||||
|
||||
if t.Digits == "8" {
|
||||
opts.Digits = otp.DigitsEight
|
||||
}
|
||||
|
||||
var err error
|
||||
t.Code, err = totp.GenerateCode(strings.ToUpper(secret), in)
|
||||
t.Code, err = totp.GenerateCodeCustom(strings.ToUpper(secret), in, opts)
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -183,7 +196,6 @@ func fetchTokenFromKey(client *api.Client, k string, respChan chan *token, wg *s
|
|||
switch k {
|
||||
case cfg.Vault.SecretField:
|
||||
tok.Secret = v.(string)
|
||||
tok.GenerateCode(pointOfTime)
|
||||
case "code":
|
||||
tok.Code = v.(string)
|
||||
case "name":
|
||||
|
@ -192,9 +204,13 @@ func fetchTokenFromKey(client *api.Client, k string, respChan chan *token, wg *s
|
|||
tok.Name = v.(string)
|
||||
case "icon":
|
||||
tok.Icon = v.(string)
|
||||
case "digits":
|
||||
tok.Digits = v.(string)
|
||||
}
|
||||
}
|
||||
|
||||
tok.GenerateCode(pointOfTime)
|
||||
|
||||
if tok.Code == "" {
|
||||
// Nothing ended in us having a code, does not seem to be something for us
|
||||
return
|
||||
|
|
Loading…
Reference in a new issue