Skip to content

Commit

Permalink
fix for the invalid header race condition
Browse files Browse the repository at this point in the history
  • Loading branch information
jcast authored and jcasts committed Mar 22, 2011
1 parent 729b7d4 commit 4d6f5ee
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
5 changes: 4 additions & 1 deletion lib/mappoint/digest_auth.rb
Expand Up @@ -4,14 +4,17 @@ module MapPoint

module DigestAuth
@@nonce_count = Hash.new(0)

CNONCE = Digest::MD5.hexdigest("%x" % (Time.now.to_i + rand(65535)))

VALID_AUTH_HEADER = /^(\w+) (.*)/

# FIXME We need to clear out @@nonce_count every once in a
# great while, but I'm uncertain when the spec allows this.

# FIXME only works for POST
def self.gen_auth_header(uri, auth_header, user, password, is_IIS = false)
auth_header =~ /^(\w+) (.*)/
auth_header =~ VALID_AUTH_HEADER

params = {}
$2.gsub(/(\w+)=("[^"]*"|[^,]*)/) {
Expand Down
9 changes: 4 additions & 5 deletions lib/mappoint/service.rb
Expand Up @@ -56,12 +56,11 @@ def ns
{'xmlns' => "http://s.mappoint.net/mappoint-30/"}
end

# FIXME Race condition
def set_digest_header(http_response)
# FIXME we need to make sure this header exists, and throw a new
# error if it doesn't.
self.class.cached_digest_header =
http_response.headers['www-authenticate'][0]
auth_header = http_response.headers['www-authenticate'][0]
return unless auth_header =~ DigestAuth::VALID_AUTH_HEADER

self.class.cached_digest_header = auth_header
end

def digest_auth_header_from_response
Expand Down

5 comments on commit 4d6f5ee

@austinrfnd
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Jeremie, either AT&T still uses this stuff or you just love mappoint.

@jcasts
Copy link
Collaborator

@jcasts jcasts commented on 4d6f5ee Mar 23, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll let you take a wild guess

@jmhodges
Copy link
Owner

@jmhodges jmhodges commented on 4d6f5ee Mar 24, 2011 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jcasts
Copy link
Collaborator

@jcasts jcasts commented on 4d6f5ee Mar 24, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We actually pull this repo into our internal github server so we shouldn't need this one anymore in the future.

@jdunphy
Copy link
Collaborator

@jdunphy jdunphy commented on 4d6f5ee Mar 24, 2011 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.