Skip to content

Commit cff9c06

Browse files
committed
Fix Rubocop and minor typos
1 parent 3879a5e commit cff9c06

29 files changed

+2063
-1801
lines changed

UPGRADING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ how validation happens in the toolkit and also the toolkit by default will check
238238
when parsing a SAML Message (`settings.check_malformed_doc`).
239239

240240
The SignedDocument class defined at xml_security.rb experienced several changes.
241-
We don't expect compatibilty issues if you use the main methods offered by ruby-saml, but if
241+
We don't expect compatibility issues if you use the main methods offered by ruby-saml, but if
242242
you use a fork or customized usage, it is possible that you will need to adapt your code.
243243

244244
## Upgrading from 1.12.x to 1.13.0
@@ -276,7 +276,7 @@ Version `1.10.1` improves Ruby 1.8.7 support.
276276

277277
## Upgrading from 1.9.0 to 1.10.0
278278

279-
Version `1.10.0` improves IdpMetadataParser to allow parse multiple IDPSSODescriptor,
279+
Version `1.10.0` improves IdpMetadataParser to allow parsing multiple IDPSSODescriptor,
280280
Add Subject support on AuthNRequest to allow SPs provide info to the IdP about the user
281281
to be authenticated and updates the format_cert method to accept certs with /\x0d/
282282

lib/ruby_saml.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@
2121
require 'ruby_saml/version'
2222

2323
# @deprecated This module adds compatibility with v1.x and will be removed in v3.0.0
24-
unless defined?(::OneLogin)
25-
module OneLogin
26-
RubySaml = ::RubySaml
27-
end
24+
unless defined?(OneLogin)
25+
module OneLogin
26+
RubySaml = ::RubySaml
27+
end
2828
end
2929

30-
unless defined?(::OneLogin::RubySaml::Logging)
31-
module OneLogin
32-
module RubySaml
33-
Logging = ::RubySaml::Logging
34-
end
30+
unless defined?(OneLogin::RubySaml::Logging)
31+
module OneLogin
32+
module RubySaml
33+
Logging = ::RubySaml::Logging
3534
end
36-
end
35+
end
36+
end

lib/ruby_saml/attributes.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def add(name, values = [])
102102

103103
# Make comparable to another Attributes collection based on attributes
104104
# @param other [Attributes] An Attributes object to compare with
105-
# @return [Boolean] True if are contains the same attributes and values
105+
# @return [Boolean] True if it contains the same attributes and values
106106
#
107107
def ==(other)
108108
if other.is_a?(Attributes)

lib/ruby_saml/idp_metadata_parser.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def self.get_idps(noko_document, only_entity_id = nil)
3131
# IdP values
3232
#
3333
# @param url [String] Url where the XML of the Identity Provider Metadata is published.
34-
# @param validate_cert [Boolean] If true and the URL is HTTPs, the cert of the domain is checked.
34+
# @param validate_cert [Boolean] If true and the URL is HTTPS, the cert of the domain is checked.
3535
#
3636
# @param options [Hash] options used for parsing the metadata and the returned Settings instance
3737
# @option options [RubySaml::Settings, Hash] :settings the RubySaml::Settings object which gets the parsed metadata merged into or an hash for Settings overrides.
@@ -54,7 +54,7 @@ def parse_remote(url, validate_cert = true, options = {})
5454
# Parse the Identity Provider metadata and return the results as Hash
5555
#
5656
# @param url [String] Url where the XML of the Identity Provider Metadata is published.
57-
# @param validate_cert [Boolean] If true and the URL is HTTPs, the cert of the domain is checked.
57+
# @param validate_cert [Boolean] If true and the URL is HTTPS, the cert of the domain is checked.
5858
#
5959
# @param options [Hash] options used for parsing the metadata
6060
# @option options [String, nil] :entity_id when this is given, the entity descriptor for this ID is used. When omitted, the first entity descriptor is used.
@@ -75,7 +75,7 @@ def parse_remote_to_hash(url, validate_cert = true, options = {})
7575
# Parse all Identity Provider metadata and return the results as Array
7676
#
7777
# @param url [String] Url where the XML of the Identity Provider Metadata is published.
78-
# @param validate_cert [Boolean] If true and the URL is HTTPs, the cert of the domain is checked.
78+
# @param validate_cert [Boolean] If true and the URL is HTTPS, the cert of the domain is checked.
7979
#
8080
# @param options [Hash] options used for parsing the metadata
8181
# @option options [String, nil] :entity_id when this is given, the entity descriptor for this ID is used. When omitted, all found IdPs are returned.
@@ -116,7 +116,7 @@ def parse(idp_metadata, options = {})
116116
end
117117
end
118118
# Remove the cache_duration because on the settings
119-
# we only gonna suppot valid_until
119+
# we only going to support valid_until
120120
parsed_metadata.delete(:cache_duration)
121121

