Anypoint Platform Capabilities and an API-Led Connectivity Example
Nial Darbey shows an example scenario of how the Anypoint platform can be a vital component of a secure API-led architecture and the capabilities to securing the API.
Join the DZone community and get the full member experience.Join For Free
this is part 3 of my api security blog series. i will be showing an example scenario of how the anypoint platform can be a vital component of a secure api-led architecture and the capabilities to securing the api.
if you missed part 1 and part 2, here they are:
mule runtime security capabilities
the mule runtime addresses a broad set of security concerns with best practice solutions for transport and message level security. your api can be hosted by mule, exposed over https, and can facilitate tls client authentication. likewise, your api can make calls out to servers over https and issue client certificates as needed. keystores and trust stores are used to store tls certificates for these scenarios. messages that are sent to exchanges and queues on anypoint mq, mulesoft’s cloud messaging solution, can be encrypted. the mule runtime can also encrypt and decrypt messages, digitally sign them and verify the validity of incoming digital signatures. ip white and blacklisting are also available. with these capabilities, the mule runtime addresses the concerns of exposing highly available apis that authenticate and authorize incoming calls while guaranteeing message integrity and confidentiality.
message confidentiality on the mule runtime
mule https connector
an https listener can be configured with reference to a key store so that your api can authenticate itself to the app. when client authentication is demanded from the app, the listener can reference a trust store. similarly, when your api needs to interact with a server over https, you can use an https requester which references a key store to authenticate itself and a trust store for when digital certificates are not recognizable by the standard java jdk trust store (cacerts).
mule encryption processor
the mule message encryption processor can change the content of a message so that it becomes unreadable by unauthorized entities. mule can encrypt the entire payload of a message or specific parts of the payload, according to security requirements, using different encryption strategies.
dynamic data filtering with dataweave
for abac scenarios (see attribute based access control 1.3.2) you will need to filter the payloads that your api sends back to apps based on the degree of access determined either for the app or for the user. dataweave is mule’s data transformation engine which transforms between different mime-types using a simple expression language which is common across all data formats. the language can be used to remove and/or mask data fields in the payload, whatever the structure of the payload and the location of the field. the same expression can be stored in a data store and blindly executed by the engine at runtime. in this way, you can cater for dynamic transformation logic that you may not necessarily be able to configure at design time. rather, at runtime based on criteria decided at runtime, you can choose a transformation and apply it to the payload.
message integrity on the mule runtime
exposing your api over https guarantees that it has not been modified in transit. however, authentication and authorization of the request still need to take place.
mule security manager
central to authentication in mule is mule security manager. this is the bridge between a standard mule configuration and spring security beans.
the figure illustrates how credentials are passed and validated in the solution. the security manager, as you can see above, delegates to the authentication-manager. the authentication-manager uses the authentication provider to authenticate the set of credentials. the authentication-provider abstracts away from the details of the system used to do the authentication, whether it be in-memory, ldap- or db-based. the spring ldapauthenticationprovider uses the bindauthenticator in order to build a dn based on the credential username with which to bind directly to the ldap server.
mule secure token service oauth 2.0 provider
mule can act as an oauth2 provider, issuing tokens to registered apps, applying expiration periods to these tokens and associating them to user roles and fine-grained access control known in the oauth world as scopes. refresh tokens can also be issued and tokens can be invalidated. mule can subsequently validate incoming tokens against expiration periods, roles and scopes and thus grant or deny access to the flows in the application.
scopes represent broad levels of access to the mule flows. the provided access token must be sent in with each request and can be validated by mule to ensure it has not expired or been revoked and that it has the scopes that correspond to a particular flow. more fine-grained control can also be applied by comparing the role of the user for whom the token was issued with the allowed roles for the flow. the validate filter has a resourceownerroles attribute to specify these. the granularity of access control can be in either the grant or the role.
as we extend apis outside of our organization we may have to cater for applications belonging to partners. imagine we were to dynamically expose access to your api to a mobile application. we need only register this new client in your oauth 2.0 provider configuration.
mule digital signature processor
mule digital signature processor adds a digital signature to a message payload, or part of the payload, to prove the identity of the message’s sender. mule can also verify a signature on a message it receives to confirm the authenticity of the message’s sender.
mule credentials vault
mule credentials vault is for the encryption of properties which are referred to and decrypted by the mule application at deployment time. these properties are encrypted with a variety of algorithms and are completely hidden from anyone who does not have the key to the credentials vault. at deployment time, the key is passed to mule as a system property. this key should only be in the hands of authorized personnel.
api availability with mule ha clusters
a single mule server hosting your api is not enough to facilitate high availability. to achieve this, you need to host the same api on more than one mule runtime. with a load balancer in front of the api, you can guarantee that the api will always handle incoming requests as the load balancer chooses between those instances which are healthy.
reliability on mule can be achieved by clustering two or more instances of mule together which is easy using anypoint runtime manager. in this scenario, we configure the mule vm endpoint as a reliable handoff mechanism immediately after receiving the message. another flow processes the message from that same vm endpoint. if the mule node which receives the message from the vm goes down, then another mule node on the same cluster will pick up the same message. for reliable processing of messages between multiple apis you can use anypoint mq (see anypoint mq 4.2).
anypoint platform security capabilities
anypoint platform api solution
anypoint platform api solution is a fully multi-tenant application running on top of amazon web services (aws) and inside a vpc (cloud vpn). data, metrics, and metadata cannot be accessed across organizations.
although anypoint platform can manage and enforce the runtime security of your api, the api itself remains wherever you have it deployed. only the configuration of the policies, metadata about your api and analytics about the usage of your api is stored in anypoint platform.
api adaptability through policies on api manager
api management is a discipline which addresses the need to publish your api for consumption by known apps, registering those apps and provisioning them with their own id and secret identifiers, authorizing the apps to consume your api and adapting the apis to the potentially different security requirements across the apps.
the adaptability is addressed with what we call policies. these are encapsulations of the types of logic that usually recur across your apis. similar to how aspect-oriented programming worked, these logical bundles can be applied to or removed from running apis without affecting their lifecycle. security is a prime example of such logic. we explore security policies next.
secure communication between the mule runtime and api manager
using the mule runtime as an api gateway you can host your api. the mule runtime communicates constantly with anypoint api manager to retrieve policies and report back analytical information about the usage of your api. this communication is initiated by the mule runtime which authenticates itself with oauth 2.0 client credentials.
you configure the mule runtime with a client id and secret which is configured for your particular organization (or business group) in anypoint platform. the id and secret are used by the mule runtime to get an oauth 2.0 token to be used in subsequent calls. all calls are to a restful service which is accessible over https. the mule runtime is insulated from external network outages since it stores a local cache and can continue to operate even if the anypoint platform were to
become unavailable. regardless, mulesoft maintains an sla of 99.99% for anypoint platform api solution. anypoint platform is certified via whitehat sentinel.
we must return to our discussion about identity in the light of what anypoint platform has to offer in its suite of policies. some of the following policies are inherently dependent on a mechanism to verify incoming identity tokens. all of them address security concerns:
- client id enforcement : locks down your api for consumption only by a set of known clients.
- sla-based throttling : same as rate limiting, but exceeded calls are queued for the next time window.
- http basic authentication : authenticates using credentials which are configured in a security manager underlying this policy.
- ip blacklist and whitelist : denies or permits calls from only from ip addresses present in this list.
- json and xml threat protection : guarantee the safety of the messages passed to your api.
- sla-based rate limiting : provides different quality of service contracts to your known clients, 10 calls a minute for some, 100 calls a second for others, etc.
- mule oauth 2.0 access token enforcement : validates incoming tokens previously issued by anypoint oauth provider upon receipt of client id and secret.
- external access token enforcement : validates incoming tokens previously issued by pingfederate or open am oauth provider upon receipt of client id and secret.
the mule runtime stores the client ids and secrets of consuming apps in an identity store. when you register a new consuming app in the api portal, anypoint platform generates a new app id and secret and persists it. later, when any identity-related policy, like sla based throttling, is applied to your api, the mule runtime downloads the policy and also downloads the id and secret for every consuming app registered to consume your api.
thus, when the mule runtime injects the policy configuration into your api, it also provides access to a local embedded database of ids and secrets which the policy consults to verify the identity of the calling app. when you choose to integrate your anypoint organization with an external identity management technology like pingfederate, this assumes the role of administering
and persisting app id and secrets.
custom security policies
policies on the anypoint platform are snippets of mule configuration. as such, custom policies are very easily configurable and can be surfaced on the api manager portal as siblings to our out-of-the-box policies.
we have a number of custom policies published to anypoint exchange. these cover saml-based security use-cases such as the ability to validate incoming assertions or username tokens.
you can write your own policy to cover any area of logic that is pertinent to your api. for the abac scenarios that we described above, you might consider configuring a custom policy which accepts either a full dataweave expression in the api manager portal ui at policy application time. this can be executed at runtime on the response payload. (see dynamic data filtering with dataweave 3.1.3)
if you wish to protect your api with openid connect, you should consider writing a custom policy to validate incoming tokens against the authorization server.
this is a multi-tenant cloud messaging service offering persistent data storage across multiple data centers, ensuring that it can handle data center outages and have full disaster recovery. for compliance with your data at rest policies, anypoint mq allows you to encrypt all messages that arrive in either an exchange or a queue.
anypoint platform virtual private cloud
mule applications can be deployed either to your on-premises mule runtime or to our fully hosted and fully managed ipaas. in most scenarios, mule applications deployed to the ipaas will need to integrate with systems in your datacenter. in some cases, a hybrid architecture is adopted where mule applications deployed to the ipaas must integrate with mule applications deployed to mule runtime on-premises. either way, there is a need to establish a secure network between the
cloud and your data center.
virtual private cloud (vpc) enables you to connect your organization in anypoint platform to your corporate data centers – whether on-premises or in other clouds – as if they were all part of a single, private secured network. you can configure these networks at hardware or software levels.
vpc can be configured to use ipsec, tls (over openvpn) or amazon vpc peering to connect to your on-premises data centers. ipsec connections can be configured at the hardware level in addition to a software client. if you already use amazon, you should use vpc peering. otherwise, ipsec is, in general, the recommended solution for vpc to on-premises connectivity. it provides a standardized, secure way to make connections and integrates well with existing it infrastructure
such as routers and appliances.
anypoint platform user roles and permissions
in anypoint platform, users belong to an organization and have a set of roles and permissions. api versions and deployment environments are grouped under organizations (and optionally under business groups too), to access them you need to have an account that owns the necessary permissions and that belongs to its corresponding organization – and to the business group if the resource exists in one.
roles and permissions can be granted for accessing resources that exist in the master organization, or for resources that exist within a business group. a user that owns any role of a business group is implicitly granted membership in the business group.
each role contains a list of permissions that define what a user that holds that role can do with the specific resources it scopes. permissions can also be added at an individual user level, without the need for roles. there are two different types of permissions: those that are for api versions and those that are for ipaas environments.
keep in mind that api permissions are api version specific and ipaas permissions are environment specific – they grant you the ability to do something within a particular api version or environment, not the entire organization. the only exceptions to that rule are the roles api versions owner – which grants ownership of all apis and all of their versions within the corresponding business group – and portals viewer – which grants viewing access to all portals in the corresponding business group.
federated user access to anypoint platform
anypoint platform can be integrated with your organization’s external federated identity provider. opting to use federated identity management for anypoint platform gives your users single sign-on access and facilitates oauth security for apis using the same identity management system. anypoint platform supports saml 2.0 identity providers for user management, the following ones were successfully tested working with the platform:
you can set up your anypoint platform organization so that when a saml user belongs to certain groups, it will automatically grant certain equivalent roles in your anypoint platform organization.
anypoint platform security compliance
when anypoint api manager manages apis from the cloud, it stores only metadata about the apis and the apps which consume them. the apis can be deployed on the mule runtime either on-premises or in our fully hosted, fully managed ipaas solution. the extent to which anypoint platform is compliant with external audits is detailed in the whitepaper “anypoint platform cloud security and compliance.” we summarize them here:
the us government security standard that requires that compliant parties use only cryptographic security modules that have been certified by nist. mule can be configured to run in a fips 140-2 certified environment. note that mule does not run in fips security mode by default. there are two requirements:
have a certified cryptography module installed in your java environment.
adjust mule settings to run in fips security model.
ssae-16 soc 2: a regular audit report that states whether or not we are compliant with the policies we give our customers. we get these every january.
- pci dss level-1: pci compliance is a set of requirements designed to ensure that all companies that process, store or transmit credit card information maintain a secure environment. we complete an onsite assessment every september.
- hitrust: a common security framework (csf) designed to simplify compliance with technical controls derived from hipaa/hitech. put another way, it is a way for a service provider like mulesoft to show compliance with the relevant aspects of hipaa/hitech to its clients.
let us consider a hypothetical scenario: mythical retail have a chain of stores and deliver an e-commerce solution to their customers. one of their business objectives is to increase their revenue by 20% over the next 18 months. to achieve this goal they aim to improve customer loyalty by providing a compelling omnichannel digital experience.
this experience will allow customers to shop with ease wherever and whenever they want, receive appropriate recommendations and offers and see their current loyalty balance in real time. mythical retail wants a 360-degree view of their customers’ visits across all touch points. they aim to reward every customer interaction made online and in-store and have a clear view of their customers’ spending habits.
mythical retail have adopted mulesoft’s api-led connectivity approach to integration and see apis as strategic assets upon which they can execute digital initiatives. they have invested in clienteling software which can help their sales associates meet and register anonymous customers in-store and identify customers already registered. this software will also provide a mobile point-of-sale (pos) experience. with apis back-boning the clienteling solution as well as the customer’s web and mobile interactions, mythical retail can guarantee the uniformity of the customer experience across every touch point.
securing the customer transactions
figure 10 is an overview of the apis and servers needed to deliver her the capability to place an order on the phone. katie is a customer of mythical retail and likes to purchase online. she uses the iphone app to make orders.
katie must sign in to the app.
the app must authenticate itself on katie’s behalf and consume the my shopping api with the relevant degree of access control. only katie’s data must be accessible for this interaction.
all calls between experience, process and system apis must be protected.
the order fulfillment api orchestrates the orders api and the tokenization api. the latter is exposed by a third-party credit card processing company and delivers obfuscation functionality to mythical retail so that katie’s credit card details are never stored in their original form in the systems of record. the call to the tokenization api needs to be authenticated, signed and encrypted.
the order fulfillment api creates a business event which it publishes to an encrypted exchange on anypoint mq. the published data must be encrypted and the publication call must be signed, encrypted and authorized.
the customer api subscribes to the event on anypoint mq and is responsible for increasing katie’s loyalty points. the recommendations api is also registered to consume this event and gathers the details of the order to feed into future recommendations accordingly. likewise, the payment api subscribes to the event and finalizes the financial transaction. the shipping of orders is the responsibility of mythical retail's partner. their shipping api also subscribes to the same event. all of these subscriptions to anypoint mq must be signed, encrypted and authorized.
the iphone app utilizes the order tracking api, which is exposed by mythical retail's partner. the partner forms a separate security context and katie is not in their identity store. her claim must be recognizable in the shipping context.
interaction with the systems of record must be secured according to the requirements of each server.
anypoint platform as part of the security fabric for mythical retail
figure 11 is an overview of the apis used to deliver the loyalty experience to mythical retail’s customers. all the apis are deployed to mulesoft’s ipaas and managed by anypoint api manager . anypoint mq is used for messaging between the apis and pingfederate are used as identity provider, mfa provider, and openid connect/oauth provider. all http apis in this context are protected with https, and anypoint security policies are applied to each of the apis using anypoint api manager .
katie signs in to her iphone app.
part of the digital solution catering to katie’s experience is the my shopping api which delivers all the relevant capabilities to her iphone app. this api is protected with the pingfederate access token enforcement policy. to consume the my shopping api, the iphone app must interact with the pingfederate authorization server to request an openid connect token on her behalf. pingfederate authenticates her credentials against active directory. upon successful authentication, it generates a token and signs it (see digital signatures 2.1.1) before responding to the iphone app with the token. the app presents this token in a custom http header on every subsequent call to my shopping api.
all calls between experience, process, and system apis are protected with the client id enforcement policy. each api has an id and secret stored in mule credentials vault.
the calls to the tokenization api are protected with client cert authentication, and the payload passed to the api is encrypted and signed with mule encryption processor and mule digital signature processor respectively before sending.
publications to anypoint mq are protected with oauth 2.0 and https.
subscriptions to anypoint mq are protected with oauth 2.0 and https.
there is a federated trust between the identity providers in both security contexts for mythical retail and its shipping partner. both the sales associate’s app and katie’s app can call the order tracking api with the access token that they received from pingfederate. the order tracking api validates the token with openam, the identity provider of the shipping company. this can verify that the token was signed by the identity provider of mythical retail, which it trusts. the order tracking api accepts the invocation by the iphone app and responds accordingly.
sales associates use multi-factor authentication to sign in to their app. the app calls pingfederate oauth 2.0 authorization server to get a token which it passes to the shop assistant api.
interaction with the systems of record is secured in various forms according to the requirements of each server. tokens and username and password credentials are stored in the mule credentials vault.
apis are a strategic necessity to give your business the agility and speed needed to succeed in today’s business environment. but with the increasing cost of security breaches, senior it decision makers quite rightly want assurances that exposing their data via apis will not create undue risk. anypoint platform’s features provide the necessary assurances for the confidentiality, reliability, and availability of apis designed and managed on the platform. anypoint platform is trusted by industries needing the highest levels of security, including five of the top 12 global banks, two of the top five global insurance companies and top pharmaceutical and global healthcare companies. mulesoft has been recognized as a leader in multiple gartner magic quadrants and is trusted by organizations in over 60 countries, from emerging companies to global 500 corporations.
Published at DZone with permission of Nial Darbey, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.