[PATCH aeolus-image-rubygem] OAuth only binds to Factory requests
Jan Provaznik
jprovazn at redhat.com
Wed May 9 08:43:12 UTC 2012
On 05/08/2012 08:40 PM, Matt Wagner wrote:
> Previously, enabling OAuth for Image Factory would cause _all_
> requests flowing through ActiveResource to have OAuth headers
> added.
> ---
> lib/aeolus_image/active_resource_oauth_client.rb | 8 +++++++-
> 1 files changed, 7 insertions(+), 1 deletions(-)
>
> diff --git a/lib/aeolus_image/active_resource_oauth_client.rb b/lib/aeolus_image/active_resource_oauth_client.rb
> index e9b87d8..258ede9 100644
> --- a/lib/aeolus_image/active_resource_oauth_client.rb
> +++ b/lib/aeolus_image/active_resource_oauth_client.rb
> @@ -26,7 +26,7 @@ module ActiveResourceOAuthClient
> def request_with_oauth(method, path, *arguments)
> @oauth_config = Aeolus::Image::Factory::Base.config || {}
> # Take care to fall back to the standard request method if we don't have full OAuth credentials
> - unless Aeolus::Image::Factory::Base.use_oauth?
> + unless use_oauth_for_url?("#{site.scheme}://#{site.host}:#{site.port}#{path}")
> return request_without_oauth(method, path, *arguments)
> end
> result = ActiveSupport::Notifications.instrument("request.active_resource") do |payload|
> @@ -56,6 +56,12 @@ module ActiveResourceOAuthClient
> raise SSLError.new(e.message)
> end
>
> + # Currently, only Factory calls should use OAuth -- extend as needed
> + def use_oauth_for_url?(url)
> + Aeolus::Image::Factory::Base.use_oauth? and
> + url.include?(Aeolus::Image::Factory::Base.config[:site])
> + end
> +
> alias_method_chain :request, :oauth
>
> end
ACK
More information about the aeolus-devel
mailing list