Integrate an Existing Custom Login Module into the Gateway
Kaazing Gateway supports a plug-in mechanism for integration with custom authentication modules based on the Java LoginModule API. This document provides an example of how you can use your existing custom login module with the Gateway.
Before You Begin
This optional procedure is part of Configure Authentication and Authorization:
- Configure the HTTP Challenge Scheme
- Configure a Chain of Login Modules
- Create a Custom Login Module (Optional)
- Integrate an Existing Custom Login Module into the Gateway (Optional)
- Configure a Challenge Handler on the Client
- Configure Authorization
To Integrate an Existing Custom Login Module into the Gateway
-
Copy the login module to the
GATEWAY_HOME/web/basedirectory.Before you begin, you need the Gateway, your Java custom login module (for demo purposes, you can use the sample custom login module at https://github.com/kaazing/gateway/tree/develop/samples/security), and the fully qualified class name of your custom login module. Note that the
GATEWAY_HOME/web/extrasdirectory is read-only. So, to modify the providedCustomLoginModule.javafile, you must copy the file to yourGATEWAY_HOME/web/basedirectory. - Compile your Java custom login module file into a JAR file and place it in
GATEWAY_HOME/lib/ext. You can also update theCLASSPATHto point to the desired directory containing the JAR file. -
In the Gateway configuration (for example,
GATEWAY_HOME/conf/gateway-config.xml), add the custom login module and set thetypeto point toclass:the-fully-qualified-class-name. For example, if you are using the sample custom login module provided with the Gateway, the fully qualified class name isorg.kaazing.demo.loginmodules.CustomLoginModule. The following is thelogin-moduleentry for this sample:<login-module> <type>class:org.kaazing.demo.loginmodules.CustomLoginModule</type> <success>required</success> </login-module>
-
Enable configuration for the services that are required to use this custom login module to authenticate with the back-end server. You can do this using the
authorization-constraintelement. The following is an example of the echo service configured to use this custom login module:<service> <accept>ws://localhost:8001/echo</accept> <accept>wss://localhost:9001/echo</accept> <type>echo</type> <authorization-constraint> <require-role>AUTHORIZED</require-role> </authorization-constraint> <cross-site-constraint> <allow-origin>http://localhost:8000</allow-origin> </cross-site-constraint> <cross-site-constraint> <allow-origin>https://localhost:9000</allow-origin> </cross-site-constraint> </service> - Add this login module to the chain, as described in Configure a Chain of Login Modules.
- Save
gateway-config.xmland restart the Gateway.
Next Steps
Configure a Challenge Handler on the Client