Supporting Authentication
DevKit is compatible only with Studio 6 and Mule 3. To build Mule 4 connectors, see the Mule SDK documentation. |
Your service probably enforces some kind of authentication in order for applications to talk to your service on behalf of a user.
Note: DevKit lets you create more than one authentication method for your connector using multiple @ConnectionStrategy
annotations.
On the client side, many Mule applications need to manage multiple connections to the same target – for example, a developer of an application interacting with an e-commerce site on behalf of thousands of users need to efficiently manage the many connections that might be live at any given moment.
In DevKit, connection management and authentication support are closely related. While a general purpose connection management framework is available for most protocols, OAuth authentication handles connection management differently. If you are not familiar with OAuth, refer to Dancing with OAuth: Understanding How Authentication Works, a widely-cited and accessible overview of how the different flavors of OAuth work.
Prerequisites
This document assumes you have already created a connector project with at least some basic functionality, and are now ready to implement authentication on your connector.
Basic Authentication Using the Connection Management Framework
Anypoint DevKit makes it easy to add username and password connection management authentication functionality to connectors by applying the @ConnectionManagement
annotation at the @Connector
class level. Connection management with basic username and password authentication (most common) can be easily generalized to other non-OAuth protocols such as SAML, Kerberos, LDAP, NTLM, or to create a custom connection.
This framework provides the following benefits, with minimal effort on the part of the connector developer:
-
Transparent Multi-tenancy – A Mule application can open many connections to a single target, using different credentials to connect on behalf of many users simultaneously.
-
Connection Pooling – Automated management of a pool of instances of the connector class, to manage connection resources effectively.
-
Exceptions - The ability to automatically invalidate connections on exceptions, and to reconnect as needed.
For more information, see the Connection Management guide.
HTTP Basic Authentication
DevKit provides support for HTTP Authentication as described in RFC-2617. You can implement HTTP Authentication as a @ConnectionStrategy
in your @Connector
class, and DevKit transparently manages the authentication for your requests.
For more information, see the HTTP Basic Authentication guide.
OAuth V1
Anypoint DevKit makes the implementation of the OAuth V1 on your connector rather straightforward. By simply implementing OAuth V1 in your @Connector
class, DevKit manages all of the requests to the target service.
For more information, see the OAuth V1 guide.
OAuth V2
DevKit support for OAuth V2 includes its own form of connection management support. Implement OAuth2 in your @Connector
class, and DevKit transparently manages multiple connections, including maintaining access tokens for multiple connections to the target service.
For more information, see the OAuth V2 guide.
Connection Management with Other Authentication Schemes
Anypoint DevKit makes the connection management framework available, providing credentials management for multiple simultaneous connections, pooling connection instances to allow for efficient connection re-use, and providing automated handling for invalidating lost connections and reconnecting when needed.
Connection Management describes how to apply connection management to your connector using annotations to @Connector
class methods. The example describes using the annotations with basic username/password authentication, but the same methods apply for other methods as well.
You can also apply connection management to connectors that use no authentication at all. For details on implementing connection management in a connector with no authentication, see the Connector to SOAP Service via CXF Client Example.
See Also
-
Connection Management (username and password authentication)
-
Return to Anypoint Connector Development