@@ -53,7 +53,7 @@ can create an XML External Entity (XXE) vulnerability if the XML data is not tru
5353However, ruby-saml never enables this dangerous Nokogiri configuration;
5454ruby-saml never enables DTDLOAD, and it never disables NONET.
5555
56- The OneLogin:: RubySaml::IdpMetadataParser class does not validate in any way the URL
56+ The RubySaml::IdpMetadataParser class does not validate in any way the URL
5757that is introduced in order to be parsed.
5858
5959Usually the same administrator that handles the Service Provider also sets the URL to
@@ -87,13 +87,13 @@ gem install ruby-saml
8787You may require the entire Ruby SAML gem:
8888
8989``` ruby
90- require ' onelogin/ruby-saml '
90+ require ' ruby_saml '
9191```
9292
9393or just the required components individually:
9494
9595``` ruby
96- require ' onelogin/ruby-saml /authrequest'
96+ require ' ruby_saml /authrequest'
9797```
9898
9999### Installation on Ruby 1.8.7
@@ -124,7 +124,7 @@ To override the default behavior and control the destination of log messages, pr
124124a ruby Logger object to the gem' s logging singleton:
125125
126126` ` ` ruby
127- OneLogin:: RubySaml::Logging.logger = Logger.new(' /var/log/ruby-saml.log' )
127+ RubySaml::Logging.logger = Logger.new(' /var/log/ruby-saml.log' )
128128` ` `
129129
130130# # The Initialization Phase
@@ -136,7 +136,7 @@ like this (ignore the saml_settings method call for now):
136136
137137```ruby
138138def init
139- request = OneLogin:: RubySaml::Authrequest.new
139+ request = RubySaml::Authrequest.new
140140 redirect_to(request.create(saml_settings))
141141end
142142```
@@ -145,7 +145,7 @@ If the SP knows who should be authenticated in the IdP, then can provide that in
145145
146146```ruby
147147def init
148- request = OneLogin:: RubySaml::Authrequest.new
148+ request = RubySaml::Authrequest.new
149149 saml_settings.name_identifier_value_requested = "testuser@example.com"
150150 saml_settings.name_identifier_format = "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"
151151 redirect_to(request.create(saml_settings))
@@ -159,7 +159,7 @@ methods are specific to your application):
159159
160160` ` ` ruby
161161def consume
162- response = OneLogin:: RubySaml::Response.new(params[:SAMLResponse], :settings => saml_settings)
162+ response = RubySaml::Response.new(params[:SAMLResponse], :settings => saml_settings)
163163
164164 # We validate the SAML Response and check if the user already exists in the system
165165 if response.is_valid?
@@ -178,7 +178,7 @@ This is all handled with how you specify the settings that are in play via the `
178178That could be implemented along the lines of this:
179179
180180` ` `
181- response = OneLogin:: RubySaml::Response.new(params[:SAMLResponse])
181+ response = RubySaml::Response.new(params[:SAMLResponse])
182182response.settings = saml_settings
183183` ` `
184184
@@ -190,7 +190,7 @@ If you don't know what expect, always use the former (set the settings on initia
190190
191191```ruby
192192def saml_settings
193- settings = OneLogin:: RubySaml::Settings.new
193+ settings = RubySaml::Settings.new
194194
195195 settings.assertion_consumer_service_url = "http://#{request.host}/saml/consume"
196196 settings.sp_entity_id = "http://#{request.host}/saml/metadata"
@@ -221,16 +221,16 @@ end
221221
222222The use of settings.issuer is deprecated in favour of settings.sp_entity_id since version 1.11.0
223223
224- Some assertion validations can be skipped by passing parameters to `OneLogin:: RubySaml::Response.new()`.
224+ Some assertion validations can be skipped by passing parameters to `RubySaml::Response.new()`.
225225For example, you can skip the `AuthnStatement`, `Conditions`, `Recipient`, or the `SubjectConfirmation`
226226validations by initializing the response with different options:
227227
228228```ruby
229- response = OneLogin:: RubySaml::Response.new(params[:SAMLResponse], {skip_authnstatement: true}) # skips AuthnStatement
230- response = OneLogin:: RubySaml::Response.new(params[:SAMLResponse], {skip_conditions: true}) # skips conditions
231- response = OneLogin:: RubySaml::Response.new(params[:SAMLResponse], {skip_subject_confirmation: true}) # skips subject confirmation
232- 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
233- response = OneLogin:: RubySaml::Response.new(params[:SAMLResponse], {skip_audience: true}) # skips audience check
229+ response = RubySaml::Response.new(params[:SAMLResponse], {skip_authnstatement: true}) # skips AuthnStatement
230+ response = RubySaml::Response.new(params[:SAMLResponse], {skip_conditions: true}) # skips conditions
231+ response = RubySaml::Response.new(params[:SAMLResponse], {skip_subject_confirmation: true}) # skips subject confirmation
232+ response = 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
233+ response = RubySaml::Response.new(params[:SAMLResponse], {skip_audience: true}) # skips audience check
234234` ` `
235235
236236All that' s left is to wrap everything in a controller and reference it in the initialization and
@@ -240,12 +240,12 @@ consumption URLs in OneLogin. A full controller example could look like this:
240240# This controller expects you to use the URLs /saml/init and /saml/consume in your OneLogin application.
241241class SamlController < ApplicationController
242242 def init
243- request = OneLogin:: RubySaml::Authrequest.new
243+ request = RubySaml::Authrequest.new
244244 redirect_to(request.create(saml_settings))
245245 end
246246
247247 def consume
248- response = OneLogin:: RubySaml::Response.new(params[:SAMLResponse])
248+ response = RubySaml::Response.new(params[:SAMLResponse])
249249 response.settings = saml_settings
250250
251251 # We validate the SAML Response and check if the user already exists in the system
@@ -262,7 +262,7 @@ class SamlController < ApplicationController
262262 private
263263
264264 def saml_settings
265- settings = OneLogin:: RubySaml::Settings.new
265+ settings = RubySaml::Settings.new
266266
267267 settings.assertion_consumer_service_url = "http://#{request.host}/saml/consume"
268268 settings.sp_entity_id = "http://#{request.host}/saml/metadata"
@@ -335,8 +335,8 @@ Using `IdpMetadataParser#parse_remote`, the IdP metadata will be added to the se
335335` ` ` ruby
336336def saml_settings
337337
338- idp_metadata_parser = OneLogin:: RubySaml::IdpMetadataParser.new
339- # Returns OneLogin:: RubySaml::Settings pre-populated with IdP metadata
338+ idp_metadata_parser = RubySaml::IdpMetadataParser.new
339+ # Returns RubySaml::Settings pre-populated with IdP metadata
340340 settings = idp_metadata_parser.parse_remote(" https://example.com/auth/saml2/idp/metadata" )
341341
342342 settings.assertion_consumer_service_url = " http://#{request.host}/saml/consume"
@@ -397,7 +397,7 @@ by the values of binding and nameid:
397397
398398# ## Parsing Metadata into an Hash
399399
400- The ` OneLogin:: RubySaml::IdpMetadataParser` also provides the methods ` # parse_to_hash` and ` # parse_remote_to_hash` .
400+ The ` RubySaml::IdpMetadataParser` also provides the methods ` # parse_to_hash` and ` # parse_remote_to_hash` .
401401Those return an Hash instead of a ` Settings` object, which may be useful for configuring
402402[omniauth-saml](https://github.com/omniauth/omniauth-saml), for instance.
403403
@@ -412,11 +412,11 @@ but it can be done as follows:
412412
413413` ` ` ruby
414414require " xml_security"
415- require " onelogin/ruby-saml /utils"
416- require " onelogin/ruby-saml /idp_metadata_parser"
415+ require " ruby_saml /utils"
416+ require " ruby_saml /idp_metadata_parser"
417417
418418url = " <url_to_the_metadata>"
419- idp_metadata_parser = OneLogin:: RubySaml::IdpMetadataParser.new
419+ idp_metadata_parser = RubySaml::IdpMetadataParser.new
420420
421421uri = URI.parse(url)
422422raise ArgumentError.new(" url must begin with http or https" ) unless /^https? / =~ uri.scheme
@@ -433,7 +433,7 @@ xml = response.body
433433errors = []
434434doc = XMLSecurity::SignedDocument.new(xml, errors)
435435cert_str = " <include_cert_here>"
436- cert = OneLogin:: RubySaml::Utils.format_cert(" cert_str" )
436+ cert = RubySaml::Utils.format_cert(" cert_str" )
437437metadata_sign_cert = OpenSSL::X509::Certificate.new(cert)
438438valid = doc.validate_document_with_cert(metadata_sign_cert, true)
439439if valid
@@ -452,7 +452,7 @@ If you are using `saml:AttributeStatement` to transfer data like the username, y
452452` single_value_compatibility` (when activated, only the first value is returned)
453453
454454` ` ` ruby
455- response = OneLogin:: RubySaml::Response.new(params[:SAMLResponse])
455+ response = RubySaml::Response.new(params[:SAMLResponse])
456456response.settings = saml_settings
457457
458458response.attributes[:username]
@@ -492,7 +492,7 @@ Imagine this `saml:AttributeStatement`
492492` ` `
493493
494494` ` ` ruby
495- pp(response.attributes) # is an OneLogin:: RubySaml::Attributes object
495+ pp(response.attributes) # is an RubySaml::Attributes object
496496# => @attributes=
497497 {" uid" => [" demo" ],
498498 " another_value" => [" value1" , " value2" ],
@@ -502,7 +502,7 @@ pp(response.attributes) # is an OneLogin::RubySaml::Attributes object
502502 " http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname" => [" usersName" ]}>
503503
504504# Active single_value_compatibility
505- OneLogin:: RubySaml::Attributes.single_value_compatibility = true
505+ RubySaml::Attributes.single_value_compatibility = true
506506
507507pp(response.attributes[:uid])
508508# => "demo"
@@ -538,7 +538,7 @@ pp(response.attributes.fetch(/givenname/))
538538# => "usersName"
539539
540540# Deprecated single_value_compatibility
541- OneLogin:: RubySaml::Attributes.single_value_compatibility = false
541+ RubySaml::Attributes.single_value_compatibility = false
542542
543543pp(response.attributes[:uid])
544544# => ["demo"]
@@ -585,7 +585,7 @@ building the authrequest object.
585585To form a trusted pair relationship with the IdP, the SP (you) need to provide metadata XML
586586to the IdP for various good reasons. (Caching, certificate lookups, relaying party permissions, etc)
587587
588- 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.
588+ The class ` 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.
589589
590590The metadata will be polled by the IdP every few minutes, so updating your settings should propagate
591591to the IdP settings.
@@ -595,7 +595,7 @@ class SamlController < ApplicationController
595595 # ... the rest of your controller definitions ...
596596 def metadata
597597 settings = Account.get_saml_settings
598- meta = OneLogin:: RubySaml::Metadata.new
598+ meta = RubySaml::Metadata.new
599599 render :xml => meta.generate(settings), :content_type => " application/samlmetadata+xml"
600600 end
601601end
@@ -711,7 +711,7 @@ You may require SP and IdP certificates to be non-expired using the following se
711711 settings.security[:check_sp_cert_expiration] = true # Raise error SP X.509 cert is expired
712712```
713713
714- By default, Ruby SAML will raise a `OneLogin:: RubySaml::ValidationError` if a signature or certificate
714+ By default, Ruby SAML will raise a `RubySaml::ValidationError` if a signature or certificate
715715validation fails. You may disable such exceptions using the `settings.security[:soft]` parameter.
716716
717717```ruby
@@ -800,7 +800,7 @@ def sp_logout_request
800800 delete_session
801801 else
802802
803- logout_request = OneLogin:: RubySaml::Logoutrequest.new
803+ logout_request = RubySaml::Logoutrequest.new
804804 logger.info " New SP SLO for userid ' #{session[:userid]}' transactionid ' #{logout_request.uuid}' "
805805
806806 if settings.name_identifier_value.nil?
@@ -831,9 +831,9 @@ def process_logout_response
831831 settings = Account.get_saml_settings
832832
833833 if session.has_key? :transaction_id
834- logout_response = OneLogin:: RubySaml::Logoutresponse.new(params[:SAMLResponse], settings, :matches_request_id => session[:transaction_id])
834+ logout_response = RubySaml::Logoutresponse.new(params[:SAMLResponse], settings, :matches_request_id => session[:transaction_id])
835835 else
836- logout_response = OneLogin:: RubySaml::Logoutresponse.new(params[:SAMLResponse], settings)
836+ logout_response = RubySaml::Logoutresponse.new(params[:SAMLResponse], settings)
837837 end
838838
839839 logger.info " LogoutResponse is: #{logout_response.to_s}"
@@ -867,7 +867,7 @@ def idp_logout_request
867867 # uppercase. Turn it True for ADFS compatibility on signature verification
868868 settings.security[:lowercase_url_encoding] = true
869869
870- logout_request = OneLogin:: RubySaml::SloLogoutrequest.new(
870+ logout_request = RubySaml::SloLogoutrequest.new(
871871 params[:SAMLRequest], settings: settings
872872 )
873873 if !logout_request.is_valid?
@@ -881,7 +881,7 @@ def idp_logout_request
881881
882882 # Generate a response to the IdP.
883883 logout_request_id = logout_request.id
884- logout_response = OneLogin:: RubySaml::SloLogoutresponse.new.create(settings, logout_request_id, nil, :RelayState => params[:RelayState])
884+ logout_response = RubySaml::SloLogoutresponse.new.create(settings, logout_request_id, nil, :RelayState => params[:RelayState])
885885 redirect_to logout_response
886886end
887887` ` `
@@ -913,7 +913,7 @@ First, ensure that both systems synchronize their clocks, using for example the
913913Even 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:
914914
915915```ruby
916- response = OneLogin:: RubySaml::Response.new(params[:SAMLResponse], :allowed_clock_drift => 1.second)
916+ response = RubySaml::Response.new(params[:SAMLResponse], :allowed_clock_drift => 1.second)
917917```
918918
919919Make sure to keep the value as comfortably small as possible to keep security risks to a minimum.
@@ -928,14 +928,14 @@ Example:
928928
929929```ruby
930930def consume
931- response = OneLogin:: RubySaml::Response.new(params[:SAMLResponse], { settings: saml_settings })
931+ response = RubySaml::Response.new(params[:SAMLResponse], { settings: saml_settings })
932932 ...
933933end
934934
935935private
936936
937937def saml_settings
938- OneLogin:: RubySaml::Settings.new(message_max_bytesize: 500_000)
938+ RubySaml::Settings.new(message_max_bytesize: 500_000)
939939end
940940```
941941
944944To request attributes from the IdP the SP needs to provide an attribute service within it' s metadata and reference the index in the assertion.
945945
946946` ` ` ruby
947- settings = OneLogin:: RubySaml::Settings.new
947+ settings = RubySaml::Settings.new
948948settings.attributes_index = 5
949949settings.attribute_consuming_service.configure do
950950 service_name " Service"
@@ -959,11 +959,11 @@ The `attribute_value` option additionally accepts an array of possible values.
959959# # Custom Metadata Fields
960960
961961Some IdPs may require to add SPs to add additional fields (Organization, ContactPerson, etc.)
962- into the SP metadata. This can be achieved by extending the ` OneLogin:: RubySaml::Metadata`
962+ into the SP metadata. This can be achieved by extending the ` RubySaml::Metadata`
963963class and overriding the ` # add_extras` method as per the following example:
964964
965965` ` ` ruby
966- class MyMetadata < OneLogin:: RubySaml::Metadata
966+ class MyMetadata < RubySaml::Metadata
967967 def add_extras(root, _settings)
968968 org = root.add_element(" md:Organization" )
969969 org.add_element(" md:OrganizationName" , ' xml:lang' => " en-US" ).text = ' ACME Inc.'
0 commit comments