Skip to content
This repository was archived by the owner on Sep 23, 2025. It is now read-only.

Commit b6f87b7

Browse files
committed
PB-7562 Fix passphrase parameter is ignored
1 parent a184f0d commit b6f87b7

File tree

4 files changed

+20
-2074
lines changed

4 files changed

+20
-2074
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,10 @@ Right now the basics, only authentication and read operations.
174174
Authentication is based on [GPGAuth](https://www.passbolt.com/help/tech/auth), so it uses your private key
175175
and your passphrase if you have one.
176176

177-
You can provide your passphrase or let GPG handle the prompt.
177+
Optionally uou can provide your passphrase if you do not want gnupg handle the pinentry.
178+
Please note that this obviously less safe.
178179
```
179-
$ passbolt auth login -p ada_password
180+
$ passbolt auth login --password=ada@passbolt.com
180181
181182
GPGAuth Skipping, you are already logged in
182183
```

app/controllers/controller.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ class Controller {
8989
.on('end', () => {
9090
resolve(result);
9191
})
92-
.on('error', () => {
92+
.on('error', (e) => {
93+
this.log(e, 'verbose');
9394
const err = new Error(`Error: could not connect to ${options.url}`);
9495
reject(err);
9596
});

app/controllers/gpgAuthController.js

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class GpgAuthController extends MfaController {
4545
this.URL_VERIFY = `${baseUrl}/verify.json`;
4646
this.URL_CHECKSESSION = `${baseUrl}/is-authenticated.json`;
4747
this.URL_LOGIN = `${baseUrl}/login.json`;
48-
this.URL_LOGOUT = `${baseUrl}/logout`;
48+
this.URL_LOGOUT = `${baseUrl}/logout.json`;
4949

5050
// Session cookie
5151
this.COOKIE_FILE = `${this.appDir}/app/tmp/cookie.json`;
@@ -176,16 +176,16 @@ class GpgAuthController extends MfaController {
176176
*/
177177
async logout() {
178178
try {
179+
this._clearCookie();
179180
const response = await this.get({
180181
url: this.URL_LOGOUT,
181182
jar: this.cookieJar
182183
});
183184
this._serverResponseHealthCheck('logout', response);
184-
this._clearCookie();
185185
return true;
186186
} catch (error) {
187-
this.error(error);
188-
return false;
187+
this.log(error, 'verbose');
188+
return true;
189189
}
190190
}
191191

@@ -225,25 +225,24 @@ class GpgAuthController extends MfaController {
225225
*/
226226
_parseProgramArg(program) {
227227
if (!program) {
228+
console.log('no program');
228229
return;
229230
}
230-
231-
if (program.fingerprint) {
231+
if (program.opts().fingerprint) {
232232
this.user = new User({
233233
privateKey: {
234-
fingerprint: program.fingerprint
234+
fingerprint: program.opts().fingerprint
235235
}
236236
});
237237
} else {
238238
this.user = new User();
239239
}
240240

241-
if (program.passphrase) {
241+
if (program.opts().passphrase) {
242242
// if no passphrase is given but is needed
243243
// a gpg prompt will be triggered by gpg itself
244-
this.passphrase = program.passphrase;
244+
this.passphrase = program.opts().passphrase;
245245
}
246-
247246
this.force = program.force || false;
248247
}
249248

@@ -329,7 +328,10 @@ class GpgAuthController extends MfaController {
329328
const encryptedAuthToken = Compat.stripslashes(Compat.urldecode(response.headers['x-gpgauth-user-auth-token']));
330329
let options;
331330
if (this.passphrase !== undefined) {
332-
options = ['--passphrase', this.passphrase];
331+
options = [
332+
'--pinentry-mode', 'loopback',
333+
'--passphrase', this.passphrase
334+
];
333335
}
334336
const userAuthToken = await Crypto.decrypt(encryptedAuthToken, options);
335337
GpgAuthToken.validate('token', userAuthToken);

0 commit comments

Comments
 (0)