Parent

Namespace

Included Modules

Class/Module Index [+]

Quicksearch

HTTPClient::OAuth

Authentication filter for handling OAuth negotiation. Used in WWWAuth.

CAUTION: This impl only support '#7 Accessing Protected Resources' in OAuth Core 1.0 spec for now. You need to obtain Access token and Access secret by yourself.

CAUTION: This impl does NOT support OAuth Request Body Hash spec for now. oauth.googlecode.com/svn/spec/ext/body_hash/1.0/oauth-bodyhash.html

Attributes

scheme[R]

Authentication scheme.

Public Class Methods

new() click to toggle source

Creates new DigestAuth filter.

# File lib/httpclient/auth.rb, line 739
def initialize
  @config = nil # common config
  @auth = {} # configs for each site
  @challengeable = {}
  @nonce_count = 0
  @signature_handler = {
    'HMAC-SHA1' => method(:sign_hmac_sha1)
  }
  @scheme = "OAuth"
end

Public Instance Methods

challenge(uri, param_str = nil) click to toggle source

Challenge handler: remember URL for response.

# File lib/httpclient/auth.rb, line 804
def challenge(uri, param_str = nil)
  if uri.nil?
    @challengeable[nil] = true
  else
    @challengeable[urify(uri)] = true
  end
  true
end
escape(str) click to toggle source
# File lib/httpclient/auth.rb, line 734
def escape(str)
  self.class.escape(str)
end
get(req) click to toggle source

Response handler: returns credential. It sends cred only when a given uri is;

  • child page of challengeable(got *Authenticate before) uri and,

  • child page of defined credential

# File lib/httpclient/auth.rb, line 793
def get(req)
  target_uri = req.header.request_uri
  return nil unless @challengeable[nil] or @challengeable.find { |uri, ok|
    Util.uri_part_of(target_uri, uri) and ok
  }
  config = get_config(target_uri) || @config
  return nil unless config
  calc_cred(req, config)
end
get_config(uri = nil) click to toggle source

Get authentication credential.

# File lib/httpclient/auth.rb, line 778
def get_config(uri = nil)
  if uri.nil?
    @config
  else
    uri = urify(uri)
    Util.hash_find_value(@auth) { |cand_uri, cred|
      Util.uri_part_of(uri, cand_uri)
    }
  end
end
reset_challenge() click to toggle source

Resets challenge state. Do not send '*Authorization' header until the server sends '*Authentication' again.

# File lib/httpclient/auth.rb, line 752
def reset_challenge
  @challengeable.clear
end
set(*args) click to toggle source

Set authentication credential. You cannot set OAuth config via WWWAuth#set_auth. Use OAuth#config=

# File lib/httpclient/auth.rb, line 758
def set(*args)
  # not supported
end
set?() click to toggle source

have we marked this as set - ie that it's valid to use in this context?

# File lib/httpclient/auth.rb, line 763
def set?
  true
end
set_config(uri, config) click to toggle source

Set authentication credential.

# File lib/httpclient/auth.rb, line 768
def set_config(uri, config)
  if uri.nil?
    @config = config
  else
    uri = Util.uri_dirname(urify(uri))
    @auth[uri] = config
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.