| Back | Next | Contents | Cams Administrator's Guide |
Cams uses an implementation of the Java Authentication and Authorization Service (JAAS) to provide user authentication services. JAAS authentication defines a Java version of the Pluggable Authentication Module (PAM) framework, which permits applications to remain independent from underlying authentication technologies. By using a PAM framework, the Cams JAAS implementation enables the use of new or updated authentication technologies without requiring internal modification to Cams. Cams does not use the authorization features of JAAS.
This document describes how to configure Cams login modules, which are standard JAAS components used to authenticate users and obtain their roles. See also the Login Configuration Tag Reference for more information on all the XML tags used in the login-config.xml file.
NOTE: If an existing Cams login module does not meet your needs, Programming Cams JAAS Login Modules explains how to create a new Cams login module. The source code for Cams login modules described in this document is included with the documentation download.
Each Cams security domain must have a login configuration defined in login-config.xml. The login-config.xml file contains both required and optional data specific to login modules. One or more login module configurations can be specified by nesting values within one or more <login-config-entry name="name"> open and close tags, as you can see in the sample login-config.xml file.
NOTE: The default http value for the name parameter should be used for most sites. This value is required for Cams authentication to reference a specific login configuration to use. In most cases, one login configuration entry is sufficient. However, you can optionally specify multiple login configuration entries, each with a unique name. You could then specify that distinct Cams web agents use different login configuration entries by setting the cams.loginconfig.entry value in cams-webagent.conf. For example, if you have distinct web servers for your extranet and intranet, you could use one login configuration entry to authenticate external users on the extranet site and the other to authenticate internal users on the intranet site.
Within the <login-config-entry> open and close tags, you specify how login modules will be used. The parameters className and flag are required for each login module entry as show in example 1. The class name specifies the fully qualified location of the Java class for the specified login module implementation. The class names for the login modules supplied with Cams are:
<login-config-entry name="http"> <login-module-entry className="com.cafesoft.cams.auth.login.module.XmlLoginModule" flag="REQUIRED"> <options> <option name="serviceId" value="cams-user-repository"/> <option name="debug" value="true"/> </options> </login-module-entry> </login-config-entry> |
A <login-config-entry> can have one or more <login-module-entry>. The flag parameter determines the behavior when multiple login modules are used by specifying whether a module is required, requisite, sufficient or optional.
Specifying more than one <login-module-entry> for a single <login-config-entry> configuration is also known as stacking. The interaction between flags when stacking can be complicated so you should keep these configurations as simple as possible. In most cases, you'll specify a single login module with flag value set to REQUIRED.
The optional values are specific to each login module and are explained in the sections below. All options tags require name and value parameters. For example, all Cams login modules include a debug option to toggle debug on and off. The tag is <option name="debug" value="true"/> with true or false as the value.
NOTE: The Jetty test web server that is included with the Cams policy server provides login module configurators to test login module values and generate the associated XML. Login module configurators are provided for Active Directory, LDAP and SQL databases. We highly recommend that you start the Jetty test server and browse to:
http://localhost:8080/
to access these configurators. Once there, you'll find complete instructions on how to proceed. By default, the Jetty test server is configured to run without modification. However, if you changed configuration values for your Cams policy server, you may have to change any associated values found in CAMS_HOME/jetty/etc/cams-webagent.conf.
The login modules included with Cams are:
You use this login module to access authentication credentials and group membership information stored in Microsoft Active Directory. Like any other directory servers, Active Directory can be configured to support virtually any schema. However, Microsoft has a strictly defined, proprietary schema that most sites use. Also, your schema will be different if migrated your from a Windows NT domain or started fresh with Active Directory. The Cams Active Directory login module provides support for the default Active Directory schema as shown in example 2, but is flexible to handle variations.
| Tree Structure | Active Directory Objects |
|---|---|
|
cn=Users,dc=company,dc=com
|
Users:
Groups:
|
The Active Directory login module expects to find user values stored in specific attributes to successfully perform:
Example 3 shows the sample settings for the Active Directory login module.
<login-module-entry |
The Active Directory login module options values are:
You use the JDBC login module to access authentication credentials stored in relational databases such as Oracle, DB2, Microsoft SQL, MySQL, Sybase or any other database with a JDBC driver. The JDBC login module is flexible to support a wide range of schema without modification. Example 4 shows a JDBC login module configuration using the Sample User Database schema and values with the open source HSQLDB relational database.
NOTE: Though valid and recommended for initial testing, configuring a JDBC login module to handle database connections as show in Example 4 requires opening and closing a database connection for each authentication request. Because this is an expensive use of resources, we recommend that you configure JDBC database connection pooling for production environments.
<login-module-entry
className="com.cafesoft.cams.auth.login.module.JdbcLoginModule"
flag="REQUIRED">
<options>
<option name="debug" value="false"/>
<option name="jdbcDriver" value="org.hsqldb.jdbcDriver"/>
<option name="jdbcUrl" value="jdbc:hsqldb:hsql://localhost/"/>
<option name="jdbcUsername" value="sa"/>
<option name="jdbcPassword" value=""/>
<option name="userPreparedStatement"
value="SELECT PASSWORD FROM USERS WHERE USER_NAME = ? "/>
<option name="passwordColumn" value="PASSWORD"/>
<option name="rolePreparedStatement"
value="SELECT ROLES.ROLE_NAME FROM USERS, ROLES, USER_ROLES
WHERE USERS.USER_NAME = ?
AND USERS.USER_ID = USER_ROLES.USER_ID_FK
AND USER_ROLES.ROLE_ID_FK = ROLES.ROLE_ID"/>
<option name="roleColumn" value="ROLE_NAME"/>
</options>
</login-module-entry>
|
Example 4 - JDBC login module configuration for the sample user database
The JDBC login module option values are (required unless otherwise specified):
The JDBC login module supports password digests using Unix Crypt, MD5, and SHA, SMD5 and SSHA algorithms. The algorithm is specified within curly brackets in a label that precedes a base 64 encoding of the hashed password (e.g. {CRYPT}, {MD5}, {SHA}, {SMD5}, {SSHA}), which may also include salt bytes.
NOTE: You must obtain and install the JDBC driver supplied by your database vendor. To use any JDBC driver with Cams, copy the driver's jar file(s) into the CAMS_HOME/lib directory. For example, if you want to use MySQL with the standard J2SDK installation, you would copy mysql-connector-java-3.0.15-ga-bin.jar to CAMS_HOME/lib. See your database vendor documentation for more information.
JDBC connection pooling is the recommended way to configure authentication with a relational database in production environments. To use JDBC connection pooling from the JDBC login module, you must:
<login-module-entry
className="com.cafesoft.cams.auth.login.module.JdbcLoginModule"
flag="REQUIRED">
<options>
<option name="debug" value="false"/>
<option name="jdbcDriver" value="org.apache.commons.dbcp.PoolingDriver"/>
<option name="jdbcUrl" value="jdbc:apache:commons:dbcp:example-jdbc-pool"/>
<option name="userPreparedStatement"
value="SELECT PASSWORD FROM USERS WHERE USERNAME = ? "/>
<option name="passwordColumn" value="PASSWORD"/>
<option name="rolePreparedStatement"
value="SELECT ROLE FROM USER_ROLES WHERE USERNAME = ? "/>
<option name="roleColumn" value="ROLE"/>
</options>
</login-module-entry>
|
Example 5 - Using pooled JDBC connections with the JDBC login module
The JDBC login module option values are configured as shown in Example 4 with the following differences:
You use the LDAP login module to access authentication credentials store in the SunOne Directory Server, OpenLDAP and any other LDAPv3 compliant user directory. LDAP directory schema will vary from site to site. This login module is flexible to support many variations of X.500 and DNS style schemas similar to those shown in example 6.
| Tree Structure | LDAP Objects |
|---|---|
|
dc=company,dc=com
|
Users:
Groups:
|
The LDAP login module expects a schema similar to the one specified in example 6 to successfully perform:
Your LDAP server may use a schema different from the one specified above. Also, your LDAP server's access control settings may effect integration with Cams. For example, for the LDAP login module to return role information successfully, the LDAP server access control policy must allow a bound user to search the group tree to obtain role membership data.
The recommended approach is to use the LDAP login module configurator, which is included with the Cams Jetty test web server. This tool enables you to quickly configure and test the required options and generate the XML once you have the correct settings. After you acheive success, you can enter the values in login-module.xml and test with Cams. For example, searches such as:
base distinguished name: ou=people,dc=company,dc=com
filter: (ou=myUserName,ou=people,dc=company,dc=com)
scope: one
attributes: userPassword
can be used to determine if the userPassword value can be returned for a user. If your search tool supports sepecification of calling the compare method, you can use similar values with it to determine if a compare can be done. Searches such as:
base distinguished name: ou=groups,dc=company,dc=com
filter: (uniqueMember=uid=myUserName,dc=company,dc=com)
scope: one
attributes: cn
can be used to determine the roles.
Example 7 shows the sample entry for the LDAP login module.
<login-module-entry className="com.cafesoft.cams.auth.login.module.LdapLoginModule" flag="REQUIRED"> <options> <option name="debug" value="false"/> <option name="host" value="host.company.com"/> |
Example 7 - Cams LDAP login module login-config.xml sample
The required LDAP login module options values are:
Example 10 shows the sample entry for the XML login module. You use the XML login module to access authentication credentials stored in a cams-users.xml directory, found by default in each security domain. This user directory is supplied with Cams for convenience and system-level use (e.g. Cams web agent authentication) and is not recommend for production sites with a large number of users.
The XML login module does not process the contents of the cams-users.xml file directly. Instead, it makes use of a Cams service, which loads the XML file and reloads it when modifications are made. This Cams service (defined in security-domain.xml) caches username, password, and role information in memory, greatly improving the efficiency of authentication making it ideal for small user communities that don't change and for authenticating Cams web agents. The path to Cams user directory and the XML handler that knows how to parse the file are specified in the service manager configuration.
<!-- In login-config.xml, register a cams-users.xml directory service --> <login-config-entry> ... <login-module-entry className="com.cafesoft.cams.auth.login.module.XmlLoginModule" flag="REQUIRED"> <options> <option name="debug" value="false"/> <option name="serviceId" value="cams-user-repository"/> </options> </login-module-entry> ... <login-config-entry> |
Example 10 - Sample Cams XML login module as defined in login-config.xml and by the associated security-domain.xml service
The required XML login module options values are:
The XML login module supports password digests using Unix Crypt, MD5, and SHA, SMD5, and SSHA. The algorithm is specified within curly brackets in a label that precedes a base 64 encoding of the hashed password (e.g., {CRYPT}, {MD5}, {SHA}, {SMD5}, {SSHA}), which may also include salt bytes. See password digests for more information.
See Security Domain Configuration - Cams XML User Repository Service for information on how to configure services.
Cams uses callback handlers to pass login credentials from the calling application to the login module. In the web or HTTP space, most webapps use form authentication, typically requesting a username and password for authentication. In this case you can use the Cams NamePasswordCallbackHandler, which takes a username and password as input and provides them to the login module.
To specify a callback handler for use with a Cams login module, each login-config-entry includes the following required tag:
<callback-handler
classname="com.cafesoft.cams.auth.callback.NamePasswordCallbackHandler"/>
The Cams JDBC, LDAP and XML login modules all require the callback handler to supply a username and password. These login modules work well with the NamePasswordCallbackHandler. However, Cams has a pluggable callback framework to associate custom callback handlers with login modules. If the NamePasswordCallbackHandler does not meet your needs, see Cams Callback Handlers to understand how to create a new one. For example, you may want to specify a third authentication credential in addition to username and password, such as the last four digits of a user's social security number or a pin.
Login parameters are optional tags that help define the login configuration.
As shown in example 11, the Cams policy server sends the camsLoginUrl
value to a Cams web agent when an access check requires user authentication.
The Cams web agent then redirects the user's browser to URL indicated by camsLoginUrl,
which references an HTML form that:
The value of camsLoginUrl can be an
absolute or relative URL. Any web server with a Cams web agent can be used provided
the web or application server is in the same Internet domain as the web or application
server that made the original request.
<login-parameters> <login-parameter name="camsLoginUrl" value="/cams/login.jsp"/> </login-parameters> |
Example 11 - Cams login parameters
NOTE: You must change camsLoginUrl to reference a login page deployed at your site. For example, IIS sites might use the default /cams/login.asp supplied with the Cams IIS web agent and Apache sites might use the default /cgi-bin/cams-login.sh supplied with the Apache 1.3/2.0 web agents. Cams login pages are provided as samples that contain the required parameters. You can customize them or create new login pages as required.
Login modules throw exceptions for various failure conditions, which you can use to provide users information on why the request failed. You can customize messages associated with these standard JAAS login exception classes used by Cams login module implementations:
In addition, login module developers are free to create new login exception subclasses to convey appropriate context for why an authentication request has failed. Cams provides a way for each security domain to define customized login exception messages based on the class or subclass of the login exception that may be thrown by a login module. Standard login exception messages are provided in a file named login-exception.properties in each security domain's home directory.
Example 12 shows the messages defined for the login exception class and standard subclasses.
#
#--- Customized LoginException error messages.
#
javax.security.auth.login.FailedLoginException.message=\
"Authentication failed, invalid credentials"
#
#--- Indicates that a user account has expired.
#
javax.security.auth.login.AccountExpiredException.message=\
"Authentication failed, account expired"
#
#--- Indicates that a credential (e.g. password) associated with a user
#--- account has expired.
#
javax.security.auth.login.CredentialExpiredException.message=\
"Authentication failed, credentials expired"
#
#--- Generic LoginException, which is returned if the LoginModule throws
#--- javax.security.auth.login.LoginException or a subclass-specific
#--- message is not defined.
#
javax.security.auth.login.LoginException.message=\
"Authentication failed, authentication error"
|
Example 12 - Standard Cams login exception messages defined in login-exception.properties
The actual message returned when a login exception (or a subclass of login exception) is thrown by a login module is as follows:
To support a context-sensitive message for a subclass of login exception which is not included in the login-exception.properties, simply add a line of the form:
<LoginException subclass name>.message=Message Text
Example 13 shows a custom exception used by a fictitious login module that records previous failed login attempts and does not permit additional login attempts for a given period.
#
#--- Indicates the authentication failed due to 3 previous failed login attempts.
#
example.auth.login.MultipleFailedLoginsException.message=\
"Authentication failed, 3 or more previous login failures. Try again in 2 minutes."
|
Example 13 - Adding a new login exception message to login-exception.properties
Password digests are one-way hashes that securely store a password using secure, industry standard hashing algorithms. Cams login modules that retrieve the password value from a database implement support for Cams to compare digests within the login module. In this case, when a user supplies a password for authentication the Cams login module determines how the password in the user directory was hashed and then uses the same formula to hash the password to be validated. If the resulting digest is the same as the digest stored in the user directory, the user is authenticated.
Cams provides supports for Unix Crypt, SHA (with and without salt) and MD5 (with and without salt) digests. Typically, encryption authorities today recommend use of the SHA algorithm with random salt bytes. For more information on how Cams implements support of digest, see the Password Digests appendix and the online password digests web application.
Cams provides an optional convenience feature that enables returning web site users to automatically and transparently login if they successfully authenticated on a previous visit and chose to be remembered. This feature is facilitated by sending a persistent AUTOLOGIN cookie containing encrypted user credentials to the user's browser on successful authentication. When the user returns to your Cams enabled site with autologin enabled and an AUTOLOGIN cookie is presented, Cams web agents will proactively and transparently try to authenticate the user. If the authentication is successful, a normal Cams memory resident session cookie is sent to the user's browser.
The Cams AUTOLOGIN feature is considered a user convenience that enables transparent authentication in the case that a previous Cams session expired due to inactivity. If a user explicitly logs out, then the Cams AUTOLOGIN cookie is removed by the Cams web agent that intercepts the logout request and the user will be required to provide their login credentials the next time he visits your Cams-enabled site.
The following steps are required to implement Cams automatic HTTP login:
More details for each of these steps is provided below.
The option to perform Cams automatic HTTP login for future authentications is normally presented to a user with a HTML checkbox on a Cams login page. You can also add a hidden field to the login page that automatically selects this feature for all authenticating users, but it is generally encouraged to allow the user to select this feature as he may have security concerns related to persistent HTTP cookies that store encrypted passwords.
Example 14 shows the HTML that adds a Remember Me checkbox to a Cams login page. The check box must be named cams_cb_autologin_flag and must be added within the HTML form containing the other HTML input fields containing Cams callback values.
... <input type="checkbox" name="cams_cb_autologin_flag" value="true"/> Remember Me ... |
Example 14 - Adding the cams_cb_autologin_flag checkbox to a Cams login page
If the user selects this checkbox then posts the form to a Cams-enabled web site, the parameter cams_cb_autologin_flag=true will be sent. This will inform Cams that the user has opted to use Cams automatic HTTP login on future visits if the current authentication request succeeds.Cams web agents enable automatic HTTP user login by setting the cams.autologin.enabled=true property in cams-webagent.conf as shown in Example 15.
# |
Example 15 - Enabling Cams HTTP autologin in cams-webagent.conf
The Cams policy server includes a component that must be uncommented and enabled in security-domain.xml to support Cams automatic HTTP login. When enabled and during normal (non-automatic) authentication, this component is responsible for:
When automatic login is requested by a Cams web agent by presenting the Cams AUTOLOGIN cookie value as an authentication token, this component is responsible for:
If the encrypted AUTOLOGIN authentication token cannot be successfully decrypted because the encryption algorithm, secret key or other security parameters have been changed since the original AUTOLOGIN cookie was created, then callback parameters cannot be added to the authentication request. In this case, authentication will fail and the Cams web agent will ultimately tell the user's browser to delete the Cams AUTOLOGIN cookie.
Example 16 shows the Cams automatic HTTP login authentication valve component that can be configured within any security-domain.xml file. If you're using the standard security-domain.xml file that ships with the system security domain, this valve is already available, but commented out and disabled. Add or uncomment this valve in the context of the security-domain.xml shown in Example 16.
... <auth-pipeline className="com.cafesoft.security.engine.auth.StandardAuthPipeline"> <!-- The Cams AutoLoginAuthValve --> |
Example 16 - Enabling the Cams Auto Login authentication valve
After adding or uncommenting the valve, you must configure its parameters as described below. Examples are not provided so that you won't be tempted to copy published values that could make encrypted AUTOLOGIN values vulnerable to attack.
NOTE: Use the scripts provided at CAMS_HOME/bin/camsSecretKeyGen.bat/sh or the web application in the Cams policy server's Jetty web server to select an encryption algorithm and generate a random encryption/decryption key and initialization vector.
A callback handler must be configured in login-config.xml for each security domain where Cams automatic HTTP login is enabled. The AutoLoginNamePasswordCallbackHandler provides support for the username, password and autologin_flag callback parameters that are sent from Cams login pages containing fields named:
Simply comment out the existing NamePasswordCallbackHandler and add the AutoLoginNamePasswordCallbackHandler in login-config.xml for each security domain as shown in Example 17.
... <!-- Register the username/password callback handler <callback-handler className="com.cafesoft.cams.auth.callback.NamePasswordCallbackHandler"/> --> <!-- The Cams AutoLoginNamePasswordCallbackHandler --> <callback-handler className="com.cafesoft.cams.auth.callback.AutoLoginNamePasswordCallbackHandler"/> ... |
Example 17 - Configuring the Cams automatic HTTP login callback handler in login-config.xml
After configuring Cams automatic HTTP login options and components, remember to restart the Cams policy server and the web or application servers containing your Cams web agents.
To test automatic login, just login to your website using normal authentication credentials making sure your select Remember Me on the login page. On successful authentication, the Cams AUTOLOGIN cookie will be created. It will have a Cams cluster and security domain-specific name. For example:
CAMS_AUTO_LOGIN_MYCAMSCLUSTER_SYSTEM
Do NOT logout from your website. You must either let the Cams session ID cookie expire, named something like CAMS_SID_MYCAMSCLUSTER_SYSTEM, or manually remove the cookie from your browser. After removal, attempt to access any resource on the site that created the Cams AUTOLOGIN cookie. If a new Cams session cookie is created and you can browse to protected resources without being prompted for authentication, then automatic login succeeded.
NOTE: The FireFox web browser is useful when doing testing involving cookies. You can use select the Tools/Options/Privacy/Cookies/View Cookies to view and remove persistent and memory resident cookies.
The Cams AUTOLOGIN cookie has a configurable expiration period (in days) that will force the user's browser to automatically delete the cookie once the expiration date/time has been passed. A user may also force deletion of the AUTOLOGIN cookie by explicitly clicking a Cams logout URL on the originating web site.
Administrators may also force deletion of AUTOLOGIN cookies by changing the secret key parameters used to encrypt the cookie value. AUTOLOGIN cookies that cannot be decrypted by the Cams automatic HTTP login valve will always be removed.
© Copyright 1996-2005 Cafésoft LLC. All rights reserved.