Commit a854752d authored by Michael Evenchick's avatar Michael Evenchick

updates to authentication based on testing, this als has some migration stuff in it

parent e2ad5cec
Pipeline #159299802 passed with stages
in 5 minutes and 20 seconds
......@@ -44,7 +44,7 @@ security:
stage: quality
script:
- node_setup
- npm audit --registry=https://registry.npmjs.org
- npm audit --registry=https://registry.npmjs.org --audit-level=moderate
unit:
stage: test
......
This diff is collapsed.
......@@ -15,7 +15,6 @@ const path = require('path');
/* Fetch in the other needed components for the this Adaptor */
const AdapterBaseCl = require(path.join(__dirname, 'adapterBase.js'));
/**
* This is the adapter/interface into Vmware_vCenter
*/
......@@ -38,7 +37,6 @@ class VmwareVCenter extends AdapterBaseCl {
}
*/
/**
* @callback healthCallback
* @param {Object} result - the result of the get request (contains an id and a status)
......
This diff is collapsed.
......@@ -4,7 +4,7 @@
"name": "getToken",
"protocol": "REST",
"method": "POST",
"entitypath": "{base_path}/{version}/login?{query}",
"entitypath": "/rest/com/vmware/cis/session",
"requestSchema": "schemaTokenReq.json",
"responseSchema": "schemaTokenResp.json",
"timeout": 0,
......@@ -12,7 +12,9 @@
"sendGetBody": false,
"requestDatatype": "JSON",
"responseDatatype": "JSON",
"headers": {},
"headers": {
"Authorization": "{b64}{username}:{password}{/b64}"
},
"sso": {
"protocol": "",
"host": "",
......
......@@ -19,23 +19,12 @@
"description": "the token returned from system",
"parse": false,
"encode": false,
"placement": "BODY",
"placement": "header",
"encrypt": {
"type": "AES",
"key": ""
},
"external_name": "aaaLogin.attributes.token"
},
"expires": {
"type": "string",
"description": "when the token will expire",
"parse": false,
"encode": false,
"encrypt": {
"type": "AES",
"key": ""
},
"external_name": "expires"
"external_name": "set-cookie.vmware-api-session-id"
}
},
"definitions": {}
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -3,18 +3,19 @@
"version": "0.5.1",
"description": "This adapter integrates with system Vmware_vCenter",
"main": "adapter.js",
"wizardVersion": "2.41.8",
"engineVersion": "1.46.3",
"wizardVersion": "2.41.21",
"engineVersion": "1.51.0",
"scripts": {
"artifactize": "npm i && node utils/packModificationScript.js",
"preinstall": "node utils/setup.js",
"lint": "eslint . --ext .json --ext .js",
"lint": "node --max_old_space_size=4096 ./node_modules/eslint/bin/eslint.js . --ext .json --ext .js",
"test:unit": "mocha test/unit/adapterTestUnit.js --LOG=error",
"test:integration": "mocha test/integration/adapterTestIntegration.js --LOG=error",
"test:cover": "nyc --reporter html --reporter text mocha --reporter dot test/*",
"test": "npm run test:unit && npm run test:integration",
"deploy": "npm publish --registry=http://registry.npmjs.org --access=public",
"build": "npm run deploy"
"build": "npm run deploy",
"lint:errors": "node --max_old_space_size=4096 ./node_modules/eslint/bin/eslint.js . --ext .json --ext .js --quiet"
},
"keywords": [
"IAP",
......@@ -39,23 +40,23 @@
"author": "Itential",
"homepage": "https://gitlab.com/itentialopensource/adapters/cloud/adapter-vmware_vcenter#readme",
"dependencies": {
"@itentialopensource/adapter-utils": "^4.27.3",
"ajv": "^6.10.0",
"fs-extra": "^7.0.0",
"readline-sync": "^1.4.9",
"@itentialopensource/adapter-utils": "^4.34.3",
"ajv": "^6.12.0",
"fs-extra": "^8.1.0",
"readline-sync": "^1.4.10",
"xmldom": "^0.1.27",
"package-json-validator": "^0.6.3"
},
"devDependencies": {
"chai": "^4.1.2",
"eslint": "^5.14.1",
"eslint-config-airbnb-base": "^13.1.0",
"eslint-plugin-import": "^2.16.0",
"eslint-plugin-json": "^1.4.0",
"mocha": "^5.2.0",
"nyc": "^14.1.1",
"testdouble": "^3.8.1",
"winston": "^2.4.0"
"chai": "^4.2.0",
"eslint": "^6.8.0",
"eslint-config-airbnb-base": "^14.1.0",
"eslint-plugin-import": "^2.20.1",
"eslint-plugin-json": "^2.1.1",
"mocha": "^7.1.1",
"nyc": "^15.0.0",
"testdouble": "^3.13.1",
"winston": "^3.2.1"
},
"private": false
}
......@@ -47,7 +47,10 @@
]
},
"save_metric": {
"type": "boolean",
"type": [
"boolean",
"string"
],
"description": "When true the metrics collected by the adapter will be stored in mongo or on the filesystem",
"default": false
},
......@@ -85,6 +88,11 @@
},
"mongo": {
"$ref": "#/definitions/mongo"
},
"encode_pathvars": {
"type": "boolean",
"description": "When true the path variables are encoded in the url",
"default": true
}
},
"required": [
......@@ -386,6 +394,23 @@
"default": 200,
"minimum": 50,
"maximum": 60000
},
"priorities": {
"type": "array",
"description": "define your priorities here",
"items": {
"type": "object",
"properties": {
"value": {
"type": "number",
"description": "Defines a priority - this number is what is passed in on a priority request"
},
"percent": {
"type": "number",
"description": "this is the percent of the queue that comes before the priority request (0 is front of queue, 100 is last in queue)"
}
}
}
}
},
"required": [
......@@ -433,11 +458,12 @@
"maximum": 20
},
"limit_retry_error": {
"type": "integer",
"description": "http error status number which defines that no capacity was available and thus after waiting a short interval the adapter can retry the request",
"default": 0,
"minimum": 0,
"maximum": 1000
"type": [
"integer",
"array"
],
"description": "http error status number which defines that no capacity was available and thus after waiting a short interval the adapter can retry the request. Supports an array of numbers or strings including a range provided as '###-###'",
"default": 0
},
"failover_codes": {
"type": "array",
......@@ -582,7 +608,7 @@
"description": "The fully qualified path name to the CA file used for SSL",
"default": "",
"examples": [
"keys/key.pem"
"security/ca.pem"
]
},
"key_file": {
......
......@@ -4,22 +4,22 @@
"properties": {
"host": "localhost",
"port": 80,
"base_path": "/",
"base_path": "/rest",
"version": "",
"cache_location": "none",
"save_metric": true,
"stub": true,
"protocol": "http",
"authentication": {
"auth_method": "basic user_password",
"auth_method": "request_token",
"username": "exampleUsername",
"password": "examplePassword",
"token": "",
"token_timeout": 180000,
"token_cache": "local",
"invalid_token_error": 401,
"auth_field": "header.headers.Authorization",
"auth_field_format": "Basic {b64}{username}:{password}{/b64}"
"auth_field": "header.headers.Cookie",
"auth_field_format": "vmware-api-session-id={token}"
},
"healthcheck": {
"type": "none",
......
......@@ -159,7 +159,7 @@ process.argv.forEach((val) => {
});
// need to set global logging
global.log = new (winston.Logger)({
global.log = winston.createLogger({
level: logLevel,
levels: myCustomLevels.levels,
transports: [
......@@ -253,7 +253,7 @@ function saveMockData(entityName, actionName, descriptor, responseData) {
};
// get the object for method we're trying to change.
const currentMethodAction = parsedJson.actions.find(obj => obj.name === actionName);
const currentMethodAction = parsedJson.actions.find((obj) => obj.name === actionName);
// if the method was not found - should never happen but...
if (!currentMethodAction) {
......@@ -261,12 +261,12 @@ function saveMockData(entityName, actionName, descriptor, responseData) {
}
// if there is a response object, we want to replace the Response object. Otherwise we'll create one.
const actionResponseObj = currentMethodAction.responseObjects.find(obj => obj.type === descriptor);
const actionResponseObj = currentMethodAction.responseObjects.find((obj) => obj.type === descriptor);
// Add the action responseObj back into the array of response objects.
if (!actionResponseObj) {
// if there is a default response object, we want to get the key.
const defaultResponseObj = currentMethodAction.responseObjects.find(obj => obj.type === 'default');
const defaultResponseObj = currentMethodAction.responseObjects.find((obj) => obj.type === 'default');
// save the default key into the new response object
if (defaultResponseObj) {
......@@ -297,7 +297,6 @@ function saveMockData(entityName, actionName, descriptor, responseData) {
return false;
}
// require the adapter that we are going to be using
const VmwareVCenter = require('../../adapter.js');
......
......@@ -161,7 +161,7 @@ process.argv.forEach((val) => {
});
// need to set global logging
global.log = new (winston.Logger)({
global.log = winston.createLogger({
level: logLevel,
levels: myCustomLevels.levels,
transports: [
......@@ -185,7 +185,6 @@ function runErrorAsserts(data, error, code, origin, displayStr) {
assert.equal(displayStr, error.IAPerror.displayString);
}
// require the adapter that we are going to be using
const VmwareVCenter = require('../../adapter.js');
......
......@@ -15,7 +15,6 @@ async function createBundle(adapterOldDir) {
const shortenedName = originalName.replace('adapter-', '');
const artifactName = originalName.replace('adapter', 'bundled-adapter');
const adapterNewDir = path.join(artifactDir, 'bundles', 'adapters', originalName);
fs.ensureDirSync(adapterNewDir);
......@@ -121,7 +120,7 @@ async function createBundle(adapterOldDir) {
// Run the commands in parallel
try {
await Promise.all(ops.map(async op => op()));
await Promise.all(ops.map(async (op) => op()));
} catch (e) {
throw new Error(e);
}
......@@ -134,18 +133,14 @@ async function createBundle(adapterOldDir) {
}
async function artifactize(entryPathToAdapter) {
try {
const truePath = path.resolve(entryPathToAdapter);
const packagePath = path.join(truePath, 'package');
// remove adapter from package and move bundle in
const pathObj = await createBundle(packagePath);
const { bundlePath } = pathObj;
fs.removeSync(packagePath);
fs.moveSync(bundlePath, packagePath);
return 'Bundle successfully created and old folder system removed';
} catch (e) {
throw e;
}
const truePath = path.resolve(entryPathToAdapter);
const packagePath = path.join(truePath, 'package');
// remove adapter from package and move bundle in
const pathObj = await createBundle(packagePath);
const { bundlePath } = pathObj;
fs.removeSync(packagePath);
fs.moveSync(bundlePath, packagePath);
return 'Bundle successfully created and old folder system removed';
}
module.exports = { createBundle, artifactize };
......@@ -18,7 +18,7 @@ printf "%b" "Running pre-commit hooks...\\n"
node utils/testRunner.js -r
# security audit on the code
npm audit --registry=https://registry.npmjs.org
npm audit --registry=https://registry.npmjs.org --audit-level=moderate
# lint the code
npm run lint
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment