Git Product home page Git Product logo

microgateway's Introduction

Introduction

This is fork with datastore cache for http-responses. To enable it you must set env var DATASTORE_USE_LOCAL_CACHE=true.

The Microgateway is an developer-focused, extensible gateway framework written in Node.js for enforcing access to Microservices & APIs - https://developer.ibm.com/apiconnect/. It supports the following core features:

  • Secure and control access to APIs using Swagger (OpenAPI) Specification
  • Collection of pre-built gateway policies for API Key validation, OAuth 2.0, rate limiting, and JavaScript
  • Create gateway policies (security, routing, integration, etc... ) using Swagger extensions (API Assembly)
  • Simple interfaces for creating your own gateway policies.

The role of a Gateway in an API architecture is to protect, enrich and control access to API services. These sets of capabilities are often related to security and rate limiting, but it also includes the ability to do deeper message inspection. For example, you may want to insure that the message received is properly formed JSON, XML, or data following your own specific format. In addition, the Gateway can modify the payload or transform it to meet old or new interfaces for the API backend. Finally, the Gateway can invoke multiple services and aggregate responses from multiple API backends.

The Microgateway is the foundation for all of those things. It is optimized to perform security, rate limiting, and much more complex packet processing through a highly flexible flow-engine.

The flow-engine is a processing unit that allows you to define a sequence of processing policies or tasks that get applied to the transaction as it passes through the Gateway for a specific API. These policies may be organized in a linear fashion, executing in sequential order. Or, they may have conditional logic deciding which set of policies will execute depending on variables that are part of the API flow.

The Microgateway currently contains the following policies that run implicitly based on swagger definitions:

  • Client_ID/Client_Secret – Use a client ID and client secret to authenticate and authorize the use of this API
  • Basic Auth – Use Basic Auth to authenticate and authorize the use of this API
  • OAuth 2.0 – Use OAuth2.0 to authenticate and authorize the use of this API
  • Rate-Limit – Limit the number of requests per time unit that the subscriber may access this API

The Microgateway currently contains the following polices that are available to the Assembly extension to the swagger definition:

  • if - If a condition evaluates to True, execute the corresponding flow.
  • switch – Given a set of conditions, execute the flow corresponding to the first condition that evaluates to True.
  • operation-switch – Given a set of conditions on the operation, select the first rule where the condition evaluates to True.
  • throw – Throw an exception
  • invoke – Retrieve a resource using HTTP or HTTPS. Currently supported HTTP request methods or verbs are GET, HEAD, POST, PUT, PATCH, DELETE, and OPTIONS.
  • javascript – Execute a JavaScript program to manipulate or inspect the transaction
  • set-variable – Set a variable in the context

API Designer Toolkit

The API Designer toolkit provides a graphical interface for the Microgateway. You can download it using NPM via npm install -g apiconnect. This toolkit can be also be used for creating enterprise API definitions using IBM API Connect, which provides features to create and manage APIs on an enterprise scale.

For more information, see https://developer.ibm.com/apiconnect/.

The API designer toolkit creates YAML files for the APIs definitions. These can then be tested directly on the internal Microgateway (part of the API Designer toolkit), or you can run them on an external Microgateway by moving the underlying YAML files to the external Microgateway directory.

The Microgateway Architecture

The Microgateway was developed with the goal of making something simple, community-based, and that could easily be extended for anyone’s needs.

The Microgateway has the following characteristics:

  • Built on Node Express and Loopback frameworks
  • Processes Swagger API definitions via a middleware chain that identifies the API and executes the API definition.
  • Contains a “datastore” that holds the data model of all API artifacts to be processed.
  • Uses a flow-engine to process a variety of policies giving the API designer the ability to perform deep packet processing on the request or response.

A diagram of the Microgateway is shown below. Looking at the diagram, the flow of a request is from left to right. The Microgateway is a collection of middleware components that process the request in order. Each middleware component passes control to the next middleware until the processing of the request is complete. The postflow and error-handler middlewares work together to return the results back to the client making the request.

alt text

The urlrewrite middleware simply modifies the prefix of the URL under certain conditions. For the most part, this is a passthrough.

