Skip to content

Commit a4f3cc8

Browse files
David JaressDavid Jaress
authored andcommitted
Update Readme
1 parent 260bdaf commit a4f3cc8

File tree

1 file changed

+30
-30
lines changed

1 file changed

+30
-30
lines changed

README.md

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ require 'onelogin/ruby-saml/authrequest'
9292

9393
### Installation on Ruby 1.8.7
9494

95-
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.
9696

9797
Using `Gemfile`
9898

@@ -121,7 +121,7 @@ OneLogin::RubySaml::Logging.logger = Logger.new(File.open('/var/log/ruby-saml.lo
121121

122122
## The Initialization Phase
123123

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 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):
125125
126126
```ruby
127127
def init
@@ -130,7 +130,7 @@ def init
130130
end
131131
```
132132
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):
134134

135135
```ruby
136136
def consume
@@ -147,17 +147,17 @@ def consume
147147
end
148148
```
149149
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:
153151
154152
```
155153
response = OneLogin::RubySaml::Response.new(params[:SAMLResponse])
156154
response.settings = saml_settings
157155
```
158-
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).
161161
162162
```ruby
163163
def saml_settings
@@ -184,14 +184,14 @@ def saml_settings
184184
end
185185
```
186186
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:
188188
189189
```ruby
190190
response = OneLogin::RubySaml::Response.new(params[:SAMLResponse], {skip_conditions: true}) # skips conditions
191191
response = OneLogin::RubySaml::Response.new(params[:SAMLResponse], {skip_subject_confirmation: true}) # skips subject confirmation
192192
```
193193
194-
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 in the initialization and consumption URLs in OneLogin. A full controller example could look like this:
195195
196196
```ruby
197197
# 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:
270270
* idp_slo_target_url
271271
* idp_cert_fingerprint
272272
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)
275275
276276
```ruby
277277
response = OneLogin::RubySaml::Response.new(params[:SAMLResponse])
@@ -280,7 +280,7 @@ response.settings = saml_settings
280280
response.attributes[:username]
281281
```
282282
283-
Imagine this saml:AttributeStatement
283+
Imagine this `saml:AttributeStatement`
284284
285285
```xml
286286
<saml:AttributeStatement>
@@ -380,15 +380,15 @@ pp(response.attributes.multi(:not_exists))
380380
# => nil
381381
```
382382
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 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`.
385385
386386
387387
## Signing
388388
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
390390
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:
392392
393393
```ruby
394394
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
414414
settings.security[:embed_sign] = false
415415
```
416416
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.
420420
421421
The Service Provider will sign the request/responses with its private key.
422422
The Identity Provider will validate the sign of the received request/responses with the public x500 cert of the
423423
Service Provider.
424424
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.
426426
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.
428428
429429
## Decrypting
430430
431431
The Ruby Toolkit supports EncryptedAssertion.
432432
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.
434434
435435
```ruby
436436
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
440440
The Identity Provider will encrypt the Assertion with the public cert of the Service Provider.
441441
The Service Provider will decrypt the EncryptedAssertion with its private key.
442442
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.
444444
445445
## Single Log Out
446446
447447
The Ruby Toolkit supports SP-initiated Single Logout and IdP-Initiated Single Logout.
448448
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:
450450
451451
```ruby
452452
# Create a SP initiated SLO
@@ -475,7 +475,7 @@ def sp_logout_request
475475
end
476476
```
477477
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:
479479
480480
```ruby
481481
# After sending an SP initiated LogoutRequest to the IdP, we need to accept
@@ -510,7 +510,7 @@ def delete_session
510510
end
511511
```
512512
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:
514514
515515
```ruby
516516
# Method to handle IdP initiated logouts
@@ -576,11 +576,11 @@ end
576576
577577
## Clock Drift
578578
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.
580580
581581
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).
582582
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 for a small amount of clock drift you can initialize the response passing in 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 for a small amount of clock drift, you can initialize the response by passing in 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:
584584
585585
```ruby
586586
response = OneLogin::RubySaml::Response.new(params[:SAMLResponse], :allowed_clock_drift => 1.second)

0 commit comments

Comments
 (0)