faraday-digestauth 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Faraday::Digestauth
1
+ # Faraday::DigestAuth
2
2
 
3
3
  This gem started as a direct copy of a gist belonging to @kapkaev
4
4
 
@@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_dependency 'faraday'
22
+ spec.add_dependency 'net-http-digest_auth'
22
23
 
23
24
  spec.add_development_dependency 'bundler', '~> 1.3'
24
25
  spec.add_development_dependency 'rake'
@@ -1,3 +1,4 @@
1
+ # -*- coding: utf-8 -*-
1
2
  require 'faraday'
2
3
  require 'faraday/digestauth/version'
3
4
  require 'net/http/digest_auth'
@@ -23,8 +24,6 @@ module Faraday
23
24
  # connection.digest_auth('USER', 'PASSWORD')
24
25
  #
25
26
  class Request::DigestAuth < Faraday::Middleware
26
-
27
-
28
27
  # Public: Initializes a DigestAuth.
29
28
  #
30
29
  # app - The Faraday app.
@@ -35,7 +34,6 @@ module Faraday
35
34
  @user, @password = user, password
36
35
  end
37
36
 
38
-
39
37
  # Public: Sends a first request with an empty body to get the
40
38
  # authentication headers and then send the same request with the body and
41
39
  # authorization header.
@@ -47,13 +45,12 @@ module Faraday
47
45
  response = handshake(env)
48
46
  return response unless response.status == 401
49
47
 
50
-
51
48
  env[:request_headers]['Authorization'] = header(response)
52
49
  @app.call(env)
53
50
  end
54
51
 
55
-
56
52
  private
53
+
57
54
  # Internal: Sends the the request with an empry body.
58
55
  #
59
56
  # env - A Hash with the request environment.
@@ -65,7 +62,6 @@ module Faraday
65
62
  @app.call(env_without_body)
66
63
  end
67
64
 
68
-
69
65
  # Internal: Builds the authorization header with the authentication data.
70
66
  #
71
67
  # response - A Faraday::Response with the authenticate headers.
@@ -76,11 +72,9 @@ module Faraday
76
72
  uri.user = @user
77
73
  uri.password = @password
78
74
 
79
-
80
75
  realm = response.headers['www-authenticate']
81
76
  method = response.env[:method].to_s.upcase
82
77
 
83
-
84
78
  Net::HTTP::DigestAuth.new.auth_header(uri, realm, method)
85
79
  end
86
80
  end
@@ -98,6 +92,5 @@ module Faraday
98
92
  end
99
93
  end
100
94
 
101
-
102
95
  # Register the middleware as a Request middleware with the name :digest
103
96
  Faraday.register_middleware :request, digest: Faraday::Request::DigestAuth
@@ -1,5 +1,7 @@
1
+ # -*- coding: utf-8 -*-
1
2
  module Faraday
3
+ # Versioning Info
2
4
  module DigestAuth
3
- VERSION = "0.0.1"
5
+ VERSION = '0.0.2'
4
6
  end
5
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: faraday-digestauth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-11-06 00:00:00.000000000 Z
13
+ date: 2014-02-14 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: faraday
@@ -28,6 +28,22 @@ dependencies:
28
28
  - - ! '>='
29
29
  - !ruby/object:Gem::Version
30
30
  version: '0'
31
+ - !ruby/object:Gem::Dependency
32
+ name: net-http-digest_auth
33
+ requirement: !ruby/object:Gem::Requirement
34
+ none: false
35
+ requirements:
36
+ - - ! '>='
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ type: :runtime
40
+ prerelease: false
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
31
47
  - !ruby/object:Gem::Dependency
32
48
  name: bundler
33
49
  requirement: !ruby/object:Gem::Requirement