1 require "oauth/controllers/provider_controller"
2 require "oauth/rack/oauth_filter"
4 Rails.configuration.middleware.use OAuth::Rack::OAuthFilter
9 value.to_s.gsub(OAuth::RESERVED_CHARACTERS) do |c|
10 format("%%%02X", c.ord)
18 request.request_method
25 module ProviderController
26 def self.prepended(mod)
28 mod.singleton_class.prepend(OpenStreetMap::ProviderController::ClassMethods)
31 def render(options = {})
32 text = options.delete(:text)
34 super options.merge(:plain => text)
35 elsif options.delete(:nothing)
36 status = options.delete(:status) || :ok
44 def included(controller)
45 controller.class_eval do
46 def self.before_filter(*names, &blk)
47 before_action(*names, &blk)
50 def self.skip_before_filter(*names, &blk)
51 skip_before_action(*names, &blk)
61 def oauth1_verify(request, options = {}, &block)
62 signature = OAuth::Signature.build(request, options, &block)
63 return false unless OauthNonce.remember(signature.request.nonce, signature.request.timestamp)
65 value = signature.verify
66 if request.ssl? && !value
67 http_request = request.dup
68 http_request.define_singleton_method(:scheme) { "http" }
69 http_request.define_singleton_method(:port) { 80 }
70 signature = OAuth::Signature.build(http_request, options, &block)
71 value = signature.verify
74 rescue OAuth::Signature::UnknownSignatureMethod
80 OAuth::Controllers::ProviderController.prepend(OpenStreetMap::ProviderController)
81 OAuth::Rack::OAuthFilter.prepend(OpenStreetMap::OAuthFilter)