Skip to content

Commit 884e24f

Browse files
authored
Merge pull request SAML-Toolkits#389 from onelogin/key_rollover_mngmt
Improve Key Rollover management
2 parents 7081338 + ce66c4e commit 884e24f

21 files changed

+1152
-179
lines changed

README.md

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,12 +252,37 @@ class SamlController < ApplicationController
252252
end
253253
end
254254
```
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+
255280
## Metadata Based Configuration
256281
257282
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
258283
key certificates which add to the trusted relationship. The IdP administrator can also configure custom settings for an SP based on the metadata.
259284
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.
261286
262287
```ruby
263288
def saml_settings
@@ -276,9 +301,35 @@ def saml_settings
276301
end
277302
```
278303
The following attributes are set:
304+
* idp_entity_id
305+
* name_identifier_format
279306
* idp_sso_target_url
280307
* 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.
282333
283334
## Retrieving Attributes
284335
@@ -454,6 +505,12 @@ The Service Provider will decrypt the EncryptedAssertion with its private key.
454505
455506
Notice that this toolkit uses 'settings.certificate' and 'settings.private_key' for the sign and decrypt processes.
456507
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+
457514
## Single Log Out
458515
459516
The Ruby Toolkit supports SP-initiated Single Logout and IdP-Initiated Single Logout.
@@ -584,6 +641,7 @@ class SamlController < ApplicationController
584641
end
585642
```
586643
644+
587645
## Clock Drift
588646
589647
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

Comments
 (0)