Skip to content

Commit

Permalink
Remove OneLogin namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnyshields committed Jul 8, 2024
1 parent ec20f55 commit 5c8fd1b
Show file tree
Hide file tree
Showing 40 changed files with 3,879 additions and 3,917 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Ruby SAML Changelog

### 2.0.0
* Remove OneLogin namespace. The root namespace of the gem is now "RubySaml".

### 1.17.0
* [#673](https://github.com/SAML-Toolkits/ruby-saml/pull/673) Add `Settings#sp_cert_multi` paramter to facilitate SP certificate and key rotation.
* [#673](https://github.com/SAML-Toolkits/ruby-saml/pull/673) Support multiple simultaneous SP decryption keys via `Settings#sp_cert_multi` parameter.
Expand Down
34 changes: 17 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ can create an XML External Entity (XXE) vulnerability if the XML data is not tru
However, ruby-saml never enables this dangerous Nokogiri configuration;
ruby-saml never enables DTDLOAD, and it never disables NONET.

The OneLogin::RubySaml::IdpMetadataParser class does not validate in any way the URL
The RubySaml::IdpMetadataParser class does not validate in any way the URL
that is introduced in order to be parsed.

Usually the same administrator that handles the Service Provider also sets the URL to
Expand Down Expand Up @@ -124,7 +124,7 @@ To override the default behavior and control the destination of log messages, pr
a ruby Logger object to the gem's logging singleton:

```ruby
OneLogin::RubySaml::Logging.logger = Logger.new('/var/log/ruby-saml.log')
RubySaml::Logging.logger = Logger.new('/var/log/ruby-saml.log')
```

## The Initialization Phase
Expand All @@ -136,7 +136,7 @@ like this (ignore the saml_settings method call for now):
```ruby
def init
request = OneLogin::RubySaml::Authrequest.new
request = RubySaml::Authrequest.new
redirect_to(request.create(saml_settings))
end
```
Expand All @@ -145,7 +145,7 @@ If the SP knows who should be authenticated in the IdP, then can provide that in
```ruby
def init
request = OneLogin::RubySaml::Authrequest.new
request = RubySaml::Authrequest.new
saml_settings.name_identifier_value_requested = "testuser@example.com"
saml_settings.name_identifier_format = "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"
redirect_to(request.create(saml_settings))
Expand All @@ -159,7 +159,7 @@ methods are specific to your application):

```ruby
def consume
response = OneLogin::RubySaml::Response.new(params[:SAMLResponse], :settings => saml_settings)
response = RubySaml::Response.new(params[:SAMLResponse], :settings => saml_settings)
# We validate the SAML Response and check if the user already exists in the system
if response.is_valid?
Expand All @@ -178,7 +178,7 @@ This is all handled with how you specify the settings that are in play via the `
That could be implemented along the lines of this:
```
response = OneLogin::RubySaml::Response.new(params[:SAMLResponse])
response = RubySaml::Response.new(params[:SAMLResponse])
response.settings = saml_settings
```
Expand All @@ -190,7 +190,7 @@ If you don't know what expect, always use the former (set the settings on initia
```ruby
def saml_settings
settings = OneLogin::RubySaml::Settings.new
settings = RubySaml::Settings.new
settings.assertion_consumer_service_url = "http://#{request.host}/saml/consume"
settings.sp_entity_id = "http://#{request.host}/saml/metadata"
Expand Down Expand Up @@ -221,16 +221,16 @@ end
The use of settings.issuer is deprecated in favour of settings.sp_entity_id since version 1.11.0
Some assertion validations can be skipped by passing parameters to `OneLogin::RubySaml::Response.new()`.
Some assertion validations can be skipped by passing parameters to `RubySaml::Response.new()`.
For example, you can skip the `AuthnStatement`, `Conditions`, `Recipient`, or the `SubjectConfirmation`
validations by initializing the response with different options:
```ruby
response = OneLogin::RubySaml::Response.new(params[:SAMLResponse], {skip_authnstatement: true}) # skips AuthnStatement
response = OneLogin::RubySaml::Response.new(params[:SAMLResponse], {skip_conditions: true}) # skips conditions
response = OneLogin::RubySaml::Response.new(params[:SAMLResponse], {skip_subject_confirmation: true}) # skips subject confirmation
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
response = OneLogin::RubySaml::Response.new(params[:SAMLResponse], {skip_audience: true}) # skips audience check
response = RubySaml::Response.new(params[:SAMLResponse], {skip_authnstatement: true}) # skips AuthnStatement
response = RubySaml::Response.new(params[:SAMLResponse], {skip_conditions: true}) # skips conditions
response = RubySaml::Response.new(params[:SAMLResponse], {skip_subject_confirmation: true}) # skips subject confirmation
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
response = RubySaml::Response.new(params[:SAMLResponse], {skip_audience: true}) # skips audience check
```
All that's left is to wrap everything in a controller and reference it in the initialization and
Expand All @@ -240,12 +240,12 @@ consumption URLs in OneLogin. A full controller example could look like this:
# This controller expects you to use the URLs /saml/init and /saml/consume in your OneLogin application.
class SamlController < ApplicationController
def init
request = OneLogin::RubySaml::Authrequest.new
request = RubySaml::Authrequest.new
redirect_to(request.create(saml_settings))
end
def consume
response = OneLogin::RubySaml::Response.new(params[:SAMLResponse])
response = RubySaml::Response.new(params[:SAMLResponse])
response.settings = saml_settings
# We validate the SAML Response and check if the user already exists in the system
Expand All @@ -262,7 +262,7 @@ class SamlController < ApplicationController
private
def saml_settings
settings = OneLogin::RubySaml::Settings.new
settings = RubySaml::Settings.new
settings.assertion_consumer_service_url = "http://#{request.host}/saml/consume"
settings.sp_entity_id = "http://#{request.host}/saml/metadata"
Expand Down Expand Up @@ -335,7 +335,7 @@ Using `IdpMetadataParser#parse_remote`, the IdP metadata will be added to the se
```ruby
def saml_settings
idp_metadata_parser = OneLogin::RubySaml::IdpMetadataParser.new
idp_metadata_parser = RubySaml::IdpMetadataParser.new
# Returns OneLogin::RubySaml::Settings pre-populated with IdP metadata
settings = idp_metadata_parser.parse_remote("https://example.com/auth/saml2/idp/metadata")
Expand Down
2 changes: 1 addition & 1 deletion UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ options = {
"RelayState" => raw_query_params["RelayState"],
},
}
slo_logout_request = OneLogin::RubySaml::SloLogoutrequest.new(query_params["SAMLRequest"], settings, options)
slo_logout_request = RubySaml::SloLogoutrequest.new(query_params["SAMLRequest"], settings, options)
raise "Invalid Logout Request" unless slo_logout_request.is_valid?
```

Expand Down
102 changes: 50 additions & 52 deletions lib/onelogin/ruby-saml/attribute_service.rb
Original file line number Diff line number Diff line change
@@ -1,59 +1,57 @@
# frozen_string_literal: true

module OneLogin
module RubySaml
module RubySaml

# SAML2 AttributeService. Auxiliary class to build the AttributeService of the SP Metadata
# SAML2 AttributeService. Auxiliary class to build the AttributeService of the SP Metadata
#
class AttributeService
attr_reader :attributes
attr_reader :name
attr_reader :index

# Initializes the AttributeService, set the index value as 1 and an empty array as attributes
#
def initialize
@index = "1"
@attributes = []
end

def configure(&block)
instance_eval(&block)
end

# @return [Boolean] True if the AttributeService object has been initialized and set with the required values
# (has attributes and a name)
def configured?
!@attributes.empty? && !@name.nil?
end

# Set a name to the service
# @param name [String] The service name
#
def service_name(name)
@name = name
end

# Set an index to the service
# @param index [Integer] An index
#
def service_index(index)
@index = index
end

# Add an AttributeService
# @param options [Hash] AttributeService option values
# add_attribute(
# :name => "Name",
# :name_format => "Name Format",
# :index => 1,
# :friendly_name => "Friendly Name",
# :attribute_value => "Attribute Value"
# )
#
class AttributeService
attr_reader :attributes
attr_reader :name
attr_reader :index

# Initializes the AttributeService, set the index value as 1 and an empty array as attributes
#
def initialize
@index = "1"
@attributes = []
end

def configure(&block)
instance_eval(&block)
end

# @return [Boolean] True if the AttributeService object has been initialized and set with the required values
# (has attributes and a name)
def configured?
!@attributes.empty? && !@name.nil?
end

# Set a name to the service
# @param name [String] The service name
#
def service_name(name)
@name = name
end

# Set an index to the service
# @param index [Integer] An index
#
def service_index(index)
@index = index
end

# Add an AttributeService
# @param options [Hash] AttributeService option values
# add_attribute(
# :name => "Name",
# :name_format => "Name Format",
# :index => 1,
# :friendly_name => "Friendly Name",
# :attribute_value => "Attribute Value"
# )
#
def add_attribute(options={})
attributes << options
end
def add_attribute(options={})
attributes << options
end
end
end
Loading

0 comments on commit 5c8fd1b

Please sign in to comment.