CDAP provides several ways to authenticate a client’s identity:
Basic Authentication
The simplest way to identity a client is to authenticate against a realm file. To configure basic authentication add these properties to cdap-site.xml
:
Property | Value | Description |
---|---|---|
|
| Name of the class handling authentication |
|
| An absolute or relative path to the realm file |
The realm file is of the following format:
username: password[,rolename ...]
In CDAP Sandbox, the realm file can be specified as conf/realmfile
and placed with the cdap-site.xml
file. Note that it is not advisable to use this method of authentication. In production, we recommend using any of the other methods described below.
LDAP Authentication
You can configure CDAP to authenticate against an LDAP instance by adding these properties to cdap-site.xml
:
Property | Value | Description |
---|---|---|
|
| Name of the class handling authentication |
|
| Name of a class used as a custom login module for authentication |
|
| Set to |
|
| LDAP server host |
|
| LDAP server port |
|
| Distinguished Name of the root for user account entries in the LDAP directory |
|
| LDAP Object attribute for username when search by role DN |
|
| LDAP Object class used to store user entries |
In addition, you may configure these optional properties in cdap-site.xml
:
Property | Value | Description |
---|---|---|
|
| LDAP Object attribute containing the username |
|
| LDAP Object attribute containing the user password |
|
| Distinguished Name of the root of the LDAP tree to search for group memberships |
|
| LDAP Object attribute specifying the group name |
|
| LDAP Object attribute specifying the group members |
|
| LDAP Object class used to store group entries |
If the LDAP instance requires binding as a specific user, you may configure these optional properties in cdap-security.xml
:
Property | Value | Description |
---|---|---|
|
| The Distinguished Name used to bind to the LDAP server and search the directory |
|
| The password used to bind to the LDAP server |
To enable SSL between the authentication server and the LDAP instance, configure these properties in cdap-site.xml
:
Property | Default Value | Value | Description |
---|---|---|---|
|
|
| Set to |
|
|
| Set to |
LDAP with Active Directory
The following properties are listed as "optional" for LDAP but are required if you are using LDAP with Active Directory.
security.authentication.handler.userIdAttribute
security.authentication.handler.bindDn
security.authentication.handler.bindPassword
When using group based authentication, you will need the following properties to further filter the access.
security.authentication.handler.roleBaseDn
security.authentication.handler.roleMemberAttribute
security.authentication.handler.roleNameAttribute
security.authentication.handler.roleObjectClass
For Active Directory, the property security.authentication.handler.userBaseDn
should NOT include the group information. It should return the full list of users in the organization or domain. The group information should be included in the property security.authentication.handler.roleBaseDn
and will only allow access to these users.
JASPI Authentication
To authenticate a user using JASPI (Java Authentication Service Provider Interface) add these properties to cdap-site.xml
:
Property | Value | Description |
---|---|---|
|
| Name of the class handling authentication |
|
| Name of the class of the login module handling authentication |
In addition, any properties with the prefix security.authentication.handler.
, such as security.authentication.handler.hostname
, will be provided to the handler. These properties, stripped of the prefix, will be used to instantiate the javax.security.auth.login.Configuration
used by the LoginModule
.
Custom Authentication
To use a Custom Authentication mechanism, set the security.authentication.handlerClassName
in cdap-site.xml
with the custom handler's classname. Any properties set in either cdap-site.xml
or cdap-security.xml
and that are prefixed with security.authentication.handler.
are available through a Map<String, String>
object and can be used to configure the handler.
To make your custom handler class available to the authentication service, copy your packaged jar file (and any additional dependency jars) to the security/lib/
directory within your CDAP installation (typically under /opt/cdap
).
The Developer Manual Custom Authentication section shows how to create a Custom Authentication Mechanism.
Configuring Exemptions from Authentication
Sometimes you need to exempt certain URLs from authentication. For example, you may want to secure your entire application, except that you want to allow sending data to a stream by unauthenticated clients. For this, you can configure the CDAP Router to bypass the authentication for URLs that match a given regular expression, by adding this property in cdap-site.xml
:
Property | Value | Description |
---|---|---|
|
| Regular expression to match URLs that are exempt from authentication. |
For example, the following configuration in cdap-site.xml
will allow unauthenticated posting to all streams in the default namespace:
<property> <name>router.bypass.auth.regex</name> <value>/v3/namespaces/default/streams/[^/]+</value> </property>
This must be configured on every node that runs the CDAP Router.
Testing Perimeter Security
To ensure that you've configured security correctly, run these simple tests to verify that the security components are working as expected. See the CDAP Reference Manual: HTTP RESTful API for information on the conventions used for these examples. Note that if SSL is enabled for CDAP Servers, then the base URL used in these examples will use https
instead of http
.
After configuring CDAP as described above, start (or restart) CDAP and attempt to make a request:
GET /v3/apps
such as:
This should return a 401 Unauthorized
response with a list of authentication URIs in the response body. For example:
{"auth_uri":["http://localhost:10009/token"]}
Submit a username and password to one of the authentication URIs (
<auth-uri>
) to obtain anAccessToken
by submitting a Basic Authorization header with the username and password:GET <auth-uri> "Authorization: Basic <encoded_username_password_string>"
Using
curl
, assuming a CDAP authentication server at the URIlocalhost:10009
and that you have defined a username:password pair such ascdap:bigdata
in the realm file, you can usecurl
's-u
option to create the header:
This should return a
200 OK
response with theAccessToken
string in the response body (formatted to fit):{"access_token":"AghjZGFwAI7e8p65Uo7OpfG5UrD87psGQE0u0sFDoqxtacdRR5GxEb6bkTypP7mXdqvqqnLmfxOS", "token_type":"Bearer","expires_in":86400}
Reattempt the first command, but this time include the
access_token
as a header in the request:GET /v3/apps "Authorization: Bearer <access_token>"
such as (formatted to fit):
This should return a 200 OK
response.
Visiting the CDAP UI should redirect you to a login page that prompts for credentials. Entering the credentials that you have configured should let you work with the CDAP UI as normal.