Skip to content

Configuration Advanced

kbeckman edited this page Jul 20, 2012 · 1 revision

YAML Configuration File###

The following code snippet shows how to setup your OmniAuth WSFed strategy to use a YAML configuration file (containing configurations for multiple environments) that is similar to the approach Rails uses for configuring database connections in database.yml

require 'yaml'

Rails.application.config.middleware.use OmniAuth::Builder do

  wsfed_yml     = YAML.load_file(File.join(Rails.root, "config", "omniauth-wsfed.yml"))
  settings_hash = wsfed_yml[Rails.env].symbolize_keys!

  provider :wsfed, settings_hash

end

OmniAuth Developer Strategy

In pre-production environments, is highly recommended that your application use the out-of-the-box OmniAuth developer strategy in addition to the WSFed strategy to enhance the ease-of-use of the application during testing. Setting up and implementing a corporate Single Sign-On strategy with WS-Federation is not a trivial task. Using alternate authentication strategies during the development process will reduce the friction of all developers having to authenticate via WSFed.

unless Rails.env == 'production'
    provider :developer, :fields => [:username], :uid_field => :username
end