HerokuConfigVars
This engine allows you to manage Heroku configuration variables from within your application.
Installation into your application
- Add
gem 'heroku_config_vars'
to your Gemfile - Add
mount HerokuConfigVars::Engine => "/heroku_config_vars"
to your routes.rb - Implement the method
:heroku_config_vars_authorized?
on your ApplicationController. (See Customization) - To make authorization easy, this engine inherits from your ApplicationController.
This means that you may have to change named routes to be more specific,
otherwise the url_helper will raise a
ActionController::RoutingError
. e.g.
class ApplicationController < ActionController::Base
before_filter :authenticate
def authenticate
- redirect_to new_session_path unless logged_in?
+ redirect_to main_app.new_session_path unless logged_in?
end
end
Security
HerokuConfigVars aims to be secure by default.
- Every request needs to be authorized by your application.
- Non SSL requests are confirmed by the user before they're loaded.
That said, this engine will open up another vector for your (potentially sensitive) application configuration to be accessed.
Setup
- (Test it works in development)
- Deploy your app to Heroku
- Visit /heroku_config_vars
- Enter valid Heroku credentials for your application.
These are stored in the Heroku configuration for this application so you don't need to enter them again.
Usage
With this engine you can:
- View the complete ruby ENV hash
- View the Heroku configuration
- Update, add and delete Heroku configuration variables
Customization
You can change the path to the engine by changing the line in your routes.rb
mount HerokuConfigVars::Engine => "/whatever_path_you_like"`
You can also change the name of the authorization method to call on ApplicationController.
You may wish to do this if you already have an appropriate authorization method defined. e.g.
HerokuConfigVars.authorization_method = :admin_logged_in?
A typical implementation of this method might look like:
class ApplicationController < ActionController::Base
...
def heroku_config_vars_authorized?
current_user && current_user.admin?
end
...
end