I am trying to build up a Web Application in Heroku with Stormpath User Management addon and Apache Shiro. When I go through the sample code its mentioned in "shiro.ini" file to provide the "apiKey.properties" file's path in property "stormpathClient.apiKeyFileLocation". Please suggest how we can configure "apiKey.properties" file's path which contains STORMPATH API KEY ID and SECRET in Heroku application.
In Heroku you can place the Api Key ID and Secret in Environment variables as described here.
So, what you can do:
package com.stormpath.sample.client;
import java.util.Properties;
public class ApiKeyEnvVariables extends Properties {
public ApiKeyEnvVariables() {
super.put("apiKey.id", System.getenv("STORMPATH_API_KEY_ID"));
super.put("apiKey.secret", System.getenv("STORMPATH_API_KEY_SECRET"));
}
}
shiro.ini
to look like this: apiKeyProps = com.stormpath.sample.client.ApiKeyEnvVariables
#stormpathClient.apiKeyFileLocation = /Users/XXXX/.stormpath/apiKey.properties
stormpathClient.apiKeyProperties = $apiKeyProps
STORMPATH_API_KEY_ID
and STORMPATH_API_KEY_SECRET
environment variables. For example: heroku config:set STORMPATH_API_KEY_ID=2JQQCIG5E8EKN4DKBT7R151
heroku config:set STORMPATH_API_KEY_ID=1oYULQMkS3dwKkl6wtbNd93IyUrRehCsEJJrIrMwuI0
Now, when your app starts, Stormpath will automatically pick the Api Key Id and Secret from the environment variables.
Hope that helps!