What Is API Gateway Authentication
What Is API Gateway Authentication
While the basic premise of API gateway authentication is easy enough to grasp, this
guide offers a more nuanced understanding of the concept.
The first role of an API gateway is to managing API request traffic as a single
point of entry. The API gateway sits in front of a group of APIs exposed by various
apps and microservices. Applications and clients that want to use those APIs simply
need to interact with the API gateway, which directs the calls and requests to the
appropriate APIs and returns the responses. If you’re developing an application or
enterprise architecture that consists of multiple apps and microservices, an API
gateway minimizes your coding burden while giving your system immediate access to a
wide variety of services, databases, and applications.
(1) Safeguards against mistakes, data breaches, malicious hacks, and other access-
related problems by ensuring that only the right consumers have access to the right
information and system controls.
(2) Allows you to limit the amount of data that gets transmitted to prevent attacks
and/or prevent one API consumer from overburdening the system.
(3) Allows you to cut off access to a service after a subscription expires.
(4) Lets you control what happens after a failed authentication request. For
example, you can block the failed request and send back an error code, or you can
allow limited access to unauthenticated users.
Since an API gives access to potentially sensitive information and app controls,
it’s important to secure the API to ensure that only the right consumers (users,
clients, applications) have the right levels of access to the API. This is where
API authentication/authorization comes into play.
First, the API gateway can bypass the need to develop authentication from scratch.
The primary advantage of API gateway authentication is that it eliminates the need
to develop an authentication solution from scratch because you can quickly
incorporate the API gateway’s native authentication tools to secure access to the
system that you used the API gateway to build.
Basic Authentication
Basic API Authentication allows API consumers to access services with a preassigned
username and password. Basic Authentication checks the username/password
combination against the Authorization and Proxy-Authorization request headers,
which hold the credentials required to authenticate the user with the server or
proxy server. As the easiest way to password-protect a web application, you can use
DreamFactory to implement Basic Authentication for all HTTP and HTTPS API requests.
LDAP Authentication
As a vendor-neutral directory services protocol, LDAP (Lightweight Directory Access
Protocol) is one of the most common user authentication frameworks used in
enterprise architecture. Like the other authentication strategies on this list,
integrating LDAP authentication into a DreamFactory-built application is as simple
as cutting and pasting a few lines of code. Simply configure the solution in
DreamFactory’s web-based administration console, insert the code, and DreamFactory
manages the rest.
OpenID Connect
OpenID Connect is a wrapper around OAuth 2.0 that allows you to quickly incorporate
any external OAuth2.0/OpenID Connect authentication service into your DreamFactory-
built applications. As a native DreamFactory integration, OpenID Connect makes it
easy to integrate role-service-access, live API documentation, and other
integration features into your applications. Once configured, DreamFactory stores
all of the configuration settings within a secure database instance.
DreamFactory’s OpenID Connect service allows you to integrate a wide range of OAuth
2.0 access control services (like Okta, Facebook, Google, Twitter, Active
Directory, and more). DreamFactory and OAuth 2.0 also allow you to issue temporary
access tokens that eventually expire and need to be renewed.
Again, with DreamFactory’s web-based admin console, you can quickly configure these
and other authentication strategies. Once configured, all you have to do is cut and
paste a few lines of code to integrate the authentication solution into your
DreamFactory-supported application.
Next, you’ll configure the consent screen that users see when they complete the
authentication/authorization process. Select ‘Configure consent screen,’ and
complete the form. Lastly, you’ll indicate the ‘application type’ and
‘restrictions.’ Note that the ‘restrictions’ field asks for an authorized
JavaScript origin URL and/or authorized redirect URI. This is required because it’s
the destination where Google sends the authorization code after authentication.
This code is received by your application, then forwarded to DreamFactory, which
generates the JSON web token (JWT) for the session.
Now that you’ve created your OAuth 2.0 Google credentials, you’ll save the changes
and set up the OpenID Connect service on DreamFactory.
(2) Configure the OpenID Connect Service in DreamFactory
Log into the DreamFactory admin console. Go to the ‘Services’ tab and click
‘Create’ on the left sidebar. Find the ‘Service Type’ dropdown. Choose ‘OAuth,’ and
then choose OpenID Connect. Visit this link for more information about the fields
on this form.
Next, you’ll select the “Config” tab, complete the service configuration form, and
save your changes. When configuring the service, DreamFactory allows you to
authorize API consumers, assign credentials to specific consumers, and limit access
to anonymous consumers.
This completes the process of creating your new authentication service. Visit this
link for more information about the fields on this form.
(3) Create a Script that Generates the JSON Web Token (JWT) for Each Session
The next step involves creating a script that will complete the OAuth callback for
a new session and generate a JSON web token (JWT) for the session. JWT is an open
standard that allows you to securely transmit data as a JSON object. Since it is
digitally signed, JWT information is verified and trusted.
Here you’ll refer to the redirection URI that you used when configuring the OpenID
credentials on Google (referenced above).
This URI endpoint intercepts the Oauth callback parameters that get forwarded to
DreamFactory, and it generates the JWT session token. On this page, you’ll find a
sample PHP script that manages the process of returning the JSON object with the
necessary JWT and user profile information (name, email, etc.). Adding a similar
script to your application code lets your application retrieve the JWT that is
defined in the session_token attribute. This JWT will be sent with subsequent API
requests to authenticate/authorize the consumer.
That’s it! Your third-party OpenID Connect authentication service is ready to use!
If you’d like to know more about DreamFactory, contact our team and schedule a free
hosted trial of DreamFactory now!
Enhancing user convenience, especially if they already have an account with the
integrated third-party service.
Handling scalability.