Class: OAuth::RequestProxy::ActionControllerRequest — Documentation by YARD 0.9.45

# Class: OAuth::RequestProxy::ActionControllerRequest

Inherits:
  Base
  - Object
  - Base
  - OAuth::RequestProxy::ActionControllerRequest
  show all

Defined in:
  lib/oauth/request_proxy/action_controller_request.rb

## Instance Attribute Summary

### Attributes inherited from Base

#options, #request, #unsigned_parameters

## Instance Method Summary collapse

- #method ⇒ Object
- #parameters ⇒ Object
- #parameters_for_signature ⇒ Object

  Override from OAuth::RequestProxy::Base to avoid round-trip conversion to Hash or Array and thus preserve the original parameter names.

- #raw_post_signature? ⇒ Boolean
- #uri ⇒ Object

### Methods inherited from Base

#initialize, #non_oauth_parameters, #normalized_parameters, #normalized_uri, #oauth_callback, #oauth_consumer_key, #oauth_header, #oauth_nonce, #oauth_parameters, #oauth_signature, #oauth_signature_method, #oauth_timestamp, #oauth_token, #oauth_verifier, #oauth_version, proxies, #query_string_blank?, #sign, #sign!, #signature_and_unsigned_parameters, #signature_base_string, #signed?, #signed_uri

### Methods included from Helper

_escape, escape, generate_key, generate_timestamp, normalize, normalize_nested_query, parse_header, stringify_keys, unescape

## Constructor Details

This class inherits a constructor from OAuth::RequestProxy::Base

## Instance Method Details

### #method ⇒ `Object`

    14
    15
    16
    # File 'lib/oauth/request_proxy/action_controller_request.rb', line 14

    def method
      request.method.to_s.upcase
    end

### #parameters ⇒ `Object`

    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    # File 'lib/oauth/request_proxy/action_controller_request.rb', line 22

    def parameters
      if options[:clobber_request]
        options[:parameters] || {}
      else
        # Rails proxies should expose array-style values for params to align with
        # historical oauth gem behavior / specs. Header params remain scalars.
        rq = wrap_values(request_params)
        qq = wrap_values(query_params)
        params = rq.merge(qq).merge(header_params)
        params.stringify_keys! if params.respond_to?(:stringify_keys!)
        params.merge(options[:parameters] || {})
      end
    end

### #parameters_for_signature ⇒ `Object`

Override from OAuth::RequestProxy::Base to avoid round-trip
conversion to Hash or Array and thus preserve the original
parameter names

    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    # File 'lib/oauth/request_proxy/action_controller_request.rb', line 39

    def parameters_for_signature
      params = []
      params << options[:parameters].to_query if options[:parameters]

      unless options[:clobber_request]
        params << header_params.to_query
        params << request.query_string unless query_string_blank?

        params << request.raw_post if raw_post_signature?
      end

      params
        .join("&").split("&")
        .reject { |s| s.match(/\A\s*\z/) }
        .map { |p| p.split("=").map { |esc| CGI.unescape(esc) } }
        .reject { |kv| kv[0] == "oauth_signature" }
    end

### #raw_post_signature? ⇒ `Boolean`

Returns:

- (`Boolean`)

    57
    58
    59
    # File 'lib/oauth/request_proxy/action_controller_request.rb', line 57

    def raw_post_signature?
      (request.post? || request.put?) && request.content_type.to_s.downcase.start_with?("application/x-www-form-urlencoded")
    end

### #uri ⇒ `Object`

    18
    19
    20
    # File 'lib/oauth/request_proxy/action_controller_request.rb', line 18

    def uri
      options[:uri] || request.url
    end