7.8. Login with Credentials From MySQL

This sample fetches the login credentials from MySQL. You must have access to an instance of MySQL in order to execute this sample. If you do not have access or just want to see how the SqlAttributesFilter works, just read the rest of this section.

For this sample you must configure your container for JNDI and MySQL. See the chapter on Configuring Deployment Containers for instructions on configuring containers for use with JNDI and MySQL. You also must create an entry for a user and create a query which returns a result with user name and password attributes. The query in the sample assumes there is a table named users, with attributes username and password. The parameter passed into the prepared statement is email=george@seinfeld.com.

$ cp $HOME/forgerock-sample-configs/WordPressLoginSQL.json
 $HOME/.ForgeRock/OpenIG/config.json
$ jetty.sh restart

To see what is happening behind the scenes, take a look at $HOME/.ForgeRock/OpenIG/config.json. For this sample, you replaced the FileAttributesFilter with the SqlAttributesFilter. The only difference between the filters is how they retrieve the attribute value pairs to set in the Exchange. Once the values are set in the Exchange, the LoginRequestFilter accesses them in the exact same way.