Skip to content
This repository has been archived by the owner on Aug 31, 2021. It is now read-only.

Commit

Permalink
private key passphrase prompts
Browse files Browse the repository at this point in the history
  • Loading branch information
mkloubert committed Jul 2, 2018
1 parent 3a265c5 commit 6595068
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 5 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

[![Share via Facebook](https://raw.githubusercontent.com/mkloubert/vscode-deploy-reloaded/master/img/share/Facebook.png)](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fmarketplace.visualstudio.com%2Fitems%3FitemName%3Dmkloubert.vscode-deploy-reloaded&quote=vscode-deploy-reloaded) [![Share via Twitter](https://raw.githubusercontent.com/mkloubert/vscode-deploy-reloaded/master/img/share/Twitter.png)](https://twitter.com/intent/tweet?source=https%3A%2F%2Fmarketplace.visualstudio.com%2Fitems%3FitemName%3Dmkloubert.vscode-deploy-reloaded&text=vscode-deploy-reloaded:%20https%3A%2F%2Fmarketplace.visualstudio.com%2Fitems%3FitemName%3Dmkloubert.vscode-deploy-reloaded&via=mjkloubert) [![Share via Google+](https://raw.githubusercontent.com/mkloubert/vscode-deploy-reloaded/master/img/share/Google+.png)](https://plus.google.com/share?url=https%3A%2F%2Fmarketplace.visualstudio.com%2Fitems%3FitemName%3Dmkloubert.vscode-deploy-reloaded) [![Share via Pinterest](https://raw.githubusercontent.com/mkloubert/vscode-deploy-reloaded/master/img/share/Pinterest.png)](https://pinterest.com/pin/create/button/?url=https%3A%2F%2Fmarketplace.visualstudio.com%2Fitems%3FitemName%3Dmkloubert.vscode-deploy-reloaded&media=https://raw.githubusercontent.com/mkloubert/vscode-deploy-reloaded/master/img/demo1.gif&description=Recoded%20version%20of%20Visual%20Studio%20Code%20extension%20%27vs-deploy%27%2C%20which%20provides%20commands%20to%20deploy%20files%20to%20one%20or%20more%20destinations.) [![Share via Reddit](https://raw.githubusercontent.com/mkloubert/vscode-deploy-reloaded/master/img/share/Reddit.png)](https://www.reddit.com/submit?url=https%3A%2F%2Fmarketplace.visualstudio.com%2Fitems%3FitemName%3Dmkloubert.vscode-deploy-reloaded&title=vscode-deploy-reloaded) [![Share via LinkedIn](https://raw.githubusercontent.com/mkloubert/vscode-deploy-reloaded/master/img/share/LinkedIn.png)](https://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Fmarketplace.visualstudio.com%2Fitems%3FitemName%3Dmkloubert.vscode-deploy-reloaded&title=vscode-deploy-reloaded&summary=Recoded%20version%20of%20Visual%20Studio%20Code%20extension%20%27vs-deploy%27%2C%20which%20provides%20commands%20to%20deploy%20files%20to%20one%20or%20more%20destinations.&source=https%3A%2F%2Fmarketplace.visualstudio.com%2Fitems%3FitemName%3Dmkloubert.vscode-deploy-reloaded) [![Share via Wordpress](https://raw.githubusercontent.com/mkloubert/vscode-deploy-reloaded/master/img/share/Wordpress.png)](https://wordpress.com/press-this.php?u=https%3A%2F%2Fmarketplace.visualstudio.com%2Fitems%3FitemName%3Dmkloubert.vscode-deploy-reloaded&quote=vscode-deploy-reloaded&s=Recoded%20version%20of%20Visual%20Studio%20Code%20extension%20%27vs-deploy%27%2C%20which%20provides%20commands%20to%20deploy%20files%20to%20one%20or%20more%20destinations.&i=https://raw.githubusercontent.com/mkloubert/vscode-deploy-reloaded/master/img/demo1.gif) [![Share via Email](https://raw.githubusercontent.com/mkloubert/vscode-deploy-reloaded/master/img/share/Email.png)](mailto:?subject=vscode-deploy-reloaded&body=Recoded%20version%20of%20Visual%20Studio%20Code%20extension%20'vs-deploy'%2C%20which%20provides%20commands%20to%20deploy%20files%20to%20one%20or%20more%20destinations.:%20https%3A%2F%2Fmarketplace.visualstudio.com%2Fitems%3FitemName%3Dmkloubert.vscode-deploy-reloaded)

## 0.80.1 (June 2nd, 2018; bugfix pull files from SFTP)
## 0.81.0 (July 3rd, 2018; private key passphrase prompts)

* added `alwaysAskForPrivateKeyPassphrase` and `askForPrivateKeyPassphrase` settings for [SFTP](https://github.com/mkloubert/vscode-deploy-reloaded/wiki/target_sftp) targets ... s. [issue #71](https://github.com/mkloubert/vscode-deploy-reloaded/issues/71)

## 0.80.1 (July 2nd, 2018; bugfix pull files from SFTP)

* fixed bug, which throws exception, when pulling files from [SFTP server](https://github.com/mkloubert/vscode-deploy-reloaded/wiki/target_sftp) ... s. [issue #81](https://github.com/mkloubert/vscode-deploy-reloaded/issues/81)

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "vscode-deploy-reloaded",
"displayName": "Deploy (Reloaded)",
"description": "Deploys files of a workspace to a destination.",
"version": "0.80.1",
"version": "0.81.0",
"publisher": "mkloubert",
"engines": {
"vscode": "^1.24.0"
Expand Down Expand Up @@ -53138,6 +53138,11 @@
"description": "Always ask for password and do not cache, if no password is defined.",
"default": false
},
"alwaysAskForPrivateKeyPassphrase": {
"type": "boolean",
"description": "Always ask for private key passphrase and do not cache.",
"default": false
},
"alwaysAskForUser": {
"type": "boolean",
"description": "Always ask for username and do not cache, if no user is defined.",
Expand All @@ -53157,6 +53162,11 @@
}
}
},
"askForPrivateKeyPassphrase": {
"type": "boolean",
"description": "Ask for private key passphrase.",
"default": false
},
"beforeDelete": {
"description": "One or more operations that should be invoked BEFORE a delete operation starts.",
"type": "array",
Expand Down
1 change: 1 addition & 0 deletions src/i18.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export interface Translation {
};
'continue'?: string;
credentials?: {
enterPassphrase?: string;
enterPassword?: string;
enterUsername?: string;
};
Expand Down
1 change: 1 addition & 0 deletions src/lang/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export const translation: Translation = {
},
'continue': "Fortfahren",
credentials: {
enterPassphrase: "Geben Sie die Passphrase an ...",
enterPassword: "Geben Sie das Passwort an ...",
enterUsername: "Geben Sie den Benutzernamen an ...",
},
Expand Down
1 change: 1 addition & 0 deletions src/lang/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export const translation: Translation = {
},
'continue': "Continue",
credentials: {
enterPassphrase: "Enter the passphrase ...",
enterPassword: "Enter the password ...",
enterUsername: "Enter the name of the user ...",
},
Expand Down
48 changes: 46 additions & 2 deletions src/plugins/sftp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,18 @@ export interface SFTPTarget extends deploy_targets.Target {
* Always ask for password and do not cache, if no password is defined.
*/
readonly alwaysAskForPassword?: boolean;
/**
* Always ask for private key passphrase and do not cache.
*/
readonly alwaysAskForPrivateKeyPassphrase?: boolean;
/**
* Always ask for uasername and do not cache, if no user is defined.
*/
readonly alwaysAskForUser?: boolean;
/**
* Ask for private key passphrase.
*/
readonly askForPrivateKeyPassphrase?: boolean;
/**
* The path to an (event) script, which is executed BEFORE a file is going to be uploaded.
*/
Expand Down Expand Up @@ -226,6 +234,7 @@ export interface SFTPUploadedModuleExecutorArguments extends SFTPUploadScriptArg


const CACHE_PASSWORD = 'password';
const CACHE_PRIV_KEY_PASSPHRASE = 'privateKeyPassphrase';
const CACHE_USER = 'user';

class SFTPPlugin extends deploy_plugins.AsyncFileClientPluginBase<SFTPTarget,
Expand Down Expand Up @@ -268,6 +277,7 @@ class SFTPPlugin extends deploy_plugins.AsyncFileClientPluginBase<SFTPTarget,
const DIR = this.replaceWithValues(target, target.dir);

let cachePassword = false;
let cachePrivKeyPassphrase = false;
let cacheUsername = false;

const ALWAYS_ASK_FOR_USER = deploy_helpers.toBooleanSafe( target.alwaysAskForUser );
Expand Down Expand Up @@ -321,6 +331,32 @@ class SFTPPlugin extends deploy_plugins.AsyncFileClientPluginBase<SFTPTarget,
cachePassword = !ALWAYS_ASK_FOR_PASSWORD;
}

const ALWAYS_ASK_FOR_PRIV_KEY_PASSPHRASE = deploy_helpers.toBooleanSafe( target.alwaysAskForPrivateKeyPassphrase );
let privateKeyPassphrase = target.privateKeyPassphrase;
if (IS_PRIVATE_KEY_DEFINED && _.isNil(privateKeyPassphrase)) {
let askForPrivKeyPassphrase = ALWAYS_ASK_FOR_PRIV_KEY_PASSPHRASE;
if (!askForPrivKeyPassphrase) {
askForPrivKeyPassphrase = !CACHE.has( CACHE_PRIV_KEY_PASSPHRASE );
}

if (askForPrivKeyPassphrase) {
privateKeyPassphrase = await vscode.window.showInputBox({
ignoreFocusOut: true,
password: true,
prompt: this.t(target, 'credentials.enterPassphrase'),
});

if (_.isNil(privateKeyPassphrase)) {
return;
}
}
else {
privateKeyPassphrase = CACHE.get( CACHE_PRIV_KEY_PASSPHRASE );
}

cachePrivKeyPassphrase = !ALWAYS_ASK_FOR_PRIV_KEY_PASSPHRASE;
}

let beforeUpload: deploy_clients_sftp.SFTPBeforeUpload;
let uploadCompleted: deploy_clients_sftp.SFTPUploadCompleted;
{
Expand Down Expand Up @@ -541,7 +577,7 @@ class SFTPPlugin extends deploy_plugins.AsyncFileClientPluginBase<SFTPTarget,
).trim()
),
privateKey: privateKeyFile,
privateKeyPassphrase: target.privateKeyPassphrase,
privateKeyPassphrase: privateKeyPassphrase,
readyTimeout: parseInt(
deploy_helpers.toStringSafe(
this.replaceWithValues(target, target.readyTimeout)
Expand Down Expand Up @@ -575,12 +611,20 @@ class SFTPPlugin extends deploy_plugins.AsyncFileClientPluginBase<SFTPTarget,
else {
CACHE.unset(CACHE_PASSWORD);
}

if (cachePrivKeyPassphrase) {
CACHE.set(CACHE_PRIV_KEY_PASSPHRASE, privateKeyPassphrase);
}
else {
CACHE.unset(CACHE_PRIV_KEY_PASSPHRASE);
}

return CTX;
}
catch (e) {
CACHE.unset(CACHE_USER)
.unset(CACHE_PASSWORD);
.unset(CACHE_PASSWORD)
.unset(CACHE_PRIV_KEY_PASSPHRASE);

throw e;
}
Expand Down

0 comments on commit 6595068

Please sign in to comment.