Module: SimpleOAuth::Header::Params
- Included in:
- SimpleOAuth::Header
- Defined in:
- lib/simple_oauth/header/params.rb,
sig/simple_oauth/header/params.rbs
Overview
Normalization of the parameters that are signed
Instance Method Summary collapse
-
#attributes ⇒ Header::signed_attributes_hash
Extracts valid OAuth attributes from options (excludes realm per RFC 5849).
-
#expanded_params ⇒ Array[untyped]
Expands parameters into one pair per value, for parameters with several values.
-
#normalized_params ⇒ String
Normalizes and sorts all request parameters for signing.
-
#signature_params ⇒ Array[untyped]
Collects all parameters to include in signature.
-
#url_params ⇒ Array[untyped]
Extracts query parameters from the request URL.
-
#validate_option_keys! ⇒ void
Validates that no unknown keys are present in options.
Instance Method Details
#attributes ⇒ Header::signed_attributes_hash
Extracts valid OAuth attributes from options (excludes realm per RFC 5849)
17 18 19 20 |
# File 'lib/simple_oauth/header/params.rb', line 17 def attributes validate_option_keys! .slice(*ATTRIBUTE_KEYS).transform_keys { |key| :"#{OAUTH_PREFIX}#{key}" } end |
#expanded_params ⇒ Array[untyped]
Expands parameters into one pair per value, for parameters with several values
72 73 74 75 76 |
# File 'lib/simple_oauth/header/params.rb', line 72 def params.flat_map do |key, value| value.is_a?(Array) ? value.map { |element| [key, element] } : [[key, value]] end end |
#normalized_params ⇒ String
Normalizes and sorts all request parameters for signing
52 53 54 55 56 57 58 |
# File 'lib/simple_oauth/header/params.rb', line 52 def normalized_params signature_params .map { |key, value| [Header.escape(key), Header.escape(value)] } .sort .map { |pair| pair.join("=") } .join("&") end |
#signature_params ⇒ Array[untyped]
Collects all parameters to include in signature
64 65 66 |
# File 'lib/simple_oauth/header/params.rb', line 64 def signature_params attributes.to_a + + url_params end |
#url_params ⇒ Array[untyped]
Extracts query parameters from the request URL
44 45 46 |
# File 'lib/simple_oauth/header/params.rb', line 44 def url_params Header.form_pairs(@uri.query) end |
#validate_option_keys! ⇒ void
This method returns an undefined value.
Validates that no unknown keys are present in options
27 28 29 30 31 32 33 34 |
# File 'lib/simple_oauth/header/params.rb', line 27 def validate_option_keys! return if [:ignore_extra_keys] extra_keys = .keys - ATTRIBUTE_KEYS - IGNORED_KEYS return if extra_keys.empty? raise InvalidOptionsError, "Unknown option keys: #{extra_keys.map(&:inspect).join(", ")}" end |