Skip to content
This repository has been archived by the owner on May 17, 2021. It is now read-only.

Allow SSO attributes including dots #49

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/redmine_omniauth_saml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ 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]
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)
Expand Down
13 changes: 9 additions & 4 deletions sample-saml-initializers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,15 @@
:name_identifier_value => "mail", # Which redmine field is used as name_identifier_value for SAML logout
:attribute_mapping => {
# How will we map attributes from SSO to redmine attributes
:login => 'extra.raw_info.username',
:mail => 'extra.raw_info.email',
:firstname => 'extra.raw_info.firstname',
:lastname => 'extra.raw_info.firstname'
# using either urn:oid:identifier, or friendly names, e.g.
# :mail => 'extra|raw_info|urn:oid:0.9.2342.19200300.100.1.3'
# or
# :mail => 'extra|raw_info|email'
# Edit defaults below to match your attributes
:login => 'extra|raw_info|username',
:mail => 'extra|raw_info|email',
:firstname => 'extra|raw_info|firstname',
:lastname => 'extra|raw_info|firstname'
}
}

Expand Down