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)
19 mod.singleton_class.prepend(OpenStreetMap::ProviderController::ClassMethods)
22 def render(options = {})
23 text = options.delete(:text)
25 super options.merge(:plain => text)
26 elsif options.delete(:nothing)
27 status = options.delete(:status) || :ok
35 def included(controller)
36 controller.class_eval do
37 def self.before_filter(*names, &blk)
38 before_action(*names, &blk)
41 def self.skip_before_filter(*names, &blk)
42 skip_before_action(*names, &blk)
52 def oauth1_verify(request, options = {}, &block)
53 signature = OAuth::Signature.build(request, options, &block)
54 return false unless OauthNonce.remember(signature.request.nonce, signature.request.timestamp)
56 value = signature.verify
57 if request.ssl? && !value
58 http_request = request.dup
59 http_request.define_singleton_method(:scheme) { "http" }
60 http_request.define_singleton_method(:port) { 80 }
61 signature = OAuth::Signature.build(http_request, options, &block)
62 value = signature.verify
65 rescue OAuth::Signature::UnknownSignatureMethod
71 OAuth::Controllers::ProviderController.prepend(OpenStreetMap::ProviderController)
72 OAuth::Rack::OAuthFilter.prepend(OpenStreetMap::OAuthFilter)