README.md in omniauth-shibboleth-1.1.2 vs README.md in omniauth-shibboleth-1.2.0

- old
+ new

@@ -16,19 +16,16 @@ https://github.com/toyokazu/omniauth-shibboleth/issues ## Getting Started -### Installation +### Setup Gemfile and Install - % gem install omniauth-shibboleth - -### Setup Gemfile - % cd rails-app % vi Gemfile gem 'omniauth-shibboleth' + % bundle install ### Setup Shibboleth Strategy To use OmniAuth Shibboleth strategy as a middleware in your rails application, add the following file to your rails application initializer directory. @@ -66,9 +63,28 @@ } } end In the previous example, Shibboleth strategy does not pass any :info fields and use 'uid' attribute as uid fields. + +### More flexible attribute configuration + +If you need more flexible attribute definition, you can use lambda (Proc) to define your attributes. In the following example, 'uid' attribute is chosen from 'eppn' or 'mail', 'info'/'name' attribute is defined as a concatenation of 'cn' and 'sn' and 'info'/'affiliation' attribute is defined as 'affiliation'@my.localdomain. 'request_param' parameter is a method defined in OmniAuth::Shibboleth::Strategy. You can specify attribute names by downcase strings in either request_type, :env, :header and :params. + + % vi config/initializer/omniauth.rb + Rails.application.config.middleware.use OmniAuth::Builder do + provider :shibboleth, { + :uid_field => lambda {|request_param| request_param.call('eppn') || request_param.call('mail')}, + :name_field => lambda {|request_param| "#{request_param.call('cn')} #{request_param.call('sn')}"}, + :info_fields => { + :affiliation => lambda {|request_param| "#{request_param.call('affiliation')}@my.localdomain"}, + :email => "mail", + :location => "contactAddress", + :image => "photo_url", + :phone => "contactPhone" + } + } + end ### !!!NOTICE!!! devise integration issue When you use omniauth with devise, the omniauth configuration is applied before devise configuration and some part of the configuration overwritten by the devise's. It may not work as you assume. So thus, in that case, currently you should write your configuration only in device configuration.