Merge branch 'master' of https://github.com/srinandan/microgateway-plugins
diff --git a/accesscontrol/README.md~ b/accesscontrol/README.md~ deleted file mode 100644 index a8e8c5c..0000000 --- a/accesscontrol/README.md~ +++ /dev/null
@@ -1,34 +0,0 @@ -#Sample Plugin - AccessControl - -##Overview -This plugin provides IP filtering to Edge Microgateway. With this plugin, users can whitelist and/or blacklist IP Addresses. - -##Enable the plugin -Include the plugin the in plugin sequence of {org}-{env}-config.yaml file: -``` - plugins: - sequence: - - oauth - - accesscontrol -``` - -##Configure the plugin -The plugin configuration has three parts: -* (instance) Defining the microgateway instance. This registers microgateway with Eureka -* (eureka) Provide the endpoint details to where Eureka is hosted -* (lookup) See below for details -``` -accesscontrol: - allow: - - 10.10.10.10 - - 11.*.11.* - deny: - - 12.12.12.* -``` - -###Lookup Configuration -Eureka registers apps (BOOK in the example above). There needs to be a mapping to map the API Proxy basePath to an app registered on Eureka. In the example above, the basePath /httpbin and /book maps to the BOOK app. - -NOTE: If a mapping is not found, then the plugins forwards the API traffic as configured in the proxy. - -
diff --git a/accesscontrol/package.json~ b/accesscontrol/package.json~ deleted file mode 100644 index 696da2b..0000000 --- a/accesscontrol/package.json~ +++ /dev/null
@@ -1,22 +0,0 @@ -{ - "name": "edgemicro-access-control", - "version": "1.0.0", - "description": "This provides ip based whitelisting or blacklisting", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "srinandan", - "license": "Apache 2.0", - "dependencies": { - "debug": "^2.2.0" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/apigee/microgateway-plugins.git" - }, - "bugs": { - "url": "https://github.com/apigee/microgateway-plugins/issues" - }, - "homepage": "https://github.com/apigee/microgateway-plugins#readme" -}
diff --git a/eurekaclient/README.md~ b/eurekaclient/README.md~ deleted file mode 100644 index e69de29..0000000 --- a/eurekaclient/README.md~ +++ /dev/null
diff --git a/eurekaclient/index.js~ b/eurekaclient/index.js~ deleted file mode 100644 index b582390..0000000 --- a/eurekaclient/index.js~ +++ /dev/null
@@ -1,95 +0,0 @@ -'use strict'; -/** - * This plugin integrate with Eureka and gets the target - * endpoint dynamically. - */ - -var debug = require('debug')('plugin:eurekeclient'); -var util = require('util'); -var os = require('os'); - -const port = 8000; -const Eureka = require('eureka-js-client').Eureka; - -module.exports.init = function (config, logger, stats) { - - const lookup = config.servicemap; - - config.instance.hostName = os.hostname(); - debug('local hostName: ' + config.instance.hostName); - config.instance.ipAddr = getIPAddr(); - config.instance.port = {}; - config.instance.port["$"] = port; - config.instance.port["@enabled"] = true; - config.instance.dataCenterInfo["@class"] = "com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo"; - - const client = new Eureka(config); - - try { - client.start(); - } catch (err) { - console.error(err); - client.stop(); - } - - function getIPAddr() { - var interfaces = os.networkInterfaces(); - var addresses = []; - for (var k in interfaces) { - for (var k2 in interfaces[k]) { - var address = interfaces[k][k2]; - if (address.family === 'IPv4' && !address.internal) { - addresses.push(address.address); - } - } - } - debug ('localhost ip: ' + addresses[0]); - return addresses[0]; - } - - function getAppName(url) { - for (var index in lookup) { - if (url.includes(lookup[index].uri) || url == lookup[index].uri) { - return { - app: lookup[index].app, - secure: lookup[index].secure - }; - } - } - return ""; - } - - function getTarget(app, secure) { - var instances = client.getInstancesByAppId(app); - - for (var index in instances) { - if (instances[index].status == "UP") { - return (secure == true) ? {"hostName": instances[index].hostName, "port": instances[index].securePort["$"]} : {"hostName": instances[index].hostName, "port":instances[index].port["$"]}; - } - } - return ""; - } - - return { - onrequest: function(req, res, next) { - var appInfo = getAppName(req.url); - var endpoint = getTarget(appInfo.app, appInfo.secure); - - if (endpoint.hostName) { - debug("target hostname: " + endpoint.hostName); - req.targetHostname = endpoint.hostName; - debug("target port: " + endpoint.port); - req.targetPort = endpoint.port; - req.targetPath = req.url; - if (appInfo.secure) { - req.targetSecure = true; - } else { - req.targetSecure = false; - } - } else { - console.warn("Target enpoint from Eureka not found"); - } - next(); - } - }; -}
diff --git a/eurekaclient/package.json~ b/eurekaclient/package.json~ deleted file mode 100644 index 02ff0ae..0000000 --- a/eurekaclient/package.json~ +++ /dev/null
@@ -1,22 +0,0 @@ -{ - "name": "edgemicro-eurekaclient", - "version": "1.0.0", - "description": "This microgateway plugin integrates for NetFlix's Eureka", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "srinandans@google.com", - "license": "ISC", - "dependencies": { - "eureka-js-client": "^4.3.0" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/apigee/microgateway-plugins.git" - }, - "bugs": { - "url": "https://github.com/apigee/microgateway-plugins/issues" - }, - "homepage": "https://github.com/apigee/microgateway-plugins#readme" -}