Open varenius opened 4 years ago
I realised I could add the line
logger.info(omniauth)
to plugins/redmine_omniauth_saml/lib/redmine_omniauth_saml/user_patch.rb
i.e. :
module OmniAuthSamlUserMethods
def find_or_create_from_omniauth(omniauth)
logger.info(omniauth)
I then find in redmine/log/debug.log this message (where REMOVED are masked values):
I, [2020-03-24T08:39:38.000470 #52519] INFO -- : #<OmniAuth::AuthHash credentials=#<OmniAuth::AuthHash> extra=#<OmniAuth::AuthHash raw_info=#<OneLogin::RubySaml::Attributes:0x000056486a4a4c60 @attributes={"urn:oid:2.16.840.1.113730.3.1.241"=>["Eskil Varenius"], "urn:oid:2.5.4.42"=>["Eskil"], "urn:oid:2.5.4.4"=>["Varenius"], "urn:oid:0.9.2342.19200300.100.1.3"=>["eskil.varenius@REMOVED"], "urn:oid:1.3.6.1.4.1.5923.1.1.1.6"=>["varenius@REMOVED"], "urn:oid:1.3.6.1.4.1.5923.1.1.1.9"=>["member@REMOVED", "employee@REMOVED"], "fingerprint"=>"REMOVED"}>> info=#<OmniAuth::AuthHash::InfoHash email=nil first_name=nil last_name=nil name=nil> provider="saml" uid="0yce5EnXNgbQM5jBqncS9oiQ/FYs50bO/KcDoJofbGg=">
so... the problem seems to be the part email=nil first_name=nil last_name=nil name=nil
. Investigations continue...
Solution found! I am using the urn:uid:... strings which contain dots (.) !
And, in plugins/redmine_omniauth_saml/lib/redmine_omniauth_saml.rb
there is a line
h[symbol] = key.split('.') # Get an array with nested keys: name.first will return [name, first]
This doesn't work for my strings. I used the Rails.logger function to log things to the redmine-log from this file like this:
Rails.logger.info("stuff_to_log")
And I see that the result I ger from the split is for example:
I, [2020-03-24T09:36:25.732545 #55859] INFO -- : ["extra", "raw_info", "urn:oid:1", "3", "6", "1", "4", "1", "5923", "1", "1", "1", "6"]
While I would like the array
["extra", "raw_info", "urn:oid:1.3.6.1.4.1.5923.1.1.1.6"]
Not sure how to properly fix this, but for now I have just hard-coded the split as follows:
#h[symbol] = key.split('.') # Get an array with nested keys: name.first will return [name, first]
h[symbol] = ["extra","raw_info",key[15..-1]] # hard-coded to avoid the problem with dots (.) in urn:oid. See https://github.com/chrodriguez/redmine_omniauth_saml/issues/47
This works! I can now login again. Not sure how to properly adress mappings which have dots in them; perhaps a better way is to use a replacement char other than "." to divide the attribute mapping stings? For example using |
which would mean I define:
# How will we map attributes from SSO to redmine attributes
:login => 'extra|raw_info|urn:oid:1.3.6.1.4.1.5923.1.1.1.6',
:mail => 'extra|raw_info|urn:oid:0.9.2342.19200300.100.1.3',
:firstname => 'extra|raw_info|urn:oid:2.5.4.42',
:lastname => 'extra|raw_info|urn:oid:2.5.4.4'
}
and then in plugins/redmine_omniauth_saml/lib/redmine_omniauth_saml.rb
h[symbol] = key.split('|') # Get an array with nested keys: name|first will return [name, first]
This works for me. Worth modifying?
Hello, I am trying to configure Redmine to use this plugin with my university login service. Environment: Redmine version 4.0.5.stable Ruby version 2.5.5-p157 (2019-03-15) [x86_64-linux-gnu] Rails version 5.2.3
I go to my redmine login page, then click the link to login wih SAML, get to the University server and provide my details, and press enter. Then I get a message on screen like
Investigating I check "/var/log/apache2/error.log" but I only find one relevant line:
App 24371 stdout: I, [2020-01-26T10:45:04.288274 #24371] INFO -- omniauth: (saml) Callback phase initiated.
Looking further in "/opt/redmine/log/debug.log" I see a lot more info (where I have REMOVED some potentially sensitive information):I suspect this has to do with me configuring my attributes the wrong way (I don't know much about this). Based on the example file I have configured /opt/redmine/config/initializers/saml.rb like this:
Parsing the SAMLResponse (which was REMOVED in the debug.log above) I find these attributes supplied by the login server:
As far as I understand, it seems I get the right information back in the SAML response, but for some reason the plugin doesn't like it. Maybe I have matched the URN strings in the wrong format? Do you have any idea of where the error could be?
I see there has been a similar discussion in https://github.com/chrodriguez/redmine_omniauth_saml/issues/21#issuecomment-256945408 but I could not get my stuff to work using the things in there. As this was from an older version (redmine <4) I thought it may be worth filing a new issue.
Kind regards Eskil