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 +1 -1
- data/faraday-digestauth.gemspec +1 -0
- data/lib/faraday/digestauth.rb +2 -9
- data/lib/faraday/digestauth/version.rb +3 -1
- metadata +18 -2
data/README.md
CHANGED
data/faraday-digestauth.gemspec
CHANGED
data/lib/faraday/digestauth.rb
CHANGED
@@ -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
|
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.
|
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:
|
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
|