forked from passbolt/passbolt_cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
passbolt-auth.js
49 lines (46 loc) · 1.63 KB
/
passbolt-auth.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/**
* Passbolt ~ Open source password manager for teams
* Copyright (c) Passbolt SA (https://www.passbolt.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Passbolt SA (https://www.passbolt.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.passbolt.com Passbolt(tm)
*/
const {Command} = require('commander');
const GpgAuthController = require('./app/controllers/gpgAuthController.js');
/**
* Passbolt GPG Authentication Command
*/
(async function() {
const program = new Command();
program
.usage('[options] [login|logout]', 'Authentication actions, login or logout')
.option('-u, --fingerprint <fingerprint>', 'The user key fingerprint to authenticate with')
.option('-p, --passphrase <passphrase>', 'The key passphrase')
.option('-v, --verbose', 'Display additional debug information')
.option('-f, --force', 'Force authentication even if not needed')
.parse(process.argv);
// Check what action was given or use login as default
let action = 'login';
if (program.args.length) {
action = program.args[0];
}
const gpgAuth = new GpgAuthController(program, process.argv);
switch (action) {
case 'logout':
await gpgAuth.logout();
console.log('logged out');
break;
case 'check':
await gpgAuth.check();
break;
case 'login':
default:
await gpgAuth.loginIfNeeded();
break;
}
})();