1 require "oauth/controllers/provider_controller"
2 require "oauth/rack/oauth_filter"
4 Rails.configuration.middleware.use OAuth::Rack::OAuthFilter
10 request.request_method
17 module ProviderController
18 def self.prepended(mod)
20 mod.singleton_class.prepend(OpenStreetMap::ProviderController::ClassMethods)
23 def render(options = {})
24 text = options.delete(:text)
26 super options.merge(:plain => text)
27 elsif options.delete(:nothing)
28 status = options.delete(:status) || :ok
36 def included(controller)
37 controller.class_eval do
38 def self.before_filter(*names, &blk)
39 before_action(*names, &blk)
42 def self.skip_before_filter(*names, &blk)
43 skip_before_action(*names, &blk)
53 def oauth1_verify(request, options = {}, &block)
54 signature = OAuth::Signature.build(request, options, &block)
55 return false unless OauthNonce.remember(signature.request.nonce, signature.request.timestamp)
57 value = signature.verify
58 if request.ssl? && !value
59 http_request = request.dup
60 http_request.define_singleton_method(:scheme) { "http" }
61 http_request.define_singleton_method(:port) { 80 }
62 signature = OAuth::Signature.build(http_request, options, &block)
63 value = signature.verify
66 rescue OAuth::Signature::UnknownSignatureMethod
72 OAuth::Controllers::ProviderController.prepend(OpenStreetMap::ProviderController)
73 OAuth::Rack::OAuthFilter.prepend(OpenStreetMap::OAuthFilter)