Non ottengo una mappatura corretta degli attributi usando il plugin SAML

Hello,

I am trying to integrate our shibboleth with our discourse instance. For now logging in works but I am getting the wrong data (name, email, etc…)

here is part of the data coming from the SSO

    <saml2:Attribute FriendlyName="givenName" Name="urn:oid:2.5.4.42" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri">
      <saml2:AttributeValue>Joao Miguel</saml2:AttributeValue>

here is the error log:

SAML Debugging: saml_auth: {:uid=>"AAdzZWNyZXQ0uudwQFYHs1n7nrvB/A4t4l6q+6aAXInZRL4XIO+mnEEEq4t8UwBnzJRh50mnTGDsQAPvWThJNaUNR6smCochT1I2oXwvyoU4lQG+5hbVmCvkkmYDPOujrvgNloXWNg==", :info=>{"name"=>nil, "email"=>nil, "first_name"=>nil, "last_name"=>nil, "nickname"=>nil}.......   @attributes={............."urn:oid:2.5.4.42"=>["Joao Miguel"]

I would say the issue has to do with the FriendlyName, as it doesnt match any of the options in saml_authenticator.rb:

statements = “name:name|email:email,mail|first_name:first_name,firstname,firstName|last_name:last_name,lastname,lastName|nickname:screenName”

Since friendly name repeats itself for every atribute I am not sure how to make the mapping. Has anyone an idea of how to deal with this?

Thank you

Ci sei riuscito a farlo funzionare?

Ciao @Ivan.bacher e @JoreisPy, qualche successo nel mappare gli attributi corretti tramite le configurazioni di discourse-saml?

Ho provato a usare questa configurazione nel plug-in ma finora senza fortuna:

Buona giornata! :slight_smile:

Mi sono imbattuto nello stesso problema durante il test dell’integrazione SAML e alla fine sono riuscito a farlo funzionare. Con i log abilitati, controlla il contenuto di @attributes, quelle sono le chiavi effettive di cui hai bisogno per il mapping e non il nome visualizzato. Corrispondono all’attributo Name dai dati XML. Nel mio caso, il mapping all’interno di app.yml è diventato:

DISCOURSE_SAML_REQUEST_ATTRIBUTES: "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress"
DISCOURSE_SAML_ATTRIBUTE_STATEMENTS: "email:http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress"

È anche importante ricompilare dopo le modifiche alla configurazione. Dopo averlo fatto, ha mappato correttamente il valore dell’email dalla mia risposta SAML.

Grazie per aver condiviso l’esempio, da discourse-saml/config/locales/server.en.yml at main · discourse/discourse-saml · GitHub non è chiaro cosa significhi il formato esatto.
Inoltre, per futuri plugin SAML c’è la possibilità di mappare più di un attributo alla variabile Discourse, quindi il formato dice fondamentalmente:

‘<variabile_Discourse>:<attributo_SAML1>,<attributo_SAML2>’

1 Mi Piace

Probabilmente non è il posto giusto, ma solo per aggiungere, avrai bisogno di email, name, first_name, last_name e uid come attributi di Discourse per poter utilizzare il plugin SAML.

Inoltre

def attribute_statements
    result = {}
    statements =
      "name:fullName,name|email:email,mail|first_name:first_name,firstname,firstName|last_name:last_name,lastname,lastName|nickname:screenName"
    custom_statements = setting(:attribute_statements)

    statements = "#{statements}|#{custom_statements}" if custom_statements.present?

    statements
      .split("|")
      .map do |statement|
        attrs = statement.split(":", 2)
        next if attrs.count != 2
        (result[attrs[0]] ||= []) << attrs[1].split(",")
        result[attrs[0]].flatten!
      end

    result
  end

questa parte del codice (tieni presente che non sono un programmatore Ruby) suggerisce che è necessario mappare tutti gli attributi ai tuoi attributi affinché il sistema possa funzionare… Proverò a testare queste informazioni (ho un problema al momento con il plugin SAML e sto cercando di indagare sui problemi).