The context middleware creates a scratchpad memory area known as the context. The context is accessible by all middlewares and policies in the flow. Any middleware or policy can add, modify or remove variables from the context.

Here are some of the context variables that are automatically populated:

alt text

One object that is particularly important is the message object. The message object contains the payload that was received from a request. For example, if you add an invoke action, the results from that action will be placed in the message object. At the end of the flow, the contents of the message object will be returned back to the client.

Here are some other context variables:

alt text

The request object is another important object. It holds all of the information about the original request that was received by the Microgateway. There are other objects that contain system information, plan information, and general API information.

One important aspect of the context is that it is read-writable by policies and middleware as they execute. Another important factor is that context variables can be used as substitution parameters inside the conditional policies. This allows you to write sophisticated logic flows, simply referencing them through configuration.

The analytics middleware is used to connect to an external analytics engine. It passes a series of variables from the context in a message to an external collection device.

The preflow middleware accomplishes the following:

  1. Identifies the API (or Swagger definition) to execute.
  2. Performs security associated with that Swagger definition.
  3. Performs rate-limiting for the API.
  4. Creates the objects necessary for the assembly (IBM extensions to the swagger definition) to be consumed by the flow-engine.

The flow-engine is a combinational processor that allows you to insert sequential logic around a series of policies. The policies can perform any operation to the request or response payload. They can be used to retrieve a response from an API backend or examine the request for security or other needs.

The flow-engine is built as a vendor extension to the standard Swagger specification. The policies that are referenced in the assembly must have a pre-built policy. Each one of the policies is a Node.js module that provides the processing of the message. Each policy also has a policy.yml file that defines the set of properties and behavior of the policy. For examples, visit the policies directory of the microgateway repository.

Getting Started with the Microgateway

Following are the steps to install and run a stand alone microgateway

Step 1. Clone the microgateway repository

cd $HOME
git clone https://github.com/strongloop/microgateway.git

Step 2. Populate all of the necessary dependencies for the project

cd $HOME/microgateway
npm install

Step 3. Change current working directory to the root directory

cd $HOME/microgateway/

Step 4. Create a startup script that sets environment variables and starts up the Microgateway. The script file is a simple node.js JavaScript file shown below. Create this file in the $HOME/microgateway/ directory.

Note: The CONFIG_DIR is the folder containing the yaml files holding the API definitions that you wish to enforce.

// sample.js
//
'use strict';

var mg = require('./lib/microgw');
var fs = require('fs');

// config dir
process.env.CONFIG_DIR = __dirname + '/definitions/myapp';
process.env.NODE_ENV = 'production';
mg.start(3000);

Step 5. Create a yaml file to define the API. Place the yaml file in the folder identified by the CONFIG_DIR environment variable created in the startup script. For this example, we are creating the file sample_1.0.0.yaml in the $HOME/microgateway/definitions/myapp directory. Note that you can place several yaml files in this directory and all will be pulled in and used by the Microgateway.

# sample_1.0.0.yaml
#
info:
  version: 1.0.0
  title: sample
  description: sample laptop yaml
basePath: /sample
swagger: '2.0'
paths:
  /echo:
    get:
      responses:
        '200':
          description: 200 OK
x-ibm-configuration:
  assembly:
    execute:
      - javascript:
          title: write a small json object
          source: |
           message.body = { text : 'Hello World' };
schemes:
  - http

Step 6. From the root directory, execute the command to start the Microgateway.

cd $HOME/microgateway/
node sample.js

Step 7. Send a curl command to test the API. It should return the {“text”:”Hello World”} JSON object.

curl http://localhost:3000/sample/echo

For more information on the internal specifics of the Microgateway, you may want to look at the microgateway/test directory. All middleware components have one or more test suites to exercise their interfaces and logic.

For more examples on how to add various policies to your API assembly, look in the microgateway/test/definitions directory. There are several swagger files that are used to test out the implementation.

How to contribute to this Project

For information on contribuging to this project, please look at CONTRIBUTING.md and CONDUCT.md as well as the LICENSE.txt file.

microgateway's People

