Skip to content

Commit

Permalink
v 0.14.1
Browse files Browse the repository at this point in the history
- fix: added custom make request with cartificate params
- fix: added additional certificate setting
  • Loading branch information
gioboa committed Feb 25, 2019
1 parent c698157 commit 7e37395
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 0.14.1

### Bug Fixes

- added additional certificate settings

## 0.14.0

### Features
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ After setup you have to set the working project, you can click on status-bar ico
The extension store credentials in VS Code settings.<br><br>
**n.b:** the extension store the password in VS Code internal storage so it's safe and hidden. :wink: <br>

- **Additional Certificate** <br>
Additional certificate settings
- **Additional Statuses** <br>
Additional custom statuses, used for manage some Jira wrong behavior
- **Base Url** <br>
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.

30 changes: 29 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "jira-plugin",
"displayName": "Jira Plugin",
"description": "Jira integration for vscode",
"version": "0.14.0",
"version": "0.14.1",
"publisher": "gioboa",
"icon": "images/icons/icon.png",
"galleryBanner": {
Expand Down Expand Up @@ -125,6 +125,34 @@
"type": "boolean",
"description": "You can manage your Jira unread notifications inside VsCode notification center (n.b: only new Jira versions has notifications)",
"default": false
},
"jira-plugin.additionalCertificate": {
"type": "object",
"title": "Additional certificate settings",
"properties": {
"ca": {
"type": "array",
"description": "CA full files path (n.b: necessary only if the server uses a self-signed certificate)",
"items": {
"type": "string"
}
},
"cert": {
"type": "string",
"description": "Certificate authority full file path (n.b: necessary only if the server requires client certificate authentication)"
},
"key": {
"type": "string",
"description": "Private key full file path (n.b: necessary only if the server requires client certificate authentication)"
}
},
"default": {
"ca": [
""
],
"cert": "",
"key": ""
}
}
}
},
Expand Down
37 changes: 35 additions & 2 deletions src/http/jira-instance-patch.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import { readFileSync } from 'fs';
import { configuration, logger } from '../services';
import { CONFIG } from '../shared/constants';

const cleanOptions = (options: any): void => {
if (!!options.headers && Object.keys(options.headers).length === 0) {
delete options.header;
Expand Down Expand Up @@ -34,13 +38,42 @@ export const patchJiraInstance = (jiraInstance: any) => {
};
jiraInstance.project.customRequest = customRequest;

const originalRequestLib = jiraInstance.requestLib;
jiraInstance.originalRequestLib = jiraInstance.requestLib;
const customRequestLib = (options: any) => {
if (!!options && !!options.headers && options.headers.deleteAuth) {
delete options.auth;
delete options.headers.deleteAuth;
}
return originalRequestLib(options);
return jiraInstance.originalRequestLib(options);
};
jiraInstance.requestLib = customRequestLib;

let certificate: any;
try {
const caSettings = configuration.get(CONFIG.ADDITIONAL_CERTIFICATE);
if (!!caSettings.ca || !!caSettings.cert || !!caSettings.key) {
certificate = {
ca: !!caSettings.ca && caSettings.ca.every((c: string) => !!c) ? caSettings.ca.map((c: string) => readFileSync(c)) : undefined,
cert: !!caSettings.cert ? readFileSync(caSettings.cert) : undefined,
key: !!caSettings.key ? readFileSync(caSettings.key) : undefined
};
if (!!certificate.cert && !!certificate.key) {
certificate.requestCert = true;
}
}
} catch (e) {
certificate = undefined;
logger.printErrorMessageInOutputAndShowAlert('Invalid certificate settings');
}
jiraInstance.originalMakeRequest = jiraInstance.makeRequest;
const customMakeRequest = (options: any, callback: any, successString: any) => {
if (!!certificate) {
options = {
...options,
...certificate
};
}
return jiraInstance.originalMakeRequest(options, callback, successString);
};
jiraInstance.makeRequest = customMakeRequest;
};
3 changes: 2 additions & 1 deletion src/shared/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ export const CONFIG = {
GIT_INTEGRATION_ENABLED: 'gitIntegration',
NUMBER_ISSUES_IN_LIST: 'numberOfIssuesInList',
DEFAULT_JQL_SEARCH: 'defaultJqlSearch',
CHECK_FOR_NOTIFICATIONS_ENABLE: 'enableCheckForNotifications'
CHECK_FOR_NOTIFICATIONS_ENABLE: 'enableCheckForNotifications',
ADDITIONAL_CERTIFICATE: 'additionalCertificate'
};

// all the tracking time mode
Expand Down

0 comments on commit 7e37395

Please sign in to comment.