Skip to content

Commit d1d3aeb

Browse files
committed
Remove OneLogin namespace from code
1 parent 7c90d25 commit d1d3aeb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+4355
-4404
lines changed

.rubocop_todo.yml

Lines changed: 158 additions & 181 deletions
Large diffs are not rendered by default.

CHANGELOG.md

Lines changed: 135 additions & 130 deletions
Large diffs are not rendered by default.

Gemfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ source 'https://rubygems.org'
44

55
gemspec
66

7-
gem 'minitest', '~> 5.18', require: false
8-
gem 'mocha', '~> 2.0', require: false
7+
gem 'minitest', '~> 5.24', require: false
8+
gem 'mocha', '~> 2.4', require: false
99
gem 'rake', '~> 13.0'
1010
gem 'rubocop', '~> 1.64.1', require: false
1111
gem 'rubocop-minitest', '~> 0.35.0', require: false

README.md

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ can create an XML External Entity (XXE) vulnerability if the XML data is not tru
5353
However, ruby-saml never enables this dangerous Nokogiri configuration;
5454
ruby-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
5757
that is introduced in order to be parsed.
5858

5959
Usually the same administrator that handles the Service Provider also sets the URL to
@@ -87,13 +87,13 @@ gem install ruby-saml
8787
You may require the entire Ruby SAML gem:
8888

8989
```ruby
90-
require 'onelogin/ruby-saml'
90+
require 'ruby_saml'
9191
```
9292

9393
or 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
124124
a 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
138138
def init
139-
request = OneLogin::RubySaml::Authrequest.new
139+
request = RubySaml::Authrequest.new
140140
redirect_to(request.create(saml_settings))
141141
end
142142
```
@@ -145,7 +145,7 @@ If the SP knows who should be authenticated in the IdP, then can provide that in
145145
146146
```ruby
147147
def 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
161161
def 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 `
178178
That 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])
182182
response.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
192192
def 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
222222
The 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()`.
225225
For example, you can skip the `AuthnStatement`, `Conditions`, `Recipient`, or the `SubjectConfirmation`
226226
validations 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
236236
All 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.
241241
class 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
336336
def 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`.
401401
Those 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
414414
require "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
418418
url = "<url_to_the_metadata>"
419-
idp_metadata_parser = OneLogin::RubySaml::IdpMetadataParser.new
419+
idp_metadata_parser = RubySaml::IdpMetadataParser.new
420420
421421
uri = URI.parse(url)
422422
raise ArgumentError.new("url must begin with http or https") unless /^https?/ =~ uri.scheme
@@ -433,7 +433,7 @@ xml = response.body
433433
errors = []
434434
doc = XMLSecurity::SignedDocument.new(xml, errors)
435435
cert_str = "<include_cert_here>"
436-
cert = OneLogin::RubySaml::Utils.format_cert("cert_str")
436+
cert = RubySaml::Utils.format_cert("cert_str")
437437
metadata_sign_cert = OpenSSL::X509::Certificate.new(cert)
438438
valid = doc.validate_document_with_cert(metadata_sign_cert, true)
439439
if 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])
456456
response.settings = saml_settings
457457
458458
response.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
507507
pp(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
543543
pp(response.attributes[:uid])
544544
# => ["demo"]
@@ -585,7 +585,7 @@ building the authrequest object.
585585
To form a trusted pair relationship with the IdP, the SP (you) need to provide metadata XML
586586
to 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
590590
The metadata will be polled by the IdP every few minutes, so updating your settings should propagate
591591
to 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
601601
end
@@ -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
715715
validation 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
886886
end
887887
```
@@ -913,7 +913,7 @@ First, ensure that both systems synchronize their clocks, using for example the
913913
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:
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
919919
Make 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
930930
def consume
931-
response = OneLogin::RubySaml::Response.new(params[:SAMLResponse], { settings: saml_settings })
931+
response = RubySaml::Response.new(params[:SAMLResponse], { settings: saml_settings })
932932
...
933933
end
934934
935935
private
936936
937937
def saml_settings
938-
OneLogin::RubySaml::Settings.new(message_max_bytesize: 500_000)
938+
RubySaml::Settings.new(message_max_bytesize: 500_000)
939939
end
940940
```
941941
@@ -944,7 +944,7 @@ end
944944
To 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
948948
settings.attributes_index = 5
949949
settings.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
961961
Some 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`
963963
class 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.'