Contributors

bosco-li avatar curtisr7 avatar danbadt avatar garytu avatar jcollinsjc avatar jgeddes2001 avatar johnbellessa avatar kraman avatar ludoblues avatar mamendoz avatar mjjuang avatar nctjsmith avatar om-design avatar ozairs avatar palgon avatar raymondfeng avatar rmg avatar simonhoibm avatar swissw avatar thomas-burke avatar tinaho avatar yhwang avatar youremai avatar yrsh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

microgateway's Issues

npm err Missing options@latest in the bundle builds console

There is npm err options@latest required by [email protected] Missing from the build
but sse is not a direct dependencies of microgateway in package.json
It is an indirect dependencies - see below but it exists in npm-shrinkwrap.json

[email protected] /Users/smartmouse/staging-5081-iFix/apiconnect/node_modules/microgateway
└─┬ [email protected]
└─┬ [email protected]
└── [email protected]

dc60server:microgateway smartmouse$
dc60server:microgateway smartmouse$ npm ls [email protected]
[email protected] /Users/smartmouse/staging-5081-iFix/apiconnect/node_modules/microgateway
└─┬ [email protected]
└─┬ [email protected]
└─┬ [email protected]
└── [email protected]

install fail, why?

events.js:72
throw er; // Unhandled 'error' event
^
Error: ENOENT, open 'binaries/appmetrics/tgz/0.10/appmetrics-2.0.1-linux-x64.tgz'
/root/.nvm/v0.10.40/lib
└── (empty)

npm ERR! Linux 3.10.0-514.2.2.el7.x86_64
npm ERR! argv "node" "/root/.nvm/v0.10.40/bin/npm" "install" "-g" "apiconnect"
npm ERR! node v0.10.40
npm ERR! npm v4.3.0
npm ERR! code ELIFECYCLE
npm ERR! errno 8

npm ERR! [email protected] install: node extract_all_binaries.js
npm ERR! Exit status 8
npm ERR!
npm ERR! Failed at the [email protected] install script 'node extract_all_binaries.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the appmetrics package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node extract_all_binaries.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs appmetrics
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls appmetrics
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! /root/.npm/_logs/2017-08-30T05_25_56_452Z-debug.log

add loopback-component-cas?

Hello,

Actualy, we use CAS specification for legacy app.

Do you think that the integration of this component with microgateway could have an interest for you and be done quickly?

Accept-Encoding gzip not working

We have an API that uses the Invoke policy to make a call out to a Bluemix Cloudant database. Recently that API was updated to return gzip encoded data, this caused our code in the microgateway to fail. After the Invoke policy we have a Javascript policy and our reference to message.body.id now fails.

To workaround this we now use a Set-Variable policy to set request.headers.accept-encoding to gzip;q=0 and now our Javascript policy code works again.

Should the Invoke policy support data returned compressed?
What is the IBM best practice for this? I am sure it is not to disable compression like we did.

Thanks in advance

"Lazy Load" for context variables.

Presently, the µgw uses 2 middlewares to pre-populate APIC context variables:

  • The context middleware: for "general" context vars (system, request, and message metadata)
  • The preflow middleware: handles apiconnect-specific context metadata

A large percentage of these values are not used by policy so copying them from the middleware req object to a µgw context is largely a waste of memory and CPU time. I propose a "lazy load" strategy, meaning that the values of context variables are values are pulled from the middleware req at the time the value is requested.

This may help with portability to the DP/Edge gateway because there is no need to do a wholesale convert from Edge gateway metadata to Micro gateway metadata and vice-versa. The logic to do this would also benefit the cases where a policy needs to set metadata.

rate limit

hitting the following error when I'm trying to do a load test on the microgateway.

Error: rate-limit: limit exceeded x-ibm-unnamed-rate-limit

where is the rate limit set?

User defined policies

Hi Strongloop Team,

I really like how API Connect's API Designer play well with microgateway.
I have followed this tutorial and the readme.
The tutorial suggested to put the user defined policies inside a "policies" folder and configure the ".apiconnect > config" to refer to this folder.

