Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

API Management Reimagined: Authentication, Authorization, and Audit

DZone 's Guide to

API Management Reimagined: Authentication, Authorization, and Audit

Read on for a great discussion of an open source platform that makes it easier to manage and secure your API gateways.

· Microservices Zone ·
Free Resource

API Gateways provide a set of features that enable secure access to its API endpoints. These features fall under three broad categories:

  • Authentication: Who is allowed to access the API Gateway at all? (Access Control)
  • Authorization: Who is allowed to perform a certain operation using exposed APIs? (Permissions/Privileges)
  • Audit: Capturing sufficient information for each client request to be able to detect and possibly prevent malicious activity.

An administrator of any API Gateway platform needs to be aware of these capabilities, which could be a bit different compared to securing web sites and databases.

There are a few important considerations beyond what most administrators typically manage.

How can you define microservices and serverless functions and expose them as APIs? What about industry best practices for API Management?

Defining microservices and serverless functions and exposing them as APIs is just the beginning and it can take time to do it right. For developers, industry standard authentication, authorization, and audit capabilities also come at a price: time, scale, and resources. It takes an experienced dev to ensure that these practices are followed throughout the entire software development lifecycle.

API Management With Express Serverless Platform

Express Serverless Platform is a microservices and serverless platform for APIs. It is unique in that it allows us to design and deploy microservices.

The platform allows us to expose both model-based microservices and serverless functions through REST APIs, using an API Gateway (the open source Express Gateway ).

How Does This Help Developers and DevOps Teams With API Management?

The Express Serverless Platform is unique in that it brings together tooling to develop microservices and one-click deployment to a scalable Kubernetes infrastructure. This accelerates development and significantly increases developer productivity. The tooling environment is actually browser-based and known as Canvas.

Let's focus some attention on the API Management component, that is, Express Gateway. However, all configurations on Express Gateway, including those relevant for authentication, authorization, and audit, can be applied through Canvas.

Simple and Straight Forward AAA Features in Express Gateway

Express Gateway supports three industry standard mechanisms for client authentication: basic authentication (username/password), key-based authentication (using API access Keys), and OAuth2 (for granting access to APIs from third-party applications).

Authorization mechanisms in Express Gateway are simple and innovative. For each API endpoint, the administrator can specify one or more scope(s). A scope is just like a tag indicating the type of users/applications that may need access to this API endpoint. Correspondingly, users granted access to the API gateway may be assigned one or more scopes. A user can retrieve information from an API only if they are assigned a matching scope.

This is a fine-grained authorization mechanism because:

  1. Each API endpoint can be assigned a different set of scope(s).
  2. Each type of operation on a given API endpoint can be assigned a different set of scope(s).

Audit capabilities in Express Gateway are based upon customizable logging options. The administrator can include a customizable log message for each pipeline that will apply to each incoming request on that pipeline. By including important request parameters like an IP address, user id, request URL, etc., each request can be analyzed for malicious activities.

Express Gateway allows us to create API endpoints and then control how client requests for any given endpoint are handled. This is achieved by defining a pipeline for each endpoint and placing a set of 'policies' in a specific order in the pipeline. Express Gateway is built on top of the Node.js Express framework, and the policies are akin to Express.js middleware. Authentication is set up by adding one of the three policies: 'basic-auth,' 'key-auth,' or 'oauth' to a pipeline. Audit logs can be enabled by adding the 'log' policy. Authorization (scopes) is an attribute of an API endpoint and is not implemented as a policy.

An Enterprise Use Case for the Express Serverless Platform

First, we will work with a simple API endpoint that simply supplies the Coordinated Universal Time (UTC) now.

To implement this API endpoint, we will make use of the existing URL, http://worldclockapi.com/api/json/utc/now, instead of reinventing the wheel. When we access this URL, we receive a response body containing the UTC time in JSON format:

{"$id":"1","currentDateTime":"2018-09-25T10:25Z","utcOffset":"00:00:00","isDayLightSavingsTime":false,"dayOfTheWeek":"Tuesday","timeZoneName":"UTC","currentFileTime":131823447213150424,"ordinalDate":"2018-268","serviceResponse":null}

Therefore, our job will be to create an API endpoint on the Express Serverless Platform, that wraps around the above URL. This API endpoint will respond with the current Universal Time. Furthermore, we will enforce authentication, authorization, and audit on this API endpoint by applying suitable configuration settings.

In a more realistic scenario, an organization using the Express Serverless Platform will build a service on its own that it wants to expose externally as an API. But our goal is to focus on the traffic management feature. So we will try not to code a new service from scratch. Stay tuned, because in our next post we'll dive head-first into technical detail on how to get this done.

If you're interested in more of these topics, join the live discussion on Twitter (@lunchbadger) or (@express_gateway).

Next Post

LunchBadger Platform is now Express Serverless Platform

Topics:
microservices ,api gateway ,api management ,microservice management

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}