Skip to content

Commit

Permalink
v0.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
stripthis committed Sep 25, 2019
2 parents 5e3195b + aa20b4c commit adf5c88
Show file tree
Hide file tree
Showing 36 changed files with 1,712 additions and 859 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ npm-debug.log

# Config
app/config/config.json
app/config/*.key

# TMP files
/app/tmp/
Expand Down
28 changes: 17 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ This repository is a command line interface for passbolt API.
It allows a user to interact with the passbolt server without the user of web extension.
Currently works as a read only access only.

# Prerequisite
In order to use passbolt CLI you will need:
- Gnupg v2
- Nodejs LTS or more recent

# How to get started?

Copy the repository
Expand Down Expand Up @@ -66,8 +71,9 @@ You also need to make sure the server public key is in your GnuPG keyring.

If you do not know the domain public key or fingerprint you can get them like follow
```
$ passbolt keyring server-public-key --display-fingerprint
$ passbolt keyring server-public-key --display-armored
$ passbolt server-key --domain=https://www.passbolt.test > app/config/server.key
$ gpg --import app/config/server.key
$ passbolt server-key --fingerprint --domain=https://www.passbolt.test
```

## User config
Expand Down Expand Up @@ -145,14 +151,13 @@ Right now the basics, only authentication and read operations.
Commands:
auth Authentication actions, login or logout
get View the OpenPGP data block of a given resource
find Find one or more resources
keyring Synchronize public keys
users List all users
user List information for a given user
help [cmd] display help for [cmd]
auth Authentication actions, login or logout
get View the OpenPGP data block of a given resource
find Find one or more resources
server-key Fetch the server public key
users List all users
user View one user details
help [cmd] display help for [cmd]
Options:
Expand Down Expand Up @@ -193,6 +198,7 @@ ftp user ftp://192.168.1.1
...
```
Your can select the columns you want to display using the `--columns` arguments.
Non existing collumns will be ignored.

```
$ passbolt find --columns=name,uuid
Expand Down Expand Up @@ -235,7 +241,7 @@ $ passbolt get $(passbolt find | awk '/inkscape/ { print $NF }') | gpg -q --no-
-q and --no-tty
```
are optional and ensures that only the password is printed.
## Runnning the tests
## Running the tests

```
$ [sudo] npm install -g mocha
Expand Down
12 changes: 9 additions & 3 deletions app/controllers/appController.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
/**
* Authentication Controller
* Passbolt ~ Open source password manager for teams
* Copyright (c) Passbolt SA (https://www.passbolt.com)
*
* @copyright (c) 2019 Passbolt SA
* @licence AGPL-3.0 http://www.gnu.org/licenses/agpl-3.0.en.html
* 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 i18n = require('../models/i18n.js');
const GpgAuthController = require('./gpgAuthController.js');
Expand Down
38 changes: 9 additions & 29 deletions app/controllers/cliController.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
/**
* Command Line Interface Controller
* Passbolt ~ Open source password manager for teams
* Copyright (c) Passbolt SA (https://www.passbolt.com)
*
* @copyright (c) 2019 Passbolt SA
* @licence AGPL-3.0 http://www.gnu.org/licenses/agpl-3.0.en.html
* 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 Controller = require('./controller.js');
const prompt = require('prompt');
Expand All @@ -19,32 +25,6 @@ class CliController extends Controller {
this._prompt.delimiter = ': ';
}

/**
* Log a message in console
* @param msg
* @param priority
*/
log(msg, priority) {
if (priority === undefined || (priority === 'verbose' && this._verbose)) {
console.log(msg);
}
}

/**
* Handle an error
* @param error
*/
error(error) {
if (error instanceof Error) {
this.log(error.message);
} else if (typeof error === 'string') {
this.log(error);
} else {
this.log(error);
}
process.exit(1);
}