122122
settings = options[:settings]
@@ -174,7 +174,7 @@ def parse_to_idp_metadata_array(idp_metadata, options = {})
174174

175175
# Retrieve the remote IdP metadata from the URL or a cached copy.
176176
# @param url [String] Url where the XML of the Identity Provider Metadata is published.
177-
# @param validate_cert [Boolean] If true and the URL is HTTPs, the cert of the domain is checked.
177+
# @param validate_cert [Boolean] If true and the URL is HTTPS, the cert of the domain is checked.
178178
# @param options [Hash] Options used for requesting the remote URL
179179
# @option options [Numeric, nil] :open_timeout Number of seconds to wait for the connection to open. See Net::HTTP#open_timeout for more info. Default is the Net::HTTP default.
180180
# @option options [Numeric, nil] :read_timeout Number of seconds to wait for one block to be read. See Net::HTTP#read_timeout for more info. Default is the Net::HTTP default.
@@ -362,7 +362,7 @@ def certificates
362362
end
363363
end
364364

365-
# @return [String|nil] the fingerpint of the X509Certificate if it exists
365+
# @return [String|nil] the fingerprint of the X509Certificate if it exists
366366
#
367367
def fingerprint(certificate, fingerprint_algorithm = RubySaml::XML::SHA256)
368368
return unless certificate

lib/ruby_saml/logoutresponse.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ class Logoutresponse < SamlMessage
1818

1919
attr_accessor :soft
2020

21-
# Constructs the Logout Response. A Logout Response Object that is an extension of the SamlMessage class.
21+
# Constructs the Logout Response. A Logout Response object that is an extension of the SamlMessage class.
2222
# @param response [String] A UUEncoded logout response from the IdP.
2323
# @param settings [RubySaml::Settings|nil] Toolkit settings
2424
# @param options [Hash] Extra parameters.
2525
# :matches_request_id It will validate that the logout response matches the ID of the request.
2626
# :get_params GET Parameters, including the SAMLResponse
27-
# :relax_signature_validation to accept signatures if no idp certificate registered on settings
27+
# :relax_signature_validation to accept signatures if no IdP certificate registered on settings
2828
#
2929
# @raise [ArgumentError] if response is nil
3030
#
@@ -50,7 +50,7 @@ def response_id
5050
end
5151

5252
# Checks if the Status has the "Success" code
53-
# @return [Boolean] True if the StatusCode is Sucess
53+
# @return [Boolean] True if the StatusCode is Success
5454
# @raise [ValidationError] if soft == false and validation fails
5555
#
5656
def success?
@@ -145,7 +145,7 @@ def validate_structure
145145
end
146146

147147
# Validates that the Logout Response provided in the initialization is not empty,
148-
# also check that the setting and the IdP cert were also provided
148+
# also check that the settings and the IdP cert were also provided
149149
# @return [Boolean] True if the required info is found, otherwise False if soft=True
150150
# @raise [ValidationError] if soft == false and validation fails
151151
#
@@ -163,9 +163,9 @@ def valid_state?
163163
true
164164
end
165165

166-
# Validates if a provided :matches_request_id matchs the inResponseTo value.
166+
# Validates if a provided :matches_request_id matches the inResponseTo value.
167167
# @param soft [String|nil] request_id The ID of the Logout Request sent by this SP to the IdP (if was sent any)
168-
# @return [Boolean] True if there is no request_id or it match, otherwise False if soft=True
168+
# @return [Boolean] True if there is no request_id or it matches, otherwise False if soft=True
169169
# @raise [ValidationError] if soft == false and validation fails
170170
#
171171
def valid_in_response_to?
@@ -178,7 +178,7 @@ def valid_in_response_to?
178178
end
179179

180180
# Validates the Issuer of the Logout Response
181-
# @return [Boolean] True if the Issuer matchs the IdP entityId, otherwise False if soft=True
181+
# @return [Boolean] True if the Issuer matches the IdP entityId, otherwise False if soft=True
182182
# @raise [ValidationError] if soft == false and validation fails
183183
#
184184
def valid_issuer?

lib/ruby_saml/metadata.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class Metadata
1010
# Return SP metadata based on the settings.
1111
# @param settings [RubySaml::Settings|nil] Toolkit settings
1212
# @param pretty_print [Boolean] Pretty print or not the response
13-
# (No pretty print if you gonna validate the signature)
13+
# (No pretty print if you are going to validate the signature)
1414
# @param valid_until [DateTime] Metadata's valid time
1515
# @param cache_duration [Integer] Duration of the cache in seconds
1616
# @return [String] XML Metadata of the Service Provider

lib/ruby_saml/response.rb

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def initialize(response, options = {})
7070
end
7171

7272
# Validates the SAML Response with the default values (soft = true)
73-
# @param collect_errors [Boolean] Stop validation when first error appears or keep validating. (if soft=true)
73+
# @param collect_errors [Boolean] Stop validation when the first error appears or keep validating. (if soft=true)
7474
# @return [Boolean] TRUE if the SAML Response is valid
7575
#
7676
def is_valid?(collect_errors = false)
@@ -209,7 +209,7 @@ def authn_context_class_ref
209209
end
210210

211211
# Checks if the Status has the "Success" code
212-
# @return [Boolean] True if the StatusCode is Sucess
212+
# @return [Boolean] True if the StatusCode is Success
213213
#
214214
def success?
215215
status_code == 'urn:oasis:names:tc:SAML:2.0:status:Success'
@@ -430,7 +430,7 @@ def validate_structure
430430
end
431431

432432
# Validates that the SAML Response provided in the initialization is not empty,
433-
# also check that the setting and the IdP cert were also provided
433+
# also check that the settings and the IdP cert were also provided
434434
# @return [Boolean] True if the required info is found, false otherwise
435435
#
436436
def validate_response_state
@@ -515,7 +515,7 @@ def validate_no_duplicated_attributes
515515
# Validates the Signed elements
516516
# If fails, the error is added to the errors array
517517
# @return [Boolean] True if there is 1 or 2 Elements signed in the SAML Response
518-
# an are a Response or an Assertion Element, otherwise False if soft=True
518+
# and are a Response or an Assertion Element, otherwise False if soft=True
519519
#
520520
def validate_signed_elements
521521
signature_nodes = (decrypted_document.nil? ? document : decrypted_document).xpath(
@@ -574,9 +574,9 @@ def validate_signed_elements
574574
true
575575
end
576576

577-
# Validates if the provided request_id match the inResponseTo value.
577+
# Validates if the provided request_id matches the inResponseTo value.
578578
# If fails, the error is added to the errors array
579-
# @return [Boolean] True if there is no request_id or it match, otherwise False if soft=True
579+
# @return [Boolean] True if there is no request_id or it matches, otherwise False if soft=True
580580
# @raise [ValidationError] if soft == false and validation fails
581581
#
582582
def validate_in_response_to
@@ -655,7 +655,7 @@ def validate_one_conditions
655655

656656
# Checks that the samlp:Response/saml:Assertion/saml:AuthnStatement element exists and is unique.
657657
# If fails, the error is added to the errors array
658-
# @return [Boolean] True if there is a authnstatement element and is unique
658+
# @return [Boolean] True if there is a AuthnStatement element and is unique
659659
#
660660
def validate_one_authnstatement
661661
return true if options[:skip_authnstatement]
@@ -717,7 +717,7 @@ def validate_issuer
717717
true
718718
end
719719

720-
# Validates that the Session haven't expired (If the response was initialized with the :allowed_clock_drift option,
720+
# Validates that the Session hasn't expired (If the response was initialized with the :allowed_clock_drift option,
721721
# this time validation is relaxed by the allowed_clock_drift value)
722722
# If fails, the error is added to the errors array
723723
# @param soft [Boolean] soft Enable or Disable the soft mode (In order to raise exceptions when the response is invalid or not)
@@ -736,12 +736,12 @@ def validate_session_expiration
736736
true
737737
end
738738

739-
# Validates if exists valid SubjectConfirmation (If the response was initialized with the :allowed_clock_drift option,
740-
# timimg validation are relaxed by the allowed_clock_drift value. If the response was initialized with the
739+
# Validates if a valid SubjectConfirmation (If the response was initialized with the :allowed_clock_drift option,
740+
# timing validation are relaxed by the allowed_clock_drift value. If the response was initialized with the
741741
# :skip_subject_confirmation option, this validation is skipped)
742742
# There is also an optional Recipient check
743743
# If fails, the error is added to the errors array
744-
# @return [Boolean] True if exists a valid SubjectConfirmation, otherwise False if soft=True
744+
# @return [Boolean] True if a valid SubjectConfirmation, otherwise False if soft=True
745745
# @raise [ValidationError] if soft == false and validation fails
746746
#
747747
def validate_subject_confirmation
@@ -945,17 +945,17 @@ def signed_assertion
945945
@signed_assertion ||= cached_signed_assertion
946946
end
947947

948-
# Extracts the first appearance that matchs the subpath (pattern)
949-
# Search on any Assertion that is signed, or has a Response parent signed
948+
# Extracts the first appearance that matches the subpath (pattern)
949+
# Searches on any Assertion that is signed, or has a Response parent signed
950950
# @param subpath [String] The XPath pattern
951951
# @return [Nokogiri::XML::Element | nil] If any matches, return the Element
952952
def xpath_first_from_signed_assertion(subpath = nil)
953953
return if !subpath || subpath.empty?
954954
signed_assertion.at_xpath("./#{subpath}", SAML_NAMESPACES)
955955
end
956956

957-
# Extracts all the appearances that matchs the subpath (pattern)
958-
# Search on any Assertion that is signed, or has a Response parent signed
957+
# Extracts all the appearances that matches the subpath (pattern)
958+
# Searches on any Assertion that is signed, or has a Response parent signed
959959
# @param subpath [String] The XPath pattern
960960
# @return [Array of Nokogiri::XML::Element] Return all matches
961961
def xpath_from_signed_assertion(subpath = nil)

lib/ruby_saml/settings.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def get_fingerprint
130130
end
131131
end
132132

133-
# @return [OpenSSL::X509::Certificate|nil] Build the IdP certificate from the settings (previously format it)
133+
# @return [OpenSSL::X509::Certificate|nil] Build the IdP certificate from the settings (previously formatting it)
134134
#
135135
def get_idp_cert
136136
RubySaml::Utils.build_cert_object(idp_cert)
@@ -190,7 +190,7 @@ def get_sp_cert
190190
node[0] if node
191191
end
192192

193-
# @return [OpenSSL::PKey::RSA] The SP signing key.
193+
# @return [OpenSSL::PKey::PKey] The SP signing key.
194194
def get_sp_signing_key
195195
node = get_sp_signing_pair
196196
node[1] if node

lib/ruby_saml/slo_logoutrequest.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class SloLogoutrequest < SamlMessage
2424
# @param request [String] A UUEncoded Logout Request from the IdP.
2525
# @param options [Hash] :settings to provide the RubySaml::Settings object
2626
# Or :allowed_clock_drift for the logout request validation process to allow a clock drift when checking dates with
27-
# Or :relax_signature_validation to accept signatures if no idp certificate registered on settings
27+
# Or :relax_signature_validation to accept signatures if no IdP certificate registered on settings
2828
#
2929
# @raise [ArgumentError] If Request is nil
3030
#
@@ -49,7 +49,7 @@ def request_id
4949
end
5050

5151
# Validates the Logout Request with the default values (soft = true)
52-
# @param collect_errors [Boolean] Stop validation when first error appears or keep validating.
52+
# @param collect_errors [Boolean] Stop validation when the first error appears or keep validating.
5353
# @return [Boolean] TRUE if the Logout Request is valid
5454
#
5555
def is_valid?(collect_errors = false)
@@ -79,7 +79,7 @@ def name_id_node
7979
end
8080
end
8181

82-
# @return [String|nil] Gets the ID attribute from the Logout Request. if exists.
82+
# @return [String|nil] Gets the ID attribute from the Logout Request. if it exists.
8383
#
8484
def id
8585
super(document)
@@ -94,7 +94,7 @@ def issuer
9494
)&.text
9595
end
9696

97-
# @return [Time|nil] Gets the NotOnOrAfter Attribute value if exists.
97+
# @return [Time|nil] Gets the NotOnOrAfter Attribute value if it exists.
9898
#
9999
def not_on_or_after
100100
@not_on_or_after ||= begin
@@ -109,7 +109,7 @@ def not_on_or_after
109109
end
110110
end
111111

112-
# @return [Array] Gets the SessionIndex if exists (Supported multiple values). Empty Array if none found
112+
# @return [Array] Gets the SessionIndex if exists (Supports multiple values). Empty Array if none found
113113
#
114114
def session_indexes
115115
document.xpath(
@@ -127,7 +127,7 @@ def allowed_clock_drift
127127
end
128128

129129
# Hard aux function to validate the Logout Request
130-
# @param collect_errors [Boolean] Stop validation when first error appears or keep validating. (if soft=true)
130+
# @param collect_errors [Boolean] Stop validation when the first error appears or keep validating. (if soft=true)
131131
# @return [Boolean] TRUE if the Logout Request is valid
132132
# @raise [ValidationError] if soft == false and validation fails
133133
#
@@ -211,7 +211,7 @@ def validate_request_state
211211

212212
# Validates the Issuer of the Logout Request
213213
# If fails, the error is added to the errors array
214-
# @return [Boolean] True if the Issuer matchs the IdP entityId, otherwise False if soft=True
214+
# @return [Boolean] True if the Issuer matches the IdP entityId, otherwise False if soft=True
215215
# @raise [ValidationError] if soft == false and validation fails
216216
#
217217
def validate_issuer
@@ -224,8 +224,8 @@ def validate_issuer
224224
true
225225
end
226226

227-
# Validates the Signature if exists and GET parameters are provided
228-
# @return [Boolean] True if not contains a Signature or if the Signature is valid, otherwise False if soft=True
227+
# Validates the Signature if it exists and GET parameters are provided
228+
# @return [Boolean] True if does not contain a Signature or if the Signature is valid, otherwise False if soft=True
229229
# @raise [ValidationError] if soft == false and validation fails
230230
#
231231
def validate_signature

0 commit comments

Comments
 (0)