diff options
author | Joshua Peek <josh@joshpeek.com> | 2008-11-25 13:20:12 -0600 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2008-11-25 13:20:12 -0600 |
commit | 3dd3ffde06931d47e3052260efba26b1cc5bd7c9 (patch) | |
tree | fb9b6c0936428702febfc87ea959d71a142b76a4 /actionpack/lib/action_controller/vendor/rack-0.4.0/rack/auth/digest/nonce.rb | |
parent | d4754677a34d34d4a0955a04f2cc6571bdc5e82d (diff) | |
download | rails-3dd3ffde06931d47e3052260efba26b1cc5bd7c9.tar.gz rails-3dd3ffde06931d47e3052260efba26b1cc5bd7c9.tar.bz2 rails-3dd3ffde06931d47e3052260efba26b1cc5bd7c9.zip |
Depend on rack 0.4.0 instead of vendoring it
Diffstat (limited to 'actionpack/lib/action_controller/vendor/rack-0.4.0/rack/auth/digest/nonce.rb')
-rw-r--r-- | actionpack/lib/action_controller/vendor/rack-0.4.0/rack/auth/digest/nonce.rb | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/actionpack/lib/action_controller/vendor/rack-0.4.0/rack/auth/digest/nonce.rb b/actionpack/lib/action_controller/vendor/rack-0.4.0/rack/auth/digest/nonce.rb deleted file mode 100644 index dbe109f29a..0000000000 --- a/actionpack/lib/action_controller/vendor/rack-0.4.0/rack/auth/digest/nonce.rb +++ /dev/null @@ -1,51 +0,0 @@ -require 'digest/md5' - -module Rack - module Auth - module Digest - # Rack::Auth::Digest::Nonce is the default nonce generator for the - # Rack::Auth::Digest::MD5 authentication handler. - # - # +private_key+ needs to set to a constant string. - # - # +time_limit+ can be optionally set to an integer (number of seconds), - # to limit the validity of the generated nonces. - - class Nonce - - class << self - attr_accessor :private_key, :time_limit - end - - def self.parse(string) - new(*string.unpack("m*").first.split(' ', 2)) - end - - def initialize(timestamp = Time.now, given_digest = nil) - @timestamp, @given_digest = timestamp.to_i, given_digest - end - - def to_s - [([ @timestamp, digest ] * ' ')].pack("m*").strip - end - - def digest - ::Digest::MD5.hexdigest([ @timestamp, self.class.private_key ] * ':') - end - - def valid? - digest == @given_digest - end - - def stale? - !self.class.time_limit.nil? && (@timestamp - Time.now.to_i) < self.class.time_limit - end - - def fresh? - !stale? - end - - end - end - end -end |