mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
feature(password) password -> criton
This commit is contained in:
parent
36e8bbb5f6
commit
343716ce0e
6 changed files with 14 additions and 34 deletions
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
exit = require(DIR_SERVER + 'exit'),
|
||||
config = require(DIR_SERVER + 'config'),
|
||||
createPass = require(DIR_SERVER + 'password'),
|
||||
|
||||
options,
|
||||
argv = process.argv,
|
||||
|
|
@ -106,7 +105,9 @@
|
|||
}
|
||||
|
||||
function getPassword(password) {
|
||||
return createPass(password, config('algo'));
|
||||
var criton = require('criton');
|
||||
|
||||
return criton(password, config('algo'));
|
||||
}
|
||||
|
||||
function version() {
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@
|
|||
rest = require(DIR_SERVER + 'rest'),
|
||||
route = require(DIR_SERVER + 'route'),
|
||||
validate = require(DIR_SERVER + 'validate'),
|
||||
createPass = require(DIR_SERVER + 'password'),
|
||||
prefixer = require(DIR_SERVER + 'prefixer'),
|
||||
|
||||
join = require('join-io'),
|
||||
|
|
@ -25,6 +24,7 @@
|
|||
spero = require('spero'),
|
||||
remedy = require('remedy'),
|
||||
ishtar = require('ishtar'),
|
||||
criton = require('criton'),
|
||||
|
||||
root = function() {
|
||||
return config('root');
|
||||
|
|
@ -67,7 +67,7 @@
|
|||
break;
|
||||
case 'password':
|
||||
/* could be useful when used as middleware */
|
||||
value = createPass(value, config('algo'));
|
||||
value = criton(value, config('algo'));
|
||||
break;
|
||||
case 'prefix':
|
||||
prefix = prefixer(value);
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
(function() {
|
||||
'use strict';
|
||||
|
||||
var DIR = './',
|
||||
var DIR = './',
|
||||
|
||||
httpAuth = require('http-auth'),
|
||||
config = require(DIR + 'config'),
|
||||
cryptPassword = require(DIR + 'password');
|
||||
httpAuth = require('http-auth'),
|
||||
criton = require('criton'),
|
||||
config = require(DIR + 'config');
|
||||
|
||||
module.exports = function() {
|
||||
var auth = httpAuth.basic({
|
||||
|
|
@ -36,7 +36,7 @@
|
|||
algo = config('algo');
|
||||
|
||||
sameName = username === name;
|
||||
samePass = pass === cryptPassword(password, algo);
|
||||
samePass = pass === criton(password, algo);
|
||||
|
||||
callback(sameName && samePass);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
path = require('path'),
|
||||
|
||||
password = require(DIR_SERVER + 'password'),
|
||||
exit = require(DIR_SERVER + 'exit'),
|
||||
CloudFunc = require(DIR_LIB + 'cloudfunc'),
|
||||
|
||||
|
|
@ -18,6 +17,8 @@
|
|||
writejson = require('writejson'),
|
||||
tryCatch = require('try-catch'),
|
||||
exec = require('execon'),
|
||||
criton = require('criton'),
|
||||
|
||||
HOME = require('os-homedir')(),
|
||||
|
||||
apiURL = CloudFunc.apiURL,
|
||||
|
|
@ -187,7 +188,7 @@
|
|||
var algo = manage('algo');
|
||||
|
||||
if (json && json.password)
|
||||
json.password = password(json.password, algo);
|
||||
json.password = criton(json.password, algo);
|
||||
}
|
||||
|
||||
})();
|
||||
|
|
|
|||
|
|
@ -1,23 +0,0 @@
|
|||
(function() {
|
||||
'use strict';
|
||||
|
||||
var crypto = require('crypto');
|
||||
|
||||
module.exports = function(password, algo) {
|
||||
var result, sha;
|
||||
|
||||
if (!password)
|
||||
throw Error('password could not be empty!');
|
||||
|
||||
if (!algo)
|
||||
algo = 'sha512WithRSAEncryption';
|
||||
|
||||
sha = crypto.createHash(algo);
|
||||
|
||||
sha.update(password);
|
||||
result = sha.digest('hex');
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
})();
|
||||
|
|
@ -58,6 +58,7 @@
|
|||
"checkup": "~1.3.0",
|
||||
"console-io": "~2.6.0",
|
||||
"copymitter": "~1.8.0",
|
||||
"criton": "~1.0.0",
|
||||
"dword": "~3.0.3",
|
||||
"edward": "~3.0.0",
|
||||
"execon": "~1.2.0",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue