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)
18 value.to_s.gsub(/%\h{2}/) do |c|
20 end.force_encoding(Encoding::UTF_8)
27 request.request_method
34 module ProviderController
35 def self.prepended(mod)
37 mod.singleton_class.prepend(OpenStreetMap::ProviderController::ClassMethods)
40 def render(options = {})
41 text = options.delete(:text)
43 super options.merge(:plain => text)
44 elsif options.delete(:nothing)
45 status = options.delete(:status) || :ok
53 def included(controller)
54 controller.class_eval do
55 def self.before_filter(*names, &blk)
56 before_action(*names, &blk)
59 def self.skip_before_filter(*names, &blk)
60 skip_before_action(*names, &blk)
70 def oauth1_verify(request, options = {}, &block)
71 signature = OAuth::Signature.build(request, options, &block)
72 return false unless OauthNonce.remember(signature.request.nonce, signature.request.timestamp)
74 value = signature.verify
75 if request.ssl? && !value
76 http_request = request.dup
77 http_request.define_singleton_method(:scheme) { "http" }
78 http_request.define_singleton_method(:port) { 80 }
79 signature = OAuth::Signature.build(http_request, options, &block)
80 value = signature.verify
83 rescue OAuth::Signature::UnknownSignatureMethod
89 OAuth::Controllers::ProviderController.prepend(OpenStreetMap::ProviderController)
90 OAuth::Rack::OAuthFilter.prepend(OpenStreetMap::OAuthFilter)