heartcombo / devise

Flexible authentication solution for Rails with Warden.

Home Page:http://blog.plataformatec.com.br/tag/devise/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

OmniAuth initializer overridden (or documentation issue)

borgand opened this issue · comments

I have set up Devise and Omniauth with Shibboleth strategy.

All of Omniauth documentation as well as the Shibboleth strategy docs and links from Devise Omniauth overview (the wiki page itself was sole exception, but I thought it was Facebook specific) indicate that I should set up extra configuration in Omniauth initializer: config/initializers/omniauth.rb:

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :shibboleth, 
    :info_fields => {:email => 'mail'},
    :extra_fields => [:cn, :sn, :schacHomeOrganization],
    :debug => false
end

Devise Omniauth documentation does not highlight enough the fact that Devise actually overrides Omniauth initializing (or parts of it) and I should actually have written this into config/initializers/devise.rb:

config.omniauth :shibboleth, {:uid_field => 'eppn',
  :info_fields => {:email => 'mail', :name => 'cn', :last_name => 'sn'},
  :extra_fields => [:schacHomeOrganization],
  :debug => false
}

It took me best part of several days to figure this out, because, for some reason, the :debug option was received by omniauth-shibboleth while the others were not. That is why it did not occur to me earlier that I am configuring in the wrong place.

Is there a bug in how Devise sets up Omniauth, that the :debug option had effect but not the :info_fields and :extra_fields when written into omniauth initializer (maybe specific to shibboleth strategy only).

Or maybe this should be highlighted more strongly in the documentation that Devise takes care of all of Omniauth setup and no separate initializer is consulted.

Is there a bug in how Devise sets up Omniauth, that the :debug option had effect but not the :info_fields and :extra_fields when written into omniauth initializer (maybe specific to shibboleth strategy only).

Devise simply forward the given option, so at first it is unexpected to have it working for some, but not all.

Or maybe this should be highlighted more strongly in the documentation that Devise takes care of all of Omniauth setup and no separate initializer is consulted.

Definitely this. Could you please provide a pull request updating the docs in the appropriate place? Thanks!!