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)
55 value = signature.verify
56 if request.ssl? && !value
57 http_request = request.dup
58 http_request.define_singleton_method(:scheme) { "http" }
59 http_request.define_singleton_method(:port) { 80 }
60 signature = OAuth::Signature.build(http_request, options, &block)
61 value = signature.verify
64 rescue OAuth::Signature::UnknownSignatureMethod
70 OAuth::Controllers::ProviderController.prepend(OpenStreetMap::ProviderController)
71 OAuth::Rack::OAuthFilter.prepend(OpenStreetMap::OAuthFilter)