/**
* Capture data from command line
* @param schema
Expand Down
72 changes: 56 additions & 16 deletions app/controllers/controller.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
/**
* Controller
* Passbolt ~ Open source password manager for teams
* Copyright (c) Passbolt SA (https://www.passbolt.com)
*
* @copyright (c) 2019 Passbolt SA
* @licence AGPL-3.0 http://www.gnu.org/licenses/agpl-3.0.en.html
* 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 i18n = require('../models/i18n.js');
const Config = require('../models/config.js');
Expand All @@ -13,21 +19,10 @@ class Controller {
* @param program
*/
constructor(program) {
const config = Config.get();
this._request = require('request');
this._agentOptions = config.agentOptions;
this._verbose = (program !== undefined && program.verbose !== undefined && program.verbose);
}

/**
* Log a message in console
* @param msg
* @param priority
*/
log(msg, priority) {
if (priority === undefined || (priority === 'verbose' && this._verbose)) {
console.log(msg);
}
const config = Config.get();
this._agentOptions = config.agentOptions;
}

/**
Expand Down Expand Up @@ -105,6 +100,51 @@ class Controller {
}
});
}

/**
* Log a message in console
* @param msg
* @param priority
*/
log(msg, priority) {
if (priority === undefined || (priority === 'verbose' && this._verbose)) {
console.log(msg);
}
}

/**
* Handle an error
* @param error
*/
error(error) {
if (error instanceof Error) {
this.log(error.message);
} else if (typeof error === 'string') {
this.log(error);
} else {
this.log(error);
}
process.exit(1);
}

/**
* Server response handler
* @param response
* @returns {*}
* @private
*/
_parseResponse(response) {
let body;
try {
// parse json body
body = JSON.parse(response.body);
} catch (syntaxError) {
this.log(response.body.toString(), 'verbose');
this.error(`${i18n.__('Error')} ${response.statusCode} ${i18n.__('could not parse server response.')}`);
return;
}
return body;
}
}

module.exports = Controller;
22 changes: 18 additions & 4 deletions app/controllers/gpgAuthController.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
/**
* Authentication Controller
* Passbolt ~ Open source password manager for teams
* Copyright (c) Passbolt SA (https://www.passbolt.com)
*
* @copyright (c) 2019 Passbolt SA
* @licence AGPL-3.0 http://www.gnu.org/licenses/agpl-3.0.en.html
* 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 MfaController = require('./mfaController.js');
const Compat = require('../lib/phpjs.js');
Expand All @@ -19,7 +25,14 @@ class GpgAuthController extends MfaController {
* Constructor
*/
constructor(program) {
super(program);
try {
super(program);
} catch (error) {
console.error(error.message);
console.error('Make sure you created a valid configuration file in app/config/config.json.');
console.error('See app/config/config.default.json for an example.');
process.exit(1);
}
try {
this._parseProgramArg(program);
} catch (e) {
Expand Down Expand Up @@ -48,6 +61,7 @@ class GpgAuthController extends MfaController {
*/
async checkStatus() {
if (this.force) {
this.log('Clearing cookies', 'verbose');
this._clearCookie();
return true;
}
Expand Down
35 changes: 0 additions & 35 deletions app/controllers/keyringController.js

This file was deleted.

12 changes: 9 additions & 3 deletions app/controllers/mfaController.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
/**
* Command Line Interface Controller
* Passbolt ~ Open source password manager for teams
* Copyright (c) Passbolt SA (https://www.passbolt.com)
*
* @copyright (c) 2019 Passbolt SA
* @licence AGPL-3.0 http://www.gnu.org/licenses/agpl-3.0.en.html
* 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 CliController = require('./cliController.js');
const Domain = require('../models/domain.js');
Expand Down
12 changes: 9 additions & 3 deletions app/controllers/resourceController.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
/**
* Resource Controller
* Passbolt ~ Open source password manager for teams
* Copyright (c) Passbolt SA (https://www.passbolt.com)
*
* @copyright (c) 2019 Passbolt SA
* @licence AGPL-3.0 http://www.gnu.org/licenses/agpl-3.0.en.html
* 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 AppController = require('./appController.js');

Expand Down
Loading

0 comments on commit adf5c88

Please sign in to comment.