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
This gem has a dependency on Nokogiri, which dropped support for Ruby 1.8.x in Nokogiri 1.6. When installing this gem on Ruby 1.8.7, you will need to make sure a version of Nokogiri prior to 1.6 is installed or specified if it hasn't been already.
95
+
This gem uses Nokogiri as a dependency, which dropped support for Ruby 1.8.x in Nokogiri 1.6. When installing this gem on Ruby 1.8.7, you will need to make sure a version of Nokogiri prior to 1.6 is installed or specified if it hasn't been already.
This is the first request you will get from the identity provider. It will hit your application at a specific URL (that you've announced as being your SAML initialization point). The response to this initialization, is a redirect back to the identity provider, which can look something like this (ignore the saml_settings method call for now):
124
+
This is the first request you will get from the identity provider. It will hit your application at a specific URL that you've announced as your SAML initialization point. The response to this initialization is a redirect back to the identity provider, which can look something like this (ignore the saml_settings method call for now):
125
125
126
126
```ruby
127
127
def init
@@ -130,7 +130,7 @@ def init
130
130
end
131
131
```
132
132
133
-
Once you've redirected back to the identity provider, it will ensure that the user has been authorized and redirect back to your application for final consumption, this is can look something like this (the authorize_success and authorize_failure methods are specific to your application):
133
+
Once you've redirected back to the identity provider, it will ensure that the user has been authorized and redirect back to your application for final consumption. This can look something like this (the `authorize_success` and `authorize_failure` methods are specific to your application):
134
134
135
135
```ruby
136
136
def consume
@@ -147,17 +147,17 @@ def consume
147
147
end
148
148
```
149
149
150
-
In the above there are a few assumptions in place, one being that the response.nameid is an email address. This is all handled with how you specify the settings that are in play via the saml_settings method. That could be implemented along the lines of this:
151
-
152
-
If the assertion of the SAMLResponse is not encrypted, you can initialize the Response without the :settings parameter and set it later,
150
+
In the above there are a few assumptions, one being that `response.nameid` is an email address. This is all handled with how you specify the settings that are in play via the `saml_settings` method. That could be implemented along the lines of this:
but if the SAMLResponse contains an encrypted assertion, you need to provide the settings in the
159
-
initialize method in order to be able to obtain the decrypted assertion, using the service provider private key in order to decrypt.
160
-
If you don't know what expect, use always the first proposed way (always set the settings on the initialize method).
156
+
157
+
If the assertion of the SAMLResponse is not encrypted, you can initialize the Response without the `:settings` parameter and set it later.
158
+
If the SAMLResponse contains an encrypted assertion, you need to provide the settings in the
159
+
initialize method in order to obtain the decrypted assertion, using the service provider private key in order to decrypt.
160
+
If you don't know what expect, always use the former (set the settings on initialize).
161
161
162
162
```ruby
163
163
def saml_settings
@@ -184,14 +184,14 @@ def saml_settings
184
184
end
185
185
```
186
186
187
-
Some assertion validations can be skipped by passing parameters to OneLogin::RubySaml::Response.new(). For example, you can skip the Conditions validation or the SubjectConfirmation validations by initializing the response with different options:
187
+
Some assertion validations can be skipped by passing parameters to `OneLogin::RubySaml::Response.new()`. For example, you can skip the `Conditions` validation or the `SubjectConfirmation` validations by initializing the response with different options:
What's left at this point, is to wrap it all up in a controller and point the initialization and consumption URLs in OneLogin at that. A full controller example could look like this:
194
+
All that's left is to wrap everything in a controller and reference it inthe initialization and consumption URLs in OneLogin. A full controller example could look like this:
195
195
196
196
```ruby
197
197
# This controller expects you to use the URLs /saml/init and /saml/consume in your OneLogin application.
@@ -270,8 +270,8 @@ The following attributes are set:
270
270
* idp_slo_target_url
271
271
* idp_cert_fingerprint
272
272
273
-
If you are using saml:AttributeStatement to transfer metadata, like the user name, you can access all the attributes through response.attributes. It contains all the saml:AttributeStatement with its 'Name' as a indifferent key the one/more saml:AttributeValue as value. The value returned depends on the value of the
274
-
`single_value_compatibility` (when activate, only one value returned, the first one)
273
+
If you are using `saml:AttributeStatement` to transfer metadata like the user name, you can access all the attributes through `response.attributes`. It contains all the `saml:AttributeStatement`s with its 'Name' as an indifferent key and one or more `saml:AttributeValue`s as values. The value returned depends on the value of the
274
+
`single_value_compatibility` (when activated, only the first value is returned)
The saml:AuthnContextClassRef of the AuthNRequest can be provided by `settings.authn_context` , possible values are described at [SAMLAuthnCxt]. The comparison method can be set using the parameter `settings.authn_context_comparison` (the possible values are: 'exact', 'better', 'maximum' and 'minimum'), 'exact' is the default value.
384
-
If we want to add a saml:AuthnContextDeclRef, define a `settings.authn_context_decl_ref`.
383
+
The `saml:AuthnContextClassRef` of the AuthNRequest can be provided by `settings.authn_context`; possible values are described at [SAMLAuthnCxt]. The comparison method can be set using `settings.authn_context_comparison` parameter. Possible values include: 'exact', 'better', 'maximum' and 'minimum' (default value is 'exact').
384
+
To add a `saml:AuthnContextDeclRef`, define `settings.authn_context_decl_ref`.
385
385
386
386
387
387
## Signing
388
388
389
-
The Ruby Toolkit supports 2 different kinds of signature: Embeded and as GET parameter
389
+
The Ruby Toolkit supports 2 different kinds of signature: Embeded and `GET` parameters
390
390
391
-
In order to be able to sign we need first to define the private key and the public cert of the service provider
391
+
In order to be able to sign, define the private key and the public cert of the service provider:
392
392
393
393
```ruby
394
394
settings.certificate = "CERTIFICATE TEXT WITH HEAD AND FOOT"
@@ -414,23 +414,23 @@ The settings related to sign are stored in the `security` attribute of the setti
414
414
settings.security[:embed_sign] = false
415
415
```
416
416
417
-
Notice that the RelayState parameter is used when creating the Signature on the HTTP-Redirect Binding,
418
-
remember to provide it to the Signature builder if you are sending a GET RelayState parameter or
419
-
Signature validation process will fail at the Identity Provider.
417
+
Notice that the RelayState parameter is used when creating the Signature on the HTTP-Redirect Binding.
418
+
Remember to provide it to the Signature builder if you are sending a `GET RelayState` parameter or the
419
+
signature validation process will fail at the Identity Provider.
420
420
421
421
The Service Provider will sign the request/responses with its private key.
422
422
The Identity Provider will validate the sign of the received request/responses with the public x500 cert of the
423
423
Service Provider.
424
424
425
-
Notice that this toolkit uses 'settings.certificate' and 'settings.private_key' for the sign and the decrypt process.
425
+
Notice that this toolkit uses 'settings.certificate' and 'settings.private_key' for the sign and decrypt processes.
426
426
427
-
Enable/disable the soft mode by the settings.soft parameter. When is set false, the saml validations errors will raise an exception.
427
+
Enable/disable the soft mode with the `settings.soft` parameter. When set to `false`, saml validations errors will raise an exception.
428
428
429
429
## Decrypting
430
430
431
431
The Ruby Toolkit supports EncryptedAssertion.
432
432
433
-
In order to be able to decrypt a SAML Response that contains a EncryptedAssertion we need first to define the private key and the public cert of the service provider, and share this with the Identity Provider.
433
+
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.
434
434
435
435
```ruby
436
436
settings.certificate = "CERTIFICATE TEXT WITH HEAD AND FOOT"
@@ -440,13 +440,13 @@ In order to be able to decrypt a SAML Response that contains a EncryptedAssertio
440
440
The Identity Provider will encrypt the Assertion with the public cert of the Service Provider.
441
441
The Service Provider will decrypt the EncryptedAssertion with its private key.
442
442
443
-
Notice that this toolkit uses 'settings.certificate' and 'settings.private_key' for the sign and the decrypt process.
443
+
Notice that this toolkit uses 'settings.certificate' and 'settings.private_key' for the sign and decrypt processes.
444
444
445
445
## Single Log Out
446
446
447
447
The Ruby Toolkit supports SP-initiated Single Logout and IdP-Initiated Single Logout.
448
448
449
-
Here is an example that we could add to our previous controller to generate and send a SAML Logout Request to the IdP
449
+
Here is an example that we could add to our previous controller to generate and send a SAML Logout Request to the IdP:
450
450
451
451
```ruby
452
452
# Create a SP initiated SLO
@@ -475,7 +475,7 @@ def sp_logout_request
475
475
end
476
476
```
477
477
478
-
and this method process the SAML Logout Response sent by the IdP as reply of the SAML Logout Request
478
+
This method processes the SAML Logout Response sent by the IdP as the reply of the SAML Logout Request:
479
479
480
480
```ruby
481
481
# After sending an SP initiated LogoutRequest to the IdP, we need to accept
@@ -510,7 +510,7 @@ def delete_session
510
510
end
511
511
```
512
512
513
-
Here is an example that we could add to our previous controller to process a SAML Logout Request from the IdP and reply a SAML Logout Response to the IdP
513
+
Here is an example that we could add to our previous controller to process a SAML Logout Request from the IdP and reply with a SAML Logout Response to the IdP:
514
514
515
515
```ruby
516
516
# Method to handle IdP initiated logouts
@@ -576,11 +576,11 @@ end
576
576
577
577
## Clock Drift
578
578
579
-
Server clocks tend to drift naturally. If during validation of the response you get the error "Current time is earlier than NotBefore condition"then this may be due to clock differences between your system and that of the Identity Provider.
579
+
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.
580
580
581
581
First, ensure that both systems synchronize their clocks, using for example the industry standard [Network Time Protocol (NTP)](http://en.wikipedia.org/wiki/Network_Time_Protocol).
582
582
583
-
Even then you may experience intermittent issues though, because the clock of the Identity Provider may drift slightly ahead of your system clocks. To allow fora small amount of clock drift you can initialize the response passingin an option named `:allowed_clock_drift`. Its value must be given in a number (and/or fraction) of seconds. The value given is added to the current time at which the response is validated before it's tested against the `NotBefore` assertion. For example:
583
+
Even then you may experience intermittent issues, as the clock of the Identity Provider may drift slightly ahead of your system clocks. To allow fora small amount of clock drift, you can initialize the response by passingin an option named `:allowed_clock_drift`. Its value must be given in a number (and/or fraction) of seconds. The value given is added to the current time at which the response is validated before it's tested against the `NotBefore` assertion. For example:
0 commit comments