1 require "oauth/controllers/provider_controller"
3 require "oauth/rack/oauth_filter"
5 Rails.configuration.middleware.use OAuth::Rack::OAuthFilter
10 value.to_s.gsub(OAuth::RESERVED_CHARACTERS) do |c|
14 end.force_encoding(Encoding::US_ASCII)
21 request.request_method
28 module ProviderController
29 def self.prepended(mod)
31 mod.singleton_class.prepend(OpenStreetMap::ProviderController::ClassMethods)
34 def render(options = {})
35 text = options.delete(:text)
37 super options.merge(:plain => text)
38 elsif options.delete(:nothing)
39 status = options.delete(:status) || :ok
47 def included(controller)
48 controller.class_eval do
49 def self.before_filter(*names, &blk)
50 before_action(*names, &blk)
53 def self.skip_before_filter(*names, &blk)
54 skip_before_action(*names, &blk)
64 def oauth1_verify(request, options = {}, &block)
65 signature = OAuth::Signature.build(request, options, &block)
66 return false unless OauthNonce.remember(signature.request.nonce, signature.request.timestamp)
68 value = signature.verify
69 if request.ssl? && !value
70 http_request = request.dup
71 http_request.define_singleton_method(:scheme) { "http" }
72 http_request.define_singleton_method(:port) { 80 }
73 signature = OAuth::Signature.build(http_request, options, &block)
74 value = signature.verify
77 rescue OAuth::Signature::UnknownSignatureMethod
83 OAuth::Controllers::ProviderController.prepend(OpenStreetMap::ProviderController)
84 OAuth::Rack::OAuthFilter.prepend(OpenStreetMap::OAuthFilter)