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
response = OneLogin::RubySaml::Response.new(params[:SAMLResponse], {skip_recipient_check: true}) # doens't skip subject confirmation, but skips the recipient check which is a sub check of the subject_confirmation check
244
+
response = OneLogin::RubySaml::Response.new(params[:SAMLResponse], {skip_recipient_check: true}) # doesn't skip subject confirmation, but skips the recipient check which is a sub check of the subject_confirmation check
@@ -298,16 +299,16 @@ class SamlController < ApplicationController
298
299
end
299
300
```
300
301
302
+
## Signature Validation
301
303
302
-
## Signature validation
303
-
304
-
On the ruby-saml toolkit there are different ways to validate the signature of the SAMLResponse:
305
-
- You can provide the IdP x509 public certificate at the 'idp_cert' setting.
306
-
- 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.
304
+
Ruby SAML allows different ways to validate the signature of the SAMLResponse:
305
+
- You can provide the IdP X.509 public certificate at the `idp_cert` setting.
306
+
- You can provide the IdP X.509 public certificate in fingerprint format using the
307
+
`idp_cert_fingerprint` setting parameter and additionally the `idp_cert_fingerprint_algorithm` parameter.
307
308
308
309
When validating the signature of redirect binding, the fingerprint is useless and the certificate
309
310
of the IdP is required in order to execute the validation. You can pass the option
310
-
`:relax_signature_validation` to SloLogoutrequest and Logoutresponse if want to avoid signature
311
+
`:relax_signature_validation` to `SloLogoutrequest` and `Logoutresponse` if want to avoid signature
311
312
validation if no certificate of the IdP is provided.
312
313
313
314
In production also we highly recommend to register on the settings the IdP certificate instead
@@ -318,34 +319,35 @@ we maintain it for compatibility and also to be used on test environment.
318
319
In some scenarios the IdP uses different certificates for signing/encryption, or is under key
319
320
rollover phase and more than one certificate is published on IdP metadata.
320
321
321
-
In order to handle that the toolkit offers the 'idp_cert_multi' parameter.
322
-
When used, 'idp_cert' and 'idp_cert_fingerprint' values are ignored.
322
+
In order to handle that Ruby SAML offers the `idp_cert_multi` parameter.
323
+
When used, `idp_cert` and `idp_cert_fingerprint` values are ignored.
323
324
324
325
The `idp_cert_multi` must be a Hash as follows:
325
326
327
+
```ruby
326
328
{
327
329
:signing => [],
328
330
:encryption => []
329
331
}
332
+
```
330
333
331
-
And on `:signing` and `:encryption` arrays, add the different IdP x509 public certificates
334
+
And on `:signing` and `:encryption` arrays, add the different IdP X.509 public certificates
332
335
published on the IdP metadata.
333
336
334
337
## Metadata Based Configuration
335
338
336
-
The method above requires a little extra work to manually specify attributes about the IdP.
337
-
(And your SP application) There's an easier method -- use a metadata exchange.
338
-
Metadata is just an XML file that defines the capabilities of both the IdP and the SP application.
339
-
It also contains the X.509 public key certificates which add to the trusted relationship.
339
+
The method above requires a little extra work to manually specify attributes about both the IdP and your SP application.
340
+
There's an easier method: use a metadata exchange. Metadata is an XML file that defines the capabilities of both the IdP
341
+
and the SP application. It also contains the X.509 public key certificates which add to the trusted relationship.
340
342
The IdP administrator can also configure custom settings for an SP based on the metadata.
341
343
342
-
Using ```idp_metadata_parser.parse_remote```IdP metadata will be added to the settings without further ado.
344
+
Using `IdpMetadataParser#parse_remote`, the IdP metadata will be added to the settings.
@@ -522,72 +525,169 @@ To add a `saml:AuthnContextDeclRef`, define `settings.authn_context_decl_ref`.
522
525
In a SP-initiated flow, the SP can indicate to the IdP the subject that should be authenticated. This is done by defining the `settings.name_identifier_value_requested` before
523
526
building the authrequest object.
524
527
528
+
## Service Provider Metadata
529
+
530
+
To form a trusted pair relationship with the IdP, the SP (you) need to provide metadata XML
531
+
to the IdP for various good reasons. (Caching, certificate lookups, relaying party permissions, etc)
525
532
526
-
## Signing
533
+
The class `OneLogin::RubySaml::Metadata` takes care of this by reading the Settings and returning XML. All you have to do is add a controller to return the data, then give this URL to the IdP administrator.
534
+
535
+
The metadata will be polled by the IdP every few minutes, so updating your settings should propagate
536
+
to the IdP settings.
527
537
528
-
The Ruby Toolkit supports 2 different kinds of signature: Embeded and `GET` parameters
In order to be able to decrypt a SAML Response that contains a EncryptedAssertion you need define the private key and the public cert of the service provider, then share this with the Identity Provider.
658
+
By default, Ruby SAML will raise a `OneLogin::RubySaml::ValidationError` if a signature or certificate
659
+
validation fails. You may disable such exceptions using the `settings.security[:soft]` parameter.
571
660
572
661
```ruby
573
-
settings.certificate = "CERTIFICATE TEXT WITH HEAD AND FOOT"
574
-
settings.private_key = "PRIVATE KEY TEXT WITH HEAD AND FOOT"
662
+
settings.security[:soft] = true # Do not raise error on failed signature/certificate validations
575
663
```
576
664
577
-
The Identity Provider will encrypt the Assertion with the public cert of the Service Provider.
578
-
The Service Provider will decrypt the EncryptedAssertion with its private key.
665
+
#### Key Rollover
579
666
580
-
Notice that this toolkit uses 'settings.certificate' and 'settings.private_key'for the sign and decrypt processes.
667
+
To update the SP X.509 certificate and private key without disruption of service, you may define the parameter
668
+
`settings.certificate_new`. This will publish the new SP certificate in your metadata so that your IdP counterparties
669
+
may cache it in preparation for rollover.
581
670
671
+
For example, if you to rollover from `CERT A` to `CERT B`. Before rollover, your settings should look as follows.
672
+
Both `CERT A` and `CERT B` will now appear in your SP metadata, however `CERT A` will still be used for signing
673
+
and encryption at this time.
582
674
583
-
## Key rollover
675
+
```ruby
676
+
settings.certificate = "CERT A"
677
+
settings.private_key = "PRIVATE KEY FOR CERT A"
678
+
settings.certificate_new = "CERT B"
679
+
```
584
680
585
-
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.
681
+
After the IdP has cached `CERT B`, you may then change your settings as follows:
586
682
683
+
```ruby
684
+
settings.certificate = "CERT B"
685
+
settings.private_key = "PRIVATE KEY FOR CERT B"
686
+
```
587
687
588
688
## Single Log Out
589
689
590
-
The Ruby Toolkit supports SP-initiated Single Logout and IdP-Initiated Single Logout.
690
+
Ruby SAML supports SP-initiated Single Logout and IdP-Initiated Single Logout.
591
691
592
692
Here is an example that we could add to our previous controller to generate and send a SAML Logout Request to the IdP:
593
693
@@ -700,38 +800,6 @@ def logout
700
800
end
701
801
```
702
802
703
-
704
-
705
-
## Service Provider Metadata
706
-
707
-
To form a trusted pair relationship with the IdP, the SP (you) need to provide metadata XML
708
-
to the IdP for various good reasons. (Caching, certificate lookups, relaying party permissions, etc)
709
-
710
-
The class `OneLogin::RubySaml::Metadata` takes care of this by reading the Settings and returning XML. All you have to do is add a controller to return the data, then give this URL to the IdP administrator.
711
-
712
-
The metadata will be polled by the IdP every few minutes, so updating your settings should propagate
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.
@@ -766,7 +834,7 @@ The `attribute_value` option additionally accepts an array of possible values.
766
834
## Custom Metadata Fields
767
835
768
836
Some IdPs may require to add SPs to add additional fields (Organization, ContactPerson, etc.)
769
-
into the SP metadata. This can be acheived by extending the `OneLogin::RubySaml::Metadata`
837
+
into the SP metadata. This can be achieved by extending the `OneLogin::RubySaml::Metadata`
770
838
class and overriding the `#add_extras` method as per the following example:
0 commit comments