faraday-digestauth 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +8 -0
- data/.travis.yml +15 -4
- data/Rakefile +1 -1
- data/faraday-digestauth.gemspec +3 -2
- data/lib/faraday/digestauth/version.rb +1 -1
- data/lib/faraday/request/digestauth.rb +5 -3
- data/spec/{faraday-digestauth_spec.rb → faraday/request/digest_auth_spec.rb} +25 -6
- metadata +40 -40
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f84765b37878c3063ae102b62617adc1c6be849180189a4f351c5e5780d5090f
|
4
|
+
data.tar.gz: d4a48a6028b2fa6171367deef0a26a161e35b90d751c3a349b701430e2e66f4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2d52fa4a06b7d19f86ccac137beea560a8d573f9f7bd7ee2d803b15f7766411d4fe8a6fb2111e67c816d0b9e4df49a5445950c47b7a063d019723a901959f7c
|
7
|
+
data.tar.gz: 7971345115f79833fb46660c6ad2a5d3d594d50cd59a41c2de823c1ea43c55eba60726eee8236128ecc65c77516b11ddb9359c38bc5faf8a39c5e1b63a457659
|
data/.rubocop.yml
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require: rubocop-rspec
|
2
|
+
|
1
3
|
AllCops:
|
2
4
|
Exclude:
|
3
5
|
- vendor/**/*
|
@@ -48,6 +50,12 @@ BlockNesting:
|
|
48
50
|
# TODO: fix too much nesting
|
49
51
|
Max: 4
|
50
52
|
|
53
|
+
Style/BlockLength:
|
54
|
+
Exclude:
|
55
|
+
- 'Rakefile'
|
56
|
+
- '**/*.rake'
|
57
|
+
- 'spec/**/*.rb'
|
58
|
+
|
51
59
|
Lambda:
|
52
60
|
# TODO: replace all lambda with -> or Proc
|
53
61
|
Enabled: false
|
data/.travis.yml
CHANGED
@@ -1,20 +1,31 @@
|
|
1
1
|
language: ruby
|
2
|
+
before_install:
|
3
|
+
- gem update --system
|
4
|
+
- gem update bundler
|
2
5
|
env:
|
3
6
|
global:
|
4
7
|
- "JRUBY_OPTS=-Xcext.enabled=true"
|
5
8
|
rvm:
|
6
|
-
-
|
7
|
-
-
|
9
|
+
- 1.8.7
|
10
|
+
- 1.9.2
|
8
11
|
- 1.9.3
|
12
|
+
- 2.0.0
|
13
|
+
- 2.1.0
|
14
|
+
- 2.2.0
|
15
|
+
- 2.3.0
|
16
|
+
- jruby-18mode
|
9
17
|
- jruby-19mode
|
10
|
-
- rbx-2.2.10
|
11
18
|
- ruby-head
|
12
19
|
- jruby-head
|
13
20
|
- ree
|
14
21
|
matrix:
|
15
22
|
allow_failures:
|
23
|
+
- rvm: 1.8.7
|
24
|
+
- rvm: 1.9.2
|
25
|
+
- rvm: 1.9.3
|
16
26
|
- rvm: ree
|
17
|
-
- rvm: ruby-head
|
18
27
|
- rvm: jruby-18mode
|
28
|
+
- rvm: jruby-19mode
|
19
29
|
- rvm: jruby-head
|
30
|
+
- rvm: ruby-head
|
20
31
|
fast_finish: true
|
data/Rakefile
CHANGED
data/faraday-digestauth.gemspec
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# coding: utf-8
|
2
|
+
|
2
3
|
lib = File.expand_path('../lib', __FILE__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
5
|
require 'faraday/digestauth/version'
|
@@ -21,9 +22,9 @@ Gem::Specification.new do |spec|
|
|
21
22
|
spec.add_dependency 'faraday', '~> 0.7'
|
22
23
|
spec.add_dependency 'net-http-digest_auth', '~> 1.4'
|
23
24
|
spec.add_development_dependency 'bundler', '~> 1.3'
|
25
|
+
spec.add_development_dependency 'coveralls', '~> 0.1'
|
24
26
|
spec.add_development_dependency 'rake', '~> 10'
|
25
27
|
spec.add_development_dependency 'rspec', '~> 3'
|
26
|
-
spec.add_development_dependency '
|
27
|
-
spec.add_development_dependency 'rubocop', '~> 0.26.1'
|
28
|
+
spec.add_development_dependency 'rubocop-rspec'
|
28
29
|
spec.add_development_dependency 'webmock', '~> 1'
|
29
30
|
end
|
@@ -31,7 +31,8 @@ module Faraday
|
|
31
31
|
# the original request body
|
32
32
|
def initialize(app, user, password, opts = {})
|
33
33
|
super(app)
|
34
|
-
@user
|
34
|
+
@user = user
|
35
|
+
@password = password
|
35
36
|
@opts = opts
|
36
37
|
end
|
37
38
|
|
@@ -45,6 +46,7 @@ module Faraday
|
|
45
46
|
def call(env)
|
46
47
|
response = handshake(env)
|
47
48
|
return response unless response.status == 401
|
49
|
+
return response unless response.headers['www-authenticate'] =~ /Digest +[^\s]+/
|
48
50
|
|
49
51
|
env[:request_headers]['Authorization'] = header(response)
|
50
52
|
@app.call(env)
|
@@ -70,8 +72,8 @@ module Faraday
|
|
70
72
|
# Returns a String with the DigestAuth header.
|
71
73
|
def header(response)
|
72
74
|
uri = response.env[:url]
|
73
|
-
uri.user = @user
|
74
|
-
uri.password = @password
|
75
|
+
uri.user = CGI.escape @user
|
76
|
+
uri.password = CGI.escape @password
|
75
77
|
|
76
78
|
realm = response.headers['www-authenticate']
|
77
79
|
method = response.env[:method].to_s.upcase
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
3
|
+
context Faraday::Request::DigestAuth do
|
4
4
|
let(:connection) do
|
5
5
|
Faraday.new('http://api.example.org/') do |builder|
|
6
6
|
builder.request :digest, 'USER', 'PASS'
|
@@ -12,27 +12,46 @@ describe Faraday::Request::DigestAuth do
|
|
12
12
|
it 'does nothing' do
|
13
13
|
stub_request(:get, 'http://api.example.org/productions/1')
|
14
14
|
.to_return(status: 500, body: 'Foo body')
|
15
|
-
|
16
15
|
response = connection.get('/productions/1')
|
17
16
|
expect(response.body).to eq 'Foo body'
|
18
17
|
end
|
19
18
|
end
|
20
19
|
|
21
|
-
describe 'when the server returns a 401' do
|
20
|
+
describe 'when the server returns a 401 without a digest authentication scheme' do
|
21
|
+
let(:first_call_headers) { 'Basic realm="MyApp"' }
|
22
|
+
let(:response) do
|
23
|
+
stub_request(:get, 'http://api.example.org/productions/1')
|
24
|
+
.with(body: nil)
|
25
|
+
.to_return(status: 401, headers: { 'www-authenticate' => first_call_headers })
|
26
|
+
connection.get('/productions/1')
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'returns empty body' do
|
30
|
+
expect(response.body).to be_empty
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'returns 401' do
|
34
|
+
expect(response.status).to eq 401
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe 'when the server returns a 401 with a digest authentication scheme' do
|
22
39
|
let(:first_call_headers) { 'Digest realm="MyApp", algorithm=MD5' }
|
23
40
|
let(:second_call_headers) { 'Digest username="USER", realm="MyApp", uri="/", algorithm="MD5"' }
|
24
|
-
|
41
|
+
let(:response) do
|
25
42
|
stub_request(:get, 'http://api.example.org/productions/1')
|
26
43
|
.with(body: nil)
|
27
44
|
.to_return(status: 401, headers: { 'www-authenticate' => first_call_headers })
|
28
|
-
|
29
45
|
stub_request(:get, 'http://api.example.org/productions/1')
|
30
46
|
.with(body: "{\"foo\":1}",
|
31
47
|
headers: { 'Authorization' => %r{second_call_headers} })
|
32
48
|
.to_return(body: '{"resource": "This is the resource"}',
|
33
49
|
headers: { content_type: 'application/json' })
|
34
|
-
|
35
50
|
connection.get('/productions/1')
|
36
51
|
end
|
52
|
+
|
53
|
+
it 'authenticates using digest' do
|
54
|
+
expect(response.body).to be_empty
|
55
|
+
end
|
37
56
|
end
|
38
57
|
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.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Haberer
|
@@ -9,118 +9,118 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2018-03-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - ~>
|
18
|
+
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '0.7'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- - ~>
|
25
|
+
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '0.7'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: net-http-digest_auth
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- - ~>
|
32
|
+
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '1.4'
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- - ~>
|
39
|
+
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '1.4'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: bundler
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- - ~>
|
46
|
+
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: '1.3'
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- - ~>
|
53
|
+
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '1.3'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
|
-
name:
|
57
|
+
name: coveralls
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
|
-
- - ~>
|
60
|
+
- - "~>"
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version: '
|
62
|
+
version: '0.1'
|
63
63
|
type: :development
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
|
-
- - ~>
|
67
|
+
- - "~>"
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: '
|
69
|
+
version: '0.1'
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
|
-
name:
|
71
|
+
name: rake
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
|
-
- - ~>
|
74
|
+
- - "~>"
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version: '
|
76
|
+
version: '10'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
|
-
- - ~>
|
81
|
+
- - "~>"
|
82
82
|
- !ruby/object:Gem::Version
|
83
|
-
version: '
|
83
|
+
version: '10'
|
84
84
|
- !ruby/object:Gem::Dependency
|
85
|
-
name:
|
85
|
+
name: rspec
|
86
86
|
requirement: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
|
-
- - ~>
|
88
|
+
- - "~>"
|
89
89
|
- !ruby/object:Gem::Version
|
90
|
-
version: '
|
90
|
+
version: '3'
|
91
91
|
type: :development
|
92
92
|
prerelease: false
|
93
93
|
version_requirements: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
|
-
- - ~>
|
95
|
+
- - "~>"
|
96
96
|
- !ruby/object:Gem::Version
|
97
|
-
version: '
|
97
|
+
version: '3'
|
98
98
|
- !ruby/object:Gem::Dependency
|
99
|
-
name: rubocop
|
99
|
+
name: rubocop-rspec
|
100
100
|
requirement: !ruby/object:Gem::Requirement
|
101
101
|
requirements:
|
102
|
-
- -
|
102
|
+
- - ">="
|
103
103
|
- !ruby/object:Gem::Version
|
104
|
-
version: 0
|
104
|
+
version: '0'
|
105
105
|
type: :development
|
106
106
|
prerelease: false
|
107
107
|
version_requirements: !ruby/object:Gem::Requirement
|
108
108
|
requirements:
|
109
|
-
- -
|
109
|
+
- - ">="
|
110
110
|
- !ruby/object:Gem::Version
|
111
|
-
version: 0
|
111
|
+
version: '0'
|
112
112
|
- !ruby/object:Gem::Dependency
|
113
113
|
name: webmock
|
114
114
|
requirement: !ruby/object:Gem::Requirement
|
115
115
|
requirements:
|
116
|
-
- - ~>
|
116
|
+
- - "~>"
|
117
117
|
- !ruby/object:Gem::Version
|
118
118
|
version: '1'
|
119
119
|
type: :development
|
120
120
|
prerelease: false
|
121
121
|
version_requirements: !ruby/object:Gem::Requirement
|
122
122
|
requirements:
|
123
|
-
- - ~>
|
123
|
+
- - "~>"
|
124
124
|
- !ruby/object:Gem::Version
|
125
125
|
version: '1'
|
126
126
|
description: Faraday extension to enable digest auth
|
@@ -131,11 +131,11 @@ executables: []
|
|
131
131
|
extensions: []
|
132
132
|
extra_rdoc_files: []
|
133
133
|
files:
|
134
|
-
- .gitignore
|
135
|
-
- .rspec
|
136
|
-
- .rubocop.yml
|
137
|
-
- .rubocop_todo.yml
|
138
|
-
- .travis.yml
|
134
|
+
- ".gitignore"
|
135
|
+
- ".rspec"
|
136
|
+
- ".rubocop.yml"
|
137
|
+
- ".rubocop_todo.yml"
|
138
|
+
- ".travis.yml"
|
139
139
|
- Gemfile
|
140
140
|
- LICENSE.txt
|
141
141
|
- README.md
|
@@ -145,7 +145,7 @@ files:
|
|
145
145
|
- lib/faraday/digestauth/connection.rb
|
146
146
|
- lib/faraday/digestauth/version.rb
|
147
147
|
- lib/faraday/request/digestauth.rb
|
148
|
-
- spec/faraday
|
148
|
+
- spec/faraday/request/digest_auth_spec.rb
|
149
149
|
- spec/spec_helper.rb
|
150
150
|
homepage: https://github.com/bhaberer/faraday-digestauth
|
151
151
|
licenses:
|
@@ -157,20 +157,20 @@ require_paths:
|
|
157
157
|
- lib
|
158
158
|
required_ruby_version: !ruby/object:Gem::Requirement
|
159
159
|
requirements:
|
160
|
-
- -
|
160
|
+
- - ">="
|
161
161
|
- !ruby/object:Gem::Version
|
162
162
|
version: '0'
|
163
163
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
164
164
|
requirements:
|
165
|
-
- -
|
165
|
+
- - ">="
|
166
166
|
- !ruby/object:Gem::Version
|
167
167
|
version: '0'
|
168
168
|
requirements: []
|
169
169
|
rubyforge_project:
|
170
|
-
rubygems_version: 2.
|
170
|
+
rubygems_version: 2.7.3
|
171
171
|
signing_key:
|
172
172
|
specification_version: 4
|
173
173
|
summary: Digest Auth for Faraday
|
174
174
|
test_files:
|
175
|
-
- spec/faraday
|
175
|
+
- spec/faraday/request/digest_auth_spec.rb
|
176
176
|
- spec/spec_helper.rb
|