What I'm trying to have in the end is the ability to login normally with devise OR choose to login with SAML. So I read that if I integrate omniauth and saml, then omniauth and devise, I could achieve that.
My problem is, that I have different IDPs that I would like to choose from. So I don't have one :idp_sso_target_url, but many. So my question is how can I dynamically change the value of the target_url. Currently the omniauth-saml gem defines this value in the config/initializers directory..
Thank you,
You can store settings for every provider in db, and then configure omniauth in the setup phase at request-time. For example:
SETUP_PROC = lambda do |env|
request = Rack::Request.new(env)
user = User.find_by_subdomain(request.subdomain)
env['omniauth.strategy'].options[:consumer_key] = user.consumer_key
env['omniauth.strategy'].options[:consumer_secret] = user.consumer_secret
end
use OmniAuth::Builder.new do
provider :twitter, :setup => SETUP_PROC
end
See https://github.com/intridea/omniauth/wiki/Setup-Phase for more information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With