Class HTTPAuth::Digest::AuthenticationInfo
In: lib/httpauth/digest.rb
Parent: AbstractHeader

The AuthenticationInfo class handles the Authentication-Info header. Sending Authentication-Info headers will allow the client to check the integrity of the response, but it isn‘t compulsory and will get in the way of pipelined retrieval of resources.

See the Digest module for examples

Methods

Public Class methods

Creates a new AuthenticationInfo instance based on the information from Credentials instance.

See initialize for valid options.

[Source]

     # File lib/httpauth/digest.rb, line 461
461:       def self.from_credentials(credentials, options={})
462:         auth_info = new credentials.h
463:         auth_info.update_from_credentials! options
464:         auth_info
465:       end

Parses the information from a Authentication-Info header and creates a new AuthenticationInfo instance with this data.

  • auth_info: The contents of the Authentication-Info header

See initialize for valid options.

[Source]

     # File lib/httpauth/digest.rb, line 453
453:       def self.from_header(auth_info, options={})
454:         new Utils.decode_directives(auth_info, :auth), options
455:       end

Create a new instance.

  • h: A Hash with directives, normally this is filled with the directives coming from a Credentials instance.
  • options: Used to set or override data from the Authentication-Info header
    • :response_body The body of the response that‘s going to be sent to the client. This is a compulsory option if the qop directive is ‘auth-int’.

[Source]

     # File lib/httpauth/digest.rb, line 474
474:       def initialize(h, options={})
475:         @h = h
476:         @h.merge! options
477:       end

Public Instance methods

Encodes directives and returns a string that can be used as the AuthorizationInfo header

[Source]

     # File lib/httpauth/digest.rb, line 480
480:       def to_header
481:         Utils.encode_directives Utils.filter_h_on(@h,
482:           [:nextnonce, :qop, :rspauth, :cnonce, :nc]), :auth
483:       end

Updates @h from options, generally called after an instance was created with from_credentials.

[Source]

     # File lib/httpauth/digest.rb, line 486
486:       def update_from_credentials!(options)
487:         # TODO: update @h after nonce invalidation
488:         @h[:response_body] = options[:response_body]
489:         @h[:nextnonce] = @h[:nc] + 1
490:       end

[Validate]