Class: HTTPAuth::Digest::Session

Inherits:
Object
  • Object
show all
Defined in:
lib/httpauth/digest.rb

Overview

Session is a file-based session implementation for storing details about the Digest authentication session between requests.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opaque, options = {}) ⇒ Session

Initializes the new Session object.

  • opaque - A string to identify the session. This would normally be the opaque sent by the client, but it could also be an identifier sent through a different mechanism.

  • options - Additional options

    • :tmpdir A tempory directory for storing the session data. Dir::tmpdir is the default.



589
590
591
592
# File 'lib/httpauth/digest.rb', line 589

def initialize(opaque, options = {})
  self.opaque = opaque
  self.options = options
end

Instance Attribute Details

#opaqueObject

Returns the value of attribute opaque.



580
581
582
# File 'lib/httpauth/digest.rb', line 580

def opaque
  @opaque
end

#optionsObject

Returns the value of attribute options.



581
582
583
# File 'lib/httpauth/digest.rb', line 581

def options
  @options
end

Instance Method Details

#loadObject

Returns the data from this session



602
603
604
605
606
607
608
# File 'lib/httpauth/digest.rb', line 602

def load
  File.open(filename, 'r') do |f|
    Marshal.load f.read
  end
rescue Errno::ENOENT
  {}
end

#save(data) ⇒ Object

Associates the new data to the session and removes the old



595
596
597
598
599
# File 'lib/httpauth/digest.rb', line 595

def save(data)
  File.open(filename, 'w') do |f|
    f.write Marshal.dump(data)
  end
end