Skip to content

Commit

Permalink
Add Timeout protection
Browse files Browse the repository at this point in the history
Signed-off-by: Joshua Peek <josh@joshpeek.com>
  • Loading branch information
technoweenie authored and josh committed Apr 22, 2008
1 parent 8a0758c commit fb20816
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
@@ -1,3 +1,5 @@
* Add Timeout protection [Rick]

* An invalid identity url passed through authenticate_with_open_id will no longer raise an InvalidOpenId exception. Instead it will return Result[:missing] to the completion block.

* Allow a return_to option to be used instead of the requested url [Josh Peek]
Expand Down
1 change: 1 addition & 0 deletions lib/open_id_authentication.rb
@@ -1,6 +1,7 @@
require 'uri'
require 'openid/extensions/sreg'
require 'openid/store/filesystem'
require File.join(File.dirname(__FILE__), 'open_id_authentication/timeout_fixes') if OpenID::VERSION == "2.0.4"

module OpenIdAuthentication
OPEN_ID_AUTHENTICATION_DIR = RAILS_ROOT + "/tmp/openids"
Expand Down
20 changes: 20 additions & 0 deletions lib/open_id_authentication/timeout_fixes.rb
@@ -0,0 +1,20 @@
# http://trac.openidenabled.com/trac/ticket/156
module OpenID
@@timeout_threshold = 20

def self.timeout_threshold
@@timeout_threshold
end

def self.timeout_threshold=(value)
@@timeout_threshold = value
end

class StandardFetcher
def make_http(uri)
http = @proxy.new(uri.host, uri.port)
http.read_timeout = http.open_timeout = OpenID.timeout_threshold
http
end
end
end

0 comments on commit fb20816

Please sign in to comment.