2016-06-17 3 views
0

Реализация SSO для Redmine: Idp- OpenAM, SP-Redmine (Ominiauth SAML плагин)SSO: Как получить массив групп в redmine ominiauth SAML-плагин из SAML respone?

Я хочу, чтобы получить список групп, которые назначены пользователю в redmine_ominiauth_saml плагин, но я могу получить только одну группу, которая является первым на SAML ответ в групповом утверждении.

Так есть ли другая конфигурация для атрибута массива:

Отображение атрибутов для ИП на OpenAM:

  • группы = isMemberOf
  • last_name = зп
  • имя пользователя = почты
  • first_name = givenName
  • email = mail

Отображение атрибутов Redmine: "/opt/redmine/config/initializers/saml_3.0.rb"

:attribute_mapping    => { 
    # How will we map attributes from SSO to redmine attribute 
     :login  => 'extra.raw_info.username', 
     :firstname => 'extra.raw_info.first_name', 
     :lastname => 'extra.raw_info.last_name', 
     :mail  => 'extra.raw_info.email', 
     :isMemberOf => 'extra.raw_info.groups' 
    } 

ответ SAML содержит группы атрибутов в массиве, как это:

<saml:AttributeStatement> 
         <saml:Attribute Name="first_name"> 
           <saml:AttributeValue xmlns:xs="http://www.w3.org/2001/XMLSchema" 
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
                xsi:type="xs:string" 
                >umesh</saml:AttributeValue> 
         </saml:Attribute> 
         <saml:Attribute Name="username"> 
           <saml:AttributeValue xmlns:xs="http://www.w3.org/2001/XMLSchema" 
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
                xsi:type="xs:string" 
                >[email protected]</saml:AttributeValue> 
         </saml:Attribute> 
         <saml:Attribute Name="email"> 
           <saml:AttributeValue xmlns:xs="http://www.w3.org/2001/XMLSchema" 
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
                xsi:type="xs:string" 
                >[email protected]</saml:AttributeValue> 
         </saml:Attribute> 
         <saml:Attribute Name="last_name"> 
           <saml:AttributeValue xmlns:xs="http://www.w3.org/2001/XMLSchema" 
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
                xsi:type="xs:string" 
                >rajani</saml:AttributeValue> 
         </saml:Attribute> 
         <saml:Attribute Name="groups"> 
           <saml:AttributeValue xmlns:xs="http://www.w3.org/2001/XMLSchema" 
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
                xsi:type="xs:string" 
                >cn=ABC,ou=groups,dc=abc,dc=opendj,dc=com</saml:AttributeValue> 
           <saml:AttributeValue xmlns:xs="http://www.w3.org/2001/XMLSchema" 
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
                xsi:type="xs:string" 
                >cn=XYZ,ou=groups,dc=abc,dc=opendj,dc=com</saml:AttributeValue> 
           <saml:AttributeValue xmlns:xs="http://www.w3.org/2001/XMLSchema" 
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
                xsi:type="xs:string" 
                >cn=YZQ,ou=groups,dc=abc,dc=opendj,dc=com</saml:AttributeValue> 
         </saml:Attribute> 
       </saml:AttributeStatement> 

Я знал, что этот код в SAML плагин дает мне одну группу (код рубин): ​​ /opt/redmine/plugins/redmine_omniauth_saml/lib/redmine_omniauth_saml.rb

def user_attributes_from_saml(omniauth) 

     HashWithIndifferentAccess.new.tap do |h| 
      required_attribute_mapping.each do |symbol| 
      key = configured_saml[:attribute_mapping][symbol] 
       h[symbol] = key.split('.')    # Get an array with nested keys: name.first will return [name, first] 
       .map {|x| [:[], x]}      # Create pair elements being :[] symbol and the key 
       .inject(omniauth) do |hash, params|  # For each key, apply method :[] with key as parameter 
       hash.send(*params) 
       end 
      **print "key:value "+key+":" +h[symbol]** # gives key value pair, first_name, group 'ABC' only leaves other group 
      end 
     end 
     end 

ответ

1

На самом деле плагин ruby-saml по умолчанию используется как атрибут как одно значение.

В плагине ruby-saml нам нужно установить как многозначное значение.

плагин ruby-saml имеет атрибут.rb файла.

Обновить значение @@ single_value_compatibility и устанавливается как «ложь»

Теперь вы получаете полный спектр значения.

Упование вы разрешаете.

+0

спасибо, что это действительно работает. !! –