My question is...
Is there a way I can config where the microgateway (not API Connect/API Designer) to grab the user defined policies?

The reason I am asking is.. I try to something as below:
(1) Follow the "readme" tutorial, in which those built-in policies are clone to my local environment
(2) Go to the project's root and "apic edit"
(3) Configure the ".apiconnect > config" to let API Connect know where my custom policies are stored
(3) Use the API Designer's "Assemble" and pull the "JavaScript" to the panel
(4) [Problem arises here!] API Designer said "This policy is not available on the selected gateway"

I try to put my custom policies in another folder "self-defined-policies" and configure the ".apiconnect > config" to read "self-defined-policies".
After that, API Connect can read the policies properly (without saying "This policy is not available on the selected gateway")
However when I run "sample.js" in the "readme" tutorial, it fails to reference my custom policies..

Thanks for your help

api loader failed to load any api

I appreciate the open source, and look forward to exercising this project/platform

I don't have a lot of time right now to dig into the code, so thought I'd post the issue encountered here, hoping you can point me in the right direction

  1. followed installation instructions and test below, including definition of yaml file in definitions/sample
  2. node sample.js appears to start-up correctly, issuing 2 warnings on deprecated context middleware
  3. curl http://localhost:3000/sample/echo -- and receive message {"name": "PreFlowError". "message": "unable to process the request"}
  4. message in cli displays "Error: api-loader failed to load any API"
  5. not sure if it is important, but i did note in the .datastore file that the following record is stored
    {"snapshot":"C:\Users\Patrick\Desktop\microgateway\test/definitions/sample","port":36042}

enable microgateway works with node 8.x and /node 10.x

node 4.x is out of service
node 6.x will be end of service next year
Please assess if microgateway will work with node 8.x and node 10.x?
Thanks

current engine in package.json

 "engines": {
    "node": ">=4.0.0"
}

should change to node >=6.0.0

Update dependencies and/or stop using deprecated functions

npm WARN deprecated [email protected]: use uuid module instead
npm WARN deprecated [email protected]: ReDoS vulnerability parsing Set-Cookie https://nodesecurity.io/advisories/130
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated [email protected]: to-iso-string has been deprecated, use @segment/to-iso-string instead.
npm WARN deprecated [email protected]: Jade has been renamed to pug, please install the latest version of pug instead of jade
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN prefer global [email protected] should be installed with -g

Typo in setup of "Hello World"

In following the instructions, I got an exception because the line

var mg = require('../lib/microgw');

in sample.js

is being executed from the $HOME/microgateway directory per the instructions and the ".." is effectively looking for that library as

$HOME/lib/microgw

instead of its actual location at

$HOME/microgateway/lib.microgw

I edited the sample.js file to change this line to:

var mg = require('./lib/microgw');

(i.e. changed ".." to "." in the require call)

and the "hello world" worked. You need to fix this typo or folks not familiar with what's going on will get frustrated.

Microgateway graphic interface

I not understand clearly.
After installation, we can manupile Api graphically as indicated.
https://strongloop.com/strongblog/introducing-api-microgateway-programmable-open-source-gateway-apis/.
Because I did the installation and I get
{"text":"Hello World"}

Or there is a difference between IBM api connect and Microgateway?.

Thank you

Connect microgateway to existing LB app that uses local user accounts and accessToken with scopes

Background
I've built an API with local user accounts (custom user model), and with custom accessToken model (custom attributes & scopes.)
For Ex. /login issues a limited access token with time limits, but when user "registered" in the app, the remote method behind /register auto-generates 4 eternal tokens with more broader scopes and custom attributes, like livemode true/false, type public/private. The public accessToken has very limited scope and is only allow to one action. The livemode attribute in the accessToken is later used to classify events. This property is inherit by the each model resulting from the use of the token, meaning that if you use a token with livemode = false, all those transactions are consider "test mode" transactions.

I also implemented custom end-points to rolled the auto-gen eternal token. At no point in the life of a user, the user is allow to generate more eternal tokens, they can generate timed tokens (/login) or rolled the existing eternal tokens created at the registration point.

Questions
I'm trying to use the microgateway to control authentication and security.

  1. How do I configure the microgateway to look at my user model and accessToken model for authentication?
    1.1 Do I need to remove these models from my app and re-implement in the microgateway?
    1.2 If the above is true: What is the equivalent of my the LB user model in the microgateway?
    1.3 Else: how do I go about integrating my existing logic?

I'll will really appreciate if someone can shine some light to these questions.
Thank for the hard-work put into LB and LB microgateway.
D.

Dockerfile does not include yaml definitions

The getting started tutorial provides instructions on how to configure API definitions but the Dockerfile does not include the any references to the same instructions.

I have made changes to reflect the tutorial but wanted to get consensus before committing any changes.

.
.
COPY package.json microgateway.js ./
COPY definitions definitions/

Dockerfile

FROM node:6-alpine

RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

COPY package.json microgateway.js ./
COPY definitions definitions/
COPY lib lib/
COPY utils utils/
COPY config config/
COPY policies policies/

ARG NPM_REGISTRY
ENV npm_config_registry ${NPM_REGISTRY:-https://registry.npmjs.com}
RUN npm install --prod --quiet --depth 0

ENV NODE_ENV production

CMD [ "node", "microgateway.js" ]

Errors running nginx during deployment

I am getting an error when deploying nginx. The easy fix is to add that to the Dockerfile but curious on whether its something in my environment.

nginx           | + openssl req -x509 -newkey rsa:2048 -days 3650 -nodes -sha256 -keyout /etc/nginx/key.pem -out /etc/nginx/cert.pem -subj /C=NN/ST=NN/L=NN/O=NN/CN=localhost
nginx           | /run.sh: line 8: openssl: command not found
nginx exited with code 127

nginx.tmpl

if [ ! -e "/etc/nginx/cert.pem" ] || [! -e "/etc/nginx/key.pem" ]
then
    openssl req -x509 -newkey rsa:2048 -days 3650 -nodes -sha256 \
     -keyout "/etc/nginx/key.pem" -out "/etc/nginx/cert.pem" \
     -subj "/C=NN/ST=NN/L=NN/O=NN/CN=localhost"
fi

I checked the base nginx image and it seems openssl does not work on the command-line

root@5a4e624bb868:/# openssl
bash: openssl: command not found

Datastore/cache reduces performance.

When we load more than 500 rps, the performance falls heavily. Because the datastore-logic (apiloader middleware) starts sending over the network snapshots data between microgateway, datastore and cache. What to do with it, can it be somehow optimized or disabled? Why it sends every time http-request (in getCurrentSnapshot) on every request to the api?

The empty policy is crashed during flow.fail

When a policy has empty 'properties:' or 'required:' attributes defined, but the 'throw:' property is populated in policy.yaml, the attempt to call flow.fail ends with crash in flow-engine on:

// 1. check the policy's own handler
if (currTask[type].catch) {

as currTask is null.

Adding some property is fixing the problem.

Microgateway not starting on apim-ui

When starting the app from the AMP in designer, the gateway never starts.

The gateway logs show:

[Wed Oct 4 13:20:45 2017] com.ibm.diagnostics.healthcenter.loader INFO: Node Application Metrics 3.1.0.201710011954 (Agent Core 3.2.2)
[Wed Oct 4 13:20:45 2017] com.ibm.diagnostics.healthcenter.mqtt INFO: Connecting to broker localhost:1883
2017-10-04T17:20:45.585Z pid:81222 worker:0 INFO supervisor starting (pid 81222)
2017-10-04T17:20:45.593Z pid:81222 worker:0 INFO supervisor reporting metrics to `internal:`
2017-10-04T17:20:45.620Z pid:81222 worker:0 INFO supervisor size set to undefined
2017-10-04T17:20:45.998Z pid:81226 worker:1 [Wed Oct 4 13:20:45 2017] com.ibm.diagnostics.healthcenter.loader INFO: Node Application Metrics 3.1.0.201710011954 (Agent Core 3.2.2)
2017-10-04T17:20:46.059Z pid:81226 worker:1 [Wed Oct 4 13:20:46 2017] com.ibm.diagnostics.healthcenter.mqtt INFO: Connecting to broker localhost:1883

But the gateway never ends up starting and doesn't return an error.

This is using the latest from master and using a basic notes template loopback app 2.x

Proper contact

Hi colleagues!
Sorry for offtopic question, but i have not found any other way to address my question.
I work at consulting company and currently we are building the API management for our client in Russia. We are interested in microgateway solution but apart from IBM API connect package.

However we have some doubts regarding future of microgateway, customization capabilities and also looking for involvement of Strongloop expert to project for consulting.

We've tried to contact IBM here in Russia, but there is no strongloop expertise here :(
I've failed to find any email address or contact point on website and documentation..
Could you please help us with correct contact point so i will be able to address my questions.

Thank you in advance.

Single docker image for node.js and ngnix

The current API microgateway combines ngnix and node.js using a docker compose file, which results in two separate container instances. We should use a single docker image that runs both processes within a single container. This can be done using supervisord, and still leverage Dockerfile for building each Docker image (node.js & ngnix).

Microgateway without loopback

Is there a way to use microgateway without creating apis with loopback. We have a use case where we have multiple microservices in different languages. Can i consider microgateway for such scenario?

WIKI

Hi Team,
This looks really cool project, however do we have a good WIKI for this. I am trying to find how i can get started up and do other things, which seems to be missing from main description. Please help.

PreFlowError running API Connect v5.0.8.0 (apiconnect v2.7.28) Microgateway

When running on the Microgateway, calls to API endpoints fail with the message:
{"name":"PreFlowError","message":"unable to process the request"}

Create a new API with any hardcoded target URL in the Invoke properties.
If you run the Test option from the Designer, it gives the error mentioned above.

Flow engine test failing

Jenkins is reporting a test case failure in the flow engine (https://cis-jenkins.swg-devops.com/job/ds/job/microgateway~develop/202/console):

Error: 'hello' deepEqual 'hello world'

    1) test file monitor after change
AssertionError: 'hello' deepEqual 'hello world'
    at Test.<anonymous> (test/yaml.laptop.test.js:121:16)
    at Test.assert (node_modules/supertest/lib/test.js:156:6)
    at assert (node_modules/supertest/lib/test.js:127:12)
    at node_modules/supertest/lib/test.js:124:5
    at Test.Request.callback (node_modules/supertest/node_modules/superagent/lib/node/index.js:691:12)
    at IncomingMessage.<anonymous> (node_modules/supertest/node_modules/superagent/lib/node/index.js:922:12)
    at endReadableNT (_stream_readable.js:921:12)
    at node_modules/loopback/node_modules/loopback-context/node_modules/continuation-local-storage/node_modules/async-listener/glue.js:188:31
npm ERR! Test failed.  See above for more details.

The origin of this failure are the new tests associated with the config file change detection. It appears that one of the checked in files is being modified during the test, which shouldn't be done since it can lead to nondeterministic results. After running npm test for microgateway, I see the following change:

diff --git a/test/definitions/yaml/yaml_1.0.0.yaml b/test/definitions/yaml/yaml_1.0.0.yaml
index 4bd0913..6fd6e9c 100644
--- a/test/definitions/yaml/yaml_1.0.0.yaml
+++ b/test/definitions/yaml/yaml_1.0.0.yaml
@@ -39,7 +39,7 @@ x-ibm-configuration:
                     title: set-variable
                     actions:
                       - set: message.body
-                        value: hello
+                        value: hello world
                 - set-variable:
                     title: set-content-type
                     actions:

Intermittent "Socket is closed" error when calling microgateway after some time

The microgateway within API Connect topology is giving some errors intermittently after some time (about 10 hours) online. We put New Relic to monitor an API published on microgateway and it is capturing the following error: Socket is closed. This error repeats about 5 min.
We tried to increase memory for node.js process but the error persist.

Enhancing the REST Management API

Enhance the REST management API to allow additional flexibility to configure the API gateway without the need for the API Connect toolkit.

Datastore refactoring

The branch of https://github.com/strongloop/microgateway/tree/feature/refactor-datastore-2 is used for prototyping and benchmark. The benchmark data is described in https://github.ibm.com/apimesh/scrum-micro-gw/issues/247#issuecomment-1274499

Then I created 2 repos to do the real refactoring

The works are not completed and wrapped up in https://github.ibm.com/garytu/refactor-apic-microgateway/blob/master/TODO.md

Npm package: not able to perform the handshake with APIM

We are trying to use the Microgateway standalone for our project.

When I clone the github repo and do the Getting Started the code works fine.
When I install the Npm-Package and try to adapt the getting started code I am running into the following error

Error: not able to perform the handshake with APIM, error: Error: can not load default private key
    at Object.exports.handshakeWithAPIm (/Users/tones/Documents/Projekte/JB/sbc/microgateway-playground/node_modules/microgateway/utils/utils.js:192:14)
    at performHandshake (/Users/tones/Documents/Projekte/JB/sbc/microgateway-playground/node_modules/microgateway/lib/analytics.js:251:9)
    at sendAnalytics (/Users/tones/Documents/Projekte/JB/sbc/microgateway-playground/node_modules/microgateway/lib/analytics.js:49:3)
    at Object.<anonymous> (/Users/tones/Documents/Projekte/JB/sbc/microgateway-playground/node_modules/microgateway/lib/microgw.js:37:9)

Here is the js I am using to launch the app

'use strict';

process.env.CONFIG_DIR = __dirname + '/definitions/catapi';
process.env.NODE_ENV = 'production';
process.env.PORT = 3333;

const microgateway = require('./node_modules/microgateway/lib/microgw');

microgateway.start(process.env.PORT);

How connect Microgateway with and external Manager

we have an instance of Microgateway correctly connected with a Manager
following the instructions of IBM, but when we make petitions from Api
Manager, these not are arrived to microgateway.

WE have a microgateway instance with env.yaml and id_rsa.pub.
We have a Manager with a catalog pointed to microgateway with env and
id_rsa.
We have not collectives.

We know the manager and microgateway are correctly connected because we
can see that in logs.

NOw, whe we make an simple API from Developer Toolkit or Manager, for
example, we have not response (404) and in Microgateway logs have not
anything, so our petitions are not correctly connected.

Please, could you help us to connect correctly Manager->Microgateway??

Need authenticated username context variable

Currently the authenticated username for a request ends up in client.org.id for basicAuth or oauth.resource-owner for oAuth.

This makes identity propagation a challenge because there is no reasonable default for a policy like ltpa-generate. We can put $(client.org.id) but oAuth customers have to figure out the right value for their case. Identity propagation is nigh impossible for APIs that use basic and oAuth.

I propose a new context variable like request.whoami, that contains the authenticated name for the user, regardless of authentication scheme.

Multibyte characters not working with microgateway

When testing the microgateway with api designer, if calling an endpoint that returns json containing multibyte characters, the response is truncated, and the test tool displays:

SyntaxError: Unexpected end of JSON input

Looking in the browser trace we can see that the expected response which is:

{"array":[{"name": "á"}]}

is returned as:

{"array":[{"name":"á"}

missing the two closing square and curly brackets.

APAR: https://jazz609.hursley.ibm.com:9443/jazz/web/projects/APIM#action=com.ibm.team.workitem.viewWorkItem&id=56533

Fixed in microgateway version Target Release Stream Date Shrinkwrapped
1.6.3 5060 TBD
1.6.3 5070 TBD
1.6.3 master TBD

Is your team having problems checking code style?

If your team is having issues checking code style, try out this automated code style review tool here: stickler-ci.com. Connect your repository and create a new pull request or update an existing one to see it in action!

how to register new client-ids and subscription (with open source version)

Hi, I have downloaded the open source version of Microgateway and created a Swagger yaml with SecurityDefinitions

securityDefinitions:
  clientIdHeader:
    type: apiKey
    in: header
    name: X-IBM-Client-Id

I was able to call the API with following curl command
curl http://localhost:3000/trial/echo -H "X-IBM-Client-Id:default"

I wanted to find out how can I register more specific client ids with Microgateway?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.