UPGRADING.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Ruby SAML Migration Guide
22

3+
## Updating from 1.17.x to 2.0.0
4+
5+
Before attempting to upgrade to `2.0.0`:
6+
- Upgrade your project to minimum Ruby 3.0, JRuby 9.4, or TruffleRuby 22.
7+
- Upgrade RubySaml to `1.17.x`. Note that RubySaml `1.17.x` is compatible with up to Ruby 3.3.
8+
9+
RubySaml version `2.0.0` changes the root namespace from `OneLogin::RubySaml::` to just `RubySaml::`. This will require you
10+
to search your codebase for the string `OneLogin::` and remove it as appropriate. Aside from this namespace change,
11+
the class names themselves have intentionally been kept the same.
12+
313
## Updating from 1.12.x to 1.13.0
414

515
Version `1.13.0` adds `settings.idp_sso_service_binding` and `settings.idp_slo_service_binding`, and
@@ -86,7 +96,7 @@ options = {
8696
"RelayState" => raw_query_params["RelayState"],
8797
},
8898
}
89-
slo_logout_request = OneLogin::RubySaml::SloLogoutrequest.new(query_params["SAMLRequest"], settings, options)
99+
slo_logout_request = RubySaml::SloLogoutrequest.new(query_params["SAMLRequest"], settings, options)
90100
raise "Invalid Logout Request" unless slo_logout_request.is_valid?
91101
```
92102

lib/ruby-saml.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# frozen_string_literal: true
22

3-
require 'onelogin/ruby-saml'
3+
require 'ruby_saml'

lib/ruby_saml.rb

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
# frozen_string_literal: true
22

3-
require 'onelogin/ruby-saml/logging'
4-
require 'onelogin/ruby-saml/saml_message'
5-
require 'onelogin/ruby-saml/authrequest'
6-
require 'onelogin/ruby-saml/logoutrequest'
7-
require 'onelogin/ruby-saml/logoutresponse'
8-
require 'onelogin/ruby-saml/attributes'
9-
require 'onelogin/ruby-saml/slo_logoutrequest'
10-
require 'onelogin/ruby-saml/slo_logoutresponse'
11-
require 'onelogin/ruby-saml/response'
12-
require 'onelogin/ruby-saml/settings'
13-
require 'onelogin/ruby-saml/attribute_service'
14-
require 'onelogin/ruby-saml/http_error'
15-
require 'onelogin/ruby-saml/validation_error'
16-
require 'onelogin/ruby-saml/metadata'
17-
require 'onelogin/ruby-saml/idp_metadata_parser'
18-
require 'onelogin/ruby-saml/utils'
19-
require 'onelogin/ruby-saml/version'
3+
require 'ruby_saml/logging'
4+
require 'ruby_saml/saml_message'
5+
require 'ruby_saml/authrequest'
6+
require 'ruby_saml/logoutrequest'
7+
require 'ruby_saml/logoutresponse'
8+
require 'ruby_saml/attributes'
9+
require 'ruby_saml/slo_logoutrequest'
10+
require 'ruby_saml/slo_logoutresponse'
11+
require 'ruby_saml/response'
12+
require 'ruby_saml/settings'
13+
require 'ruby_saml/attribute_service'
14+
require 'ruby_saml/http_error'
15+
require 'ruby_saml/validation_error'
16+
require 'ruby_saml/metadata'
17+
require 'ruby_saml/idp_metadata_parser'
18+
require 'ruby_saml/utils'
19+
require 'ruby_saml/version'

0 commit comments

Comments
 (0)