webfinger 1.1.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/FUNDING.yml +3 -0
- data/.github/workflows/spec.yml +32 -0
- data/README.rdoc +1 -3
- data/VERSION +1 -1
- data/lib/webfinger/exception.rb +1 -1
- data/lib/webfinger/request.rb +10 -11
- data/lib/webfinger.rb +10 -8
- data/spec/helpers/webmock_helper.rb +1 -1
- data/spec/webfinger_spec.rb +4 -4
- data/webfinger.gemspec +2 -1
- metadata +24 -14
- data/.travis.yml +0 -6
- data/lib/webfinger/debugger/request_filter.rb +0 -20
- data/lib/webfinger/debugger.rb +0 -3
- data/spec/webfinger/debugger/request_filter_spec.rb +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 453c181e3514a3c48a35bf9313439ce3e010b55381a825551563361e6ff1a10b
|
4
|
+
data.tar.gz: 6eea576a4c6402866a98ade6a92ab14f4823b81a03210b3ff156b800250f8c0a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a350849707db88ae1a09d9fb86e6fbb05a9b20528f1ed9ff726830aa2f17ac3fb31659d7c83eb1ec56ef3243966066812d65926de088e62ac6604304f258d14a
|
7
|
+
data.tar.gz: 4f52b74f9f365229dfa41017cf2e06ff8d5d1e6497f40fc8acda26630829a43cd3fbd005f25a3c263bbc19b886357b005cf6e2f1b4dd7b422d675eeb3849f535
|
data/.github/FUNDING.yml
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
name: Spec
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- master
|
7
|
+
pull_request:
|
8
|
+
|
9
|
+
permissions:
|
10
|
+
contents: read
|
11
|
+
|
12
|
+
jobs:
|
13
|
+
spec:
|
14
|
+
strategy:
|
15
|
+
matrix:
|
16
|
+
os: ['ubuntu-20.04']
|
17
|
+
ruby-version: ['2.6', '2.7', '3.0', '3.1']
|
18
|
+
# ubuntu 22.04 only supports ssl 3 and thus only ruby 3.1
|
19
|
+
include:
|
20
|
+
- os: 'ubuntu-22.04'
|
21
|
+
ruby-version: '3.1'
|
22
|
+
runs-on: ${{ matrix.os }}
|
23
|
+
|
24
|
+
steps:
|
25
|
+
- uses: actions/checkout@v3
|
26
|
+
- name: Set up Ruby
|
27
|
+
uses: ruby/setup-ruby@v1
|
28
|
+
with:
|
29
|
+
ruby-version: ${{ matrix.ruby-version }}
|
30
|
+
bundler-cache: true
|
31
|
+
- name: Run Specs
|
32
|
+
run: bundle exec rake spec
|
data/README.rdoc
CHANGED
@@ -2,8 +2,6 @@
|
|
2
2
|
|
3
3
|
An Ruby WebFinger client library.
|
4
4
|
|
5
|
-
{<img src="https://secure.travis-ci.org/nov/webfinger.png" />}[http://travis-ci.org/nov/webfinger]
|
6
|
-
|
7
5
|
Following the latest WebFinger spec discussed at IETF WebFinger WG.
|
8
6
|
http://tools.ietf.org/html/draft-ietf-appsawg-webfinger
|
9
7
|
|
@@ -75,4 +73,4 @@ You can also specify URL builder to force non-HTTPS access. (NOTE: allow non-HTT
|
|
75
73
|
|
76
74
|
== Copyright
|
77
75
|
|
78
|
-
Copyright (c) 2012 nov matake. See LICENSE for details.
|
76
|
+
Copyright (c) 2012 nov matake. See LICENSE for details.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
2.0.0
|
data/lib/webfinger/exception.rb
CHANGED
data/lib/webfinger/request.rb
CHANGED
@@ -10,7 +10,7 @@ module WebFinger
|
|
10
10
|
|
11
11
|
def discover!
|
12
12
|
handle_response do
|
13
|
-
WebFinger.http_client.
|
13
|
+
WebFinger.http_client.get(endpoint.to_s)
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
@@ -50,23 +50,22 @@ module WebFinger
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def handle_response
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
case e.res.try(:status)
|
53
|
+
json = yield.body
|
54
|
+
Response.new json
|
55
|
+
rescue Faraday::Error => e
|
56
|
+
case e.response_status
|
58
57
|
when nil
|
59
58
|
raise e
|
60
59
|
when 400
|
61
|
-
raise BadRequest.new('Bad Request',
|
60
|
+
raise BadRequest.new('Bad Request', e.response_body)
|
62
61
|
when 401
|
63
|
-
raise Unauthorized.new('Unauthorized',
|
62
|
+
raise Unauthorized.new('Unauthorized', e.response_body)
|
64
63
|
when 403
|
65
|
-
raise Forbidden.new('Forbidden',
|
64
|
+
raise Forbidden.new('Forbidden', e.response_body)
|
66
65
|
when 404
|
67
|
-
raise NotFound.new('Not Found',
|
66
|
+
raise NotFound.new('Not Found', e.response_body)
|
68
67
|
else
|
69
|
-
raise HttpError.new(e.
|
68
|
+
raise HttpError.new(e.response_status, e.response_body, e.response_body)
|
70
69
|
end
|
71
70
|
end
|
72
71
|
end
|
data/lib/webfinger.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'json'
|
2
|
-
require '
|
2
|
+
require 'faraday'
|
3
|
+
require 'faraday_middleware'
|
3
4
|
require 'active_support'
|
4
5
|
require 'active_support/core_ext'
|
5
6
|
|
@@ -42,19 +43,20 @@ module WebFinger
|
|
42
43
|
end
|
43
44
|
|
44
45
|
def http_client
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
46
|
+
Faraday.new(headers: {user_agent: "WebFinger #{VERSION}"}) do |f|
|
47
|
+
f.response :raise_error
|
48
|
+
f.response :json
|
49
|
+
f.response :logger, WebFinger.logger if debugging?
|
50
|
+
f.use FaradayMiddleware::FollowRedirects
|
51
|
+
http_config.try(:call, f)
|
52
|
+
end
|
51
53
|
end
|
54
|
+
|
52
55
|
def http_config(&block)
|
53
56
|
@http_config ||= block
|
54
57
|
end
|
55
58
|
end
|
56
59
|
|
57
|
-
require 'webfinger/debugger'
|
58
60
|
require 'webfinger/exception'
|
59
61
|
require 'webfinger/request'
|
60
62
|
require 'webfinger/response'
|
data/spec/webfinger_spec.rb
CHANGED
@@ -158,16 +158,16 @@ describe WebFinger do
|
|
158
158
|
subject { WebFinger.http_client }
|
159
159
|
|
160
160
|
describe '#request_filter' do
|
161
|
-
subject { WebFinger.http_client.
|
161
|
+
subject { WebFinger.http_client.builder.handlers.collect(&:klass) }
|
162
162
|
|
163
163
|
context 'as default' do
|
164
|
-
it { should_not include
|
164
|
+
it { should_not include Faraday::Response::Logger }
|
165
165
|
end
|
166
166
|
|
167
167
|
context 'when debugging' do
|
168
168
|
before { WebFinger.debug! }
|
169
|
-
it { should include
|
169
|
+
it { should include Faraday::Response::Logger }
|
170
170
|
end
|
171
171
|
end
|
172
172
|
end
|
173
|
-
end
|
173
|
+
end
|
data/webfinger.gemspec
CHANGED
@@ -12,7 +12,8 @@ Gem::Specification.new do |gem|
|
|
12
12
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
13
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
14
|
gem.require_paths = ['lib']
|
15
|
-
gem.add_runtime_dependency '
|
15
|
+
gem.add_runtime_dependency 'faraday', '~> 1.7'
|
16
|
+
gem.add_runtime_dependency 'faraday_middleware', '~> 1.1'
|
16
17
|
gem.add_runtime_dependency 'activesupport'
|
17
18
|
gem.add_development_dependency 'rake'
|
18
19
|
gem.add_development_dependency 'rspec'
|
metadata
CHANGED
@@ -1,29 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webfinger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nov matake
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-10-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: faraday
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '1.7'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: faraday_middleware
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
25
39
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
40
|
+
version: '1.1'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: activesupport
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -115,16 +129,15 @@ executables: []
|
|
115
129
|
extensions: []
|
116
130
|
extra_rdoc_files: []
|
117
131
|
files:
|
132
|
+
- ".github/FUNDING.yml"
|
133
|
+
- ".github/workflows/spec.yml"
|
118
134
|
- ".gitignore"
|
119
|
-
- ".travis.yml"
|
120
135
|
- Gemfile
|
121
136
|
- LICENSE.txt
|
122
137
|
- README.rdoc
|
123
138
|
- Rakefile
|
124
139
|
- VERSION
|
125
140
|
- lib/webfinger.rb
|
126
|
-
- lib/webfinger/debugger.rb
|
127
|
-
- lib/webfinger/debugger/request_filter.rb
|
128
141
|
- lib/webfinger/exception.rb
|
129
142
|
- lib/webfinger/request.rb
|
130
143
|
- lib/webfinger/response.rb
|
@@ -134,7 +147,6 @@ files:
|
|
134
147
|
- spec/mock_json/email_config.json
|
135
148
|
- spec/mock_json/open_id.json
|
136
149
|
- spec/spec_helper.rb
|
137
|
-
- spec/webfinger/debugger/request_filter_spec.rb
|
138
150
|
- spec/webfinger/response_spec.rb
|
139
151
|
- spec/webfinger_spec.rb
|
140
152
|
- webfinger.gemspec
|
@@ -157,8 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
157
169
|
- !ruby/object:Gem::Version
|
158
170
|
version: '0'
|
159
171
|
requirements: []
|
160
|
-
|
161
|
-
rubygems_version: 2.6.11
|
172
|
+
rubygems_version: 3.1.6
|
162
173
|
signing_key:
|
163
174
|
specification_version: 4
|
164
175
|
summary: Ruby WebFinger client library, following IETF WebFinger WG spec updates.
|
@@ -169,6 +180,5 @@ test_files:
|
|
169
180
|
- spec/mock_json/email_config.json
|
170
181
|
- spec/mock_json/open_id.json
|
171
182
|
- spec/spec_helper.rb
|
172
|
-
- spec/webfinger/debugger/request_filter_spec.rb
|
173
183
|
- spec/webfinger/response_spec.rb
|
174
184
|
- spec/webfinger_spec.rb
|
data/.travis.yml
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
module WebFinger
|
2
|
-
module Debugger
|
3
|
-
class RequestFilter
|
4
|
-
# Callback called in HTTPClient (before sending a request)
|
5
|
-
# request:: HTTP::Message
|
6
|
-
def filter_request(request)
|
7
|
-
started = "======= [WebFinger] HTTP REQUEST STARTED ======="
|
8
|
-
WebFinger.logger.info [started, request.dump].join("\n")
|
9
|
-
end
|
10
|
-
|
11
|
-
# Callback called in HTTPClient (after received a response)
|
12
|
-
# request:: HTTP::Message
|
13
|
-
# response:: HTTP::Message
|
14
|
-
def filter_response(request, response)
|
15
|
-
finished = "======= [WebFinger] HTTP REQUEST FINISHED ======="
|
16
|
-
WebFinger.logger.info ['-' * 50, response.dump, finished].join("\n")
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
data/lib/webfinger/debugger.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe WebFinger::Debugger::RequestFilter do
|
4
|
-
let(:resource_endpoint) { 'https://example.com/resources' }
|
5
|
-
let(:request) { HTTP::Message.new_request(:get, URI.parse(resource_endpoint)) }
|
6
|
-
let(:response) { HTTP::Message.new_response({:hello => 'world'}.to_json) }
|
7
|
-
let(:request_filter) { WebFinger::Debugger::RequestFilter.new }
|
8
|
-
|
9
|
-
describe '#filter_request' do
|
10
|
-
it 'should log request' do
|
11
|
-
expect(WebFinger.logger).to receive(:info).with(
|
12
|
-
"======= [WebFinger] HTTP REQUEST STARTED =======\n" +
|
13
|
-
request.dump
|
14
|
-
)
|
15
|
-
request_filter.filter_request(request)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe '#filter_response' do
|
20
|
-
it 'should log response' do
|
21
|
-
expect(WebFinger.logger).to receive(:info).with(
|
22
|
-
"--------------------------------------------------\n" +
|
23
|
-
response.dump +
|
24
|
-
"\n======= [WebFinger] HTTP REQUEST FINISHED ======="
|
25
|
-
)
|
26
|
-
request_filter.filter_response(request, response)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|