You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ability to set attribute_map via config setting (#162)
I added a config hook to set the attribute map dynamically based on the SAML response. By default, it will maintain the existing behavior: look up the `attribute-map.yml` file in the Rails root.
Other changes:
- The tests started failing on Travis despite working locally—I finally determined that bundler was looking at this repository's Gemfile instead of the test app's Gemfile, so I added a temporary working directory to put the test apps in. That seems to have worked.
- Updated the test matrix for new Ruby versions
Fixes#65
Co-authored-by: Kevin Trowbridge <[email protected]>
Copy file name to clipboardExpand all lines: README.md
+50-7Lines changed: 50 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -130,7 +130,26 @@ In `config/initializers/devise.rb`:
130
130
end
131
131
```
132
132
133
-
In the config directory, create a YAML file (`attribute-map.yml`) that maps SAML attributes with your model's fields:
133
+
#### Attributes
134
+
135
+
There are two ways to map SAML attributes to User attributes:
136
+
137
+
-[initializer](#attribute-map-initializer)
138
+
-[config file](#attribute-map-config-file)
139
+
140
+
The attribute mappings are very dependent on the way the IdP encodes the attributes.
141
+
In these examples the attributes are given in URN style.
142
+
Other IdPs might provide them as OID's, or by other means.
143
+
144
+
You are now ready to test it against an IdP.
145
+
146
+
When the user visits `/users/saml/sign_in` they will be redirected to the login page of the IdP.
147
+
148
+
Upon successful login the user is redirected to the Devise `user_root_path`.
149
+
150
+
##### Attribute map config file
151
+
152
+
Create a YAML file (`config/attribute-map.yml`) that maps SAML attributes with your model's fields:
134
153
135
154
```yaml
136
155
# attribute-map.yml
@@ -141,15 +160,39 @@ In the config directory, create a YAML file (`attribute-map.yml`) that maps SAML
141
160
"urn:mace:dir:attribute-def:givenName": "name"
142
161
```
143
162
144
-
The attribute mappings are very dependent on the way the IdP encodes the attributes.
145
-
In this example the attributes are given in URN style.
146
-
Other IdPs might provide them as OID's, or by other means.
163
+
##### Attribute map initializer
147
164
148
-
You are now ready to test it against an IdP.
165
+
In `config/initializers/devise.rb` (see above), add an attribute map resolver.
166
+
The resolver gets the [SAML response from the IdP](https://github.com/onelogin/ruby-saml/blob/master/lib/onelogin/ruby-saml/response.rb) so it can decide which attribute map to load.
167
+
If you only have one IdP, you can use the config file above, or just return a single hash.
149
168
150
-
When the user visits `/users/saml/sign_in` they will be redirected to the login page of the IdP.
169
+
```ruby
170
+
# config/initializers/devise.rb
171
+
Devise.setup do |config|
172
+
...
173
+
# ==> Configuration for :saml_authenticatable
151
174
152
-
Upon successful login the user is redirected to the Devise `user_root_path`.
0 commit comments