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
Copy file name to clipboardExpand all lines: README.md
+60-2Lines changed: 60 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -252,12 +252,37 @@ class SamlController < ApplicationController
252
252
end
253
253
end
254
254
```
255
+
256
+
257
+
## Signature validation
258
+
259
+
On the ruby-saml toolkit there are different ways to validate the signature of the SAMLResponse:
260
+
- You can provide the IdP x509 public certificate at the 'idp_cert' setting.
261
+
- You can provide the IdP x509 public certificate in fingerprint format using the 'idp_cert_fingerprint' setting parameter and additionally the 'idp_cert_fingerprint_algorithm' parameter.
262
+
263
+
When validating the signature of redirect binding, the fingerprint is useless and the certficate of the IdP is required in order to execute the validation.
264
+
You can pass the option :relax_signature_validation to SloLogoutrequest and Logoutresponse if want to avoid signature validation if no certificate of the IdP is provided.
265
+
266
+
In some scenarios the IdP uses different certificates for signing/encryption, or is under key rollover phase and more than one certificate is published on IdP metadata.
267
+
268
+
In order to handle that the toolkit offers the 'idp_cert_multi' parameter.
269
+
When used, 'idp_cert' and 'idp_cert_fingerprint' values are ignored.
270
+
271
+
That 'idp_cert_multi' must be a Hash as follows:
272
+
{
273
+
:signing => [],
274
+
:encryption => []
275
+
}
276
+
277
+
And on 'signing' and 'encryption' arrays, add the different IdP x509 public certificates published on the IdP metadata.
278
+
279
+
255
280
## Metadata Based Configuration
256
281
257
282
The method above requires a little extra work to manually specify attributes about the IdP. (And your SP application) There's an easier method -- use a metadata exchange. Metadata is just an XML file that defines the capabilities of both the IdP and the SP application. It also contains the X.509 public
258
283
key certificates which add to the trusted relationship. The IdP administrator can also configure custom settings for an SP based on the metadata.
259
284
260
-
Using ```idp_metadata_parser.parse_remote``` IdP metadata will be added to the settings withouth further ado.
285
+
Using ```idp_metadata_parser.parse_remote``` IdP metadata will be added to the settings without further ado.
261
286
262
287
```ruby
263
288
def saml_settings
@@ -276,9 +301,35 @@ def saml_settings
276
301
end
277
302
```
278
303
The following attributes are set:
304
+
* idp_entity_id
305
+
* name_identifier_format
279
306
* idp_sso_target_url
280
307
* idp_slo_target_url
281
-
* idp_cert_fingerprint
308
+
* idp_attribute_names
309
+
* idp_cert
310
+
* idp_cert_fingerprint
311
+
* idp_cert_multi
312
+
313
+
### Retrieve one Entity Descriptor when many exist in Metadata
314
+
315
+
If the Metadata contains several entities, the relevant Entity
316
+
Descriptor can be specified when retrieving the settings from the
317
+
IdpMetadataParser by its Entity Id value:
318
+
319
+
```ruby
320
+
validate_cert = true
321
+
settings = idp_metadata_parser.parse_remote(
322
+
"https://example.com/auth/saml2/idp/metadata",
323
+
validate_cert,
324
+
entity_id: "http//example.com/target/entity"
325
+
)
326
+
```
327
+
328
+
### Parsing Metadata into an Hash
329
+
330
+
The `OneLogin::RubySaml::IdpMetadataParser` also provides the methods `#parse_to_hash` and `#parse_remote_to_hash`.
331
+
Those return an Hash instead of a `Settings` object, which may be useful for configuring
332
+
[omniauth-saml](https://github.com/omniauth/omniauth-saml), for instance.
282
333
283
334
## Retrieving Attributes
284
335
@@ -454,6 +505,12 @@ The Service Provider will decrypt the EncryptedAssertion with its private key.
454
505
455
506
Notice that this toolkit uses 'settings.certificate' and 'settings.private_key'for the sign and decrypt processes.
456
507
508
+
509
+
## Key rollover
510
+
511
+
If you plan to update the SP x509cert and privateKey you can define the parameter 'certificate_new' at the settings and that new SP public certificate will be published on the SP metadata so Identity Providers can read them and get ready for rollover.
512
+
513
+
457
514
## Single Log Out
458
515
459
516
The Ruby Toolkit supports SP-initiated Single Logout and IdP-Initiated Single Logout.
@@ -584,6 +641,7 @@ class SamlController < ApplicationController
584
641
end
585
642
```
586
643
644
+
587
645
## Clock Drift
588
646
589
647
Server clocks tend to drift naturally. If during validation of the response you get the error "Current time is earlier than NotBefore condition", this may be due to clock differences between your system and that of the Identity Provider.
0 commit comments