openid_connect 0.4.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0a794ead00a4df88df6f42e75c8fbab30e8bc31a
4
+ data.tar.gz: 6d6a735d8d0fd25b23c3b77cbe847eedc46408fc
5
+ SHA512:
6
+ metadata.gz: e163661d484cf04fb02660783affd6ffab261dade19166c9d22acc0a1ce69eb65f451653f93b313ce454360bbdf52864de09801ce79783ffc860cd19fba381fc
7
+ data.tar.gz: cda7908012fd20d5ffdb8e3e73afe149dae37741779d653264f0318c9931520189b5308cf51f22fc9fa6ffaaec1db99b28b232842435c3586d1a24d62cf64ff6
data/Gemfile CHANGED
@@ -1,2 +1,2 @@
1
- source :rubygems
1
+ source 'https://rubygems.org'
2
2
  gemspec
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- openid_connect (0.4.1)
4
+ openid_connect (0.5.0)
5
5
  activemodel (>= 3)
6
6
  attr_required (>= 0.0.5)
7
7
  json (>= 1.4.3)
@@ -11,59 +11,60 @@ PATH
11
11
  tzinfo
12
12
  validate_email
13
13
  validate_url
14
+ webfinger (>= 0.0.2)
14
15
 
15
16
  GEM
16
- remote: http://rubygems.org/
17
+ remote: https://rubygems.org/
17
18
  specs:
18
- activemodel (3.2.9)
19
- activesupport (= 3.2.9)
19
+ activemodel (3.2.12)
20
+ activesupport (= 3.2.12)
20
21
  builder (~> 3.0.0)
21
- activesupport (3.2.9)
22
+ activesupport (3.2.12)
22
23
  i18n (~> 0.6)
23
24
  multi_json (~> 1.0)
24
- addressable (2.3.2)
25
+ addressable (2.3.3)
25
26
  attr_required (0.0.5)
26
27
  builder (3.0.4)
27
- configatron (2.9.1)
28
+ configatron (2.10.0)
28
29
  yamler (>= 0.1.0)
29
30
  cover_me (1.2.0)
30
31
  configatron
31
32
  hashie
32
- crack (0.3.1)
33
- diff-lcs (1.1.3)
34
- hashie (1.2.0)
35
- httpclient (2.3.0.1)
36
- i18n (0.6.1)
37
- json (1.7.5)
38
- json-jwt (0.4.0)
33
+ crack (0.3.2)
34
+ diff-lcs (1.2.1)
35
+ hashie (2.0.2)
36
+ httpclient (2.3.3)
37
+ i18n (0.6.4)
38
+ json (1.7.7)
39
+ json-jwt (0.4.2)
39
40
  activesupport (>= 2.3)
40
41
  i18n
41
- json (>= 1.4.3)
42
+ multi_json (>= 1.3)
42
43
  url_safe_base64
43
44
  mail (2.5.3)
44
45
  i18n (>= 0.4.0)
45
46
  mime-types (~> 1.16)
46
47
  treetop (~> 1.4.8)
47
- mime-types (1.19)
48
- multi_json (1.5.0)
48
+ mime-types (1.21)
49
+ multi_json (1.6.1)
49
50
  polyglot (0.3.3)
50
- rack (1.4.1)
51
- rack-oauth2 (1.0.0)
51
+ rack (1.5.2)
52
+ rack-oauth2 (1.0.3)
52
53
  activesupport (>= 2.3)
53
54
  attr_required (>= 0.0.5)
54
55
  httpclient (>= 2.2.0.2)
55
56
  i18n
56
57
  multi_json (>= 1.3.6)
57
58
  rack (>= 1.1)
58
- rake (10.0.2)
59
- rspec (2.12.0)
60
- rspec-core (~> 2.12.0)
61
- rspec-expectations (~> 2.12.0)
62
- rspec-mocks (~> 2.12.0)
63
- rspec-core (2.12.1)
64
- rspec-expectations (2.12.0)
65
- diff-lcs (~> 1.1.3)
66
- rspec-mocks (2.12.0)
59
+ rake (10.0.3)
60
+ rspec (2.13.0)
61
+ rspec-core (~> 2.13.0)
62
+ rspec-expectations (~> 2.13.0)
63
+ rspec-mocks (~> 2.13.0)
64
+ rspec-core (2.13.0)
65
+ rspec-expectations (2.13.0)
66
+ diff-lcs (>= 1.1.3, < 2.0)
67
+ rspec-mocks (2.13.0)
67
68
  swd (0.2.1)
68
69
  activesupport (>= 3)
69
70
  attr_required (>= 0.0.5)
@@ -80,9 +81,13 @@ GEM
80
81
  mail (>= 2.2.5)
81
82
  validate_url (0.2.0)
82
83
  activemodel (>= 3.0.0)
83
- webmock (1.9.0)
84
+ webfinger (0.0.4)
85
+ activesupport (>= 3)
86
+ httpclient (>= 2.2.0.2)
87
+ multi_json
88
+ webmock (1.10.1)
84
89
  addressable (>= 2.2.7)
85
- crack (>= 0.1.7)
90
+ crack (>= 0.3.2)
86
91
  yamler (0.1.0)
87
92
 
88
93
  PLATFORMS
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.1
1
+ 0.5.0
@@ -1,6 +1,7 @@
1
1
  require 'json'
2
2
  require 'logger'
3
3
  require 'swd'
4
+ require 'webfinger'
4
5
  require 'active_model'
5
6
  require 'tzinfo'
6
7
  require 'validate_url'
@@ -156,7 +156,8 @@ module OpenIDConnect
156
156
 
157
157
  def valid_uri?(uri, schemes = ['http', 'https'])
158
158
  # NOTE: specify nil for schemes to allow any schemes
159
- URI::regexp(schemes).match(uri).present?
159
+ URI::regexp(schemes).match(uri).present? &&
160
+ URI.parse(uri).fragment.blank?
160
161
  end
161
162
 
162
163
  def validate_contacts
@@ -5,7 +5,7 @@ module OpenIDConnect
5
5
  # request:: HTTP::Message
6
6
  def filter_request(request)
7
7
  started = "======= [OpenIDConnect] HTTP REQUEST STARTED ======="
8
- OpenIDConnect.logger.info [started, request.dump].join("\n")
8
+ log started, request.dump
9
9
  end
10
10
 
11
11
  # Callback called in HTTPClient (after received a response)
@@ -13,7 +13,15 @@ module OpenIDConnect
13
13
  # response:: HTTP::Message
14
14
  def filter_response(request, response)
15
15
  finished = "======= [OpenIDConnect] HTTP REQUEST FINISHED ======="
16
- OpenIDConnect.logger.info ['-' * 50, response.dump, finished].join("\n")
16
+ log '-' * 50, response.dump, finished
17
+ end
18
+
19
+ private
20
+
21
+ def log(*outputs)
22
+ outputs.each do |output|
23
+ OpenIDConnect.logger.info output
24
+ end
17
25
  end
18
26
  end
19
27
  end
@@ -1,9 +1,10 @@
1
1
  module OpenIDConnect
2
2
  module Discovery
3
+ REL_VALUE = 'http://openid.net/specs/connect/1.0/issuer'
4
+
3
5
  class InvalidIdentifier < Exception; end
4
6
  class DiscoveryFailed < Exception; end
5
7
  end
6
8
  end
7
9
 
8
- require 'openid_connect/discovery/principal'
9
10
  require 'openid_connect/discovery/provider'
@@ -1,10 +1,27 @@
1
1
  module OpenIDConnect
2
2
  module Discovery
3
3
  module Provider
4
- SERVICE_URI = 'http://openid.net/specs/connect/1.0/issuer'
4
+ module Issuer
5
+ def issuer
6
+ self.link_for(REL_VALUE)[:href]
7
+ end
8
+ end
5
9
 
6
- def self.discover!(identifier, cache_options = {})
7
- Principal.parse(identifier).discover!(cache_options)
10
+ def self.discover!(identifier)
11
+ resource = case identifier
12
+ when /^acct:/, /@/, /^https?:\/\//
13
+ identifier
14
+ else
15
+ "https://#{identifier}"
16
+ end
17
+ response = WebFinger.discover!(
18
+ resource,
19
+ rel: REL_VALUE
20
+ )
21
+ response.extend Issuer
22
+ response
23
+ rescue WebFinger::Exception => e
24
+ raise DiscoveryFailed.new(e.message)
8
25
  end
9
26
  end
10
27
  end
@@ -3,8 +3,8 @@ module OpenIDConnect
3
3
  module Provider
4
4
  class Config
5
5
  def self.discover!(identifier, cache_options = {})
6
- principal = Principal.parse(identifier)
7
- Resource.new(principal).discover!(cache_options)
6
+ uri = URI.parse(identifier)
7
+ Resource.new(uri).discover!(cache_options)
8
8
  rescue SWD::Exception => e
9
9
  raise DiscoveryFailed.new(e.message)
10
10
  end
@@ -7,9 +7,9 @@ module OpenIDConnect
7
7
 
8
8
  class Expired < SWD::Resource::Expired; end
9
9
 
10
- def initialize(principal)
11
- @host = principal.host
12
- @port = principal.port unless [80, 443].include?(principal.port)
10
+ def initialize(uri)
11
+ @host = uri.host
12
+ @port = uri.port unless [80, 443].include?(uri.port)
13
13
  @path ||= '/.well-known/openid-configuration'
14
14
  attr_missing!
15
15
  end
@@ -18,6 +18,7 @@ Gem::Specification.new do |s|
18
18
  s.add_runtime_dependency "validate_email"
19
19
  s.add_runtime_dependency "json-jwt", ">= 0.3.3"
20
20
  s.add_runtime_dependency "swd", ">= 0.1.2"
21
+ s.add_runtime_dependency "webfinger", ">= 0.0.2"
21
22
  s.add_runtime_dependency "rack-oauth2", ">= 1.0.0"
22
23
  s.add_development_dependency "rake", ">= 0.8"
23
24
  s.add_development_dependency "rspec", ">= 2"
@@ -0,0 +1,8 @@
1
+ {
2
+ "expires": "2013-03-09T06:43:23Z",
3
+ "links": [{
4
+ "rel": "http://openid.net/specs/connect/1.0/issuer",
5
+ "href": "https://server.example.com"
6
+ }],
7
+ "subject": "acct:foo@server.example.com"
8
+ }
@@ -144,6 +144,22 @@ describe OpenIDConnect::Client::Registrar do
144
144
  end
145
145
  end
146
146
 
147
+ describe '#redirect_uris' do
148
+ let(:base_url) { 'http://client.example.com/callback' }
149
+ let(:attributes) { minimum_attributes.merge(redirect_uris: redirect_uri) }
150
+
151
+ context 'when query included' do
152
+ let(:redirect_uri) { [base_url, '?foo=bar'].join }
153
+ it { should be_valid }
154
+ its(:redirect_uris) { should == [redirect_uri] }
155
+ end
156
+
157
+ context 'when fragment included' do
158
+ let(:redirect_uri) { [base_url, '#foo=bar'].join }
159
+ it { should_not be_valid }
160
+ end
161
+ end
162
+
147
163
  describe '#contacts' do
148
164
  context 'when contacts given' do
149
165
  context 'when invalid email included' do
@@ -8,21 +8,25 @@ describe OpenIDConnect::Debugger::RequestFilter do
8
8
 
9
9
  describe '#filter_request' do
10
10
  it 'should log request' do
11
- OpenIDConnect.logger.should_receive(:info).with(
12
- "======= [OpenIDConnect] HTTP REQUEST STARTED =======\n" +
11
+ [
12
+ "======= [OpenIDConnect] HTTP REQUEST STARTED =======",
13
13
  request.dump
14
- )
14
+ ].each do |output|
15
+ OpenIDConnect.logger.should_receive(:info).with output
16
+ end
15
17
  request_filter.filter_request(request)
16
18
  end
17
19
  end
18
20
 
19
21
  describe '#filter_response' do
20
22
  it 'should log response' do
21
- OpenIDConnect.logger.should_receive(:info).with(
22
- "--------------------------------------------------\n" +
23
- response.dump +
24
- "\n======= [OpenIDConnect] HTTP REQUEST FINISHED ======="
25
- )
23
+ [
24
+ "--------------------------------------------------",
25
+ response.dump,
26
+ "======= [OpenIDConnect] HTTP REQUEST FINISHED ======="
27
+ ].each do |output|
28
+ OpenIDConnect.logger.should_receive(:info).with output
29
+ end
26
30
  request_filter.filter_response(request, response)
27
31
  end
28
32
  end
@@ -3,39 +3,38 @@ require 'spec_helper'
3
3
  describe OpenIDConnect::Discovery::Provider do
4
4
  let(:provider) { 'https://server.example.com' }
5
5
  let(:discover) { OpenIDConnect::Discovery::Provider.discover! identifier }
6
- let(:endpoint) { "https://#{host}/.well-known/simple-web-discovery" }
6
+ let(:endpoint) { "https://#{host}/.well-known/webfinger" }
7
7
  let(:query) do
8
8
  {
9
- service: OpenIDConnect::Discovery::Provider::SERVICE_URI,
10
- principal: principal
9
+ rel: OpenIDConnect::Discovery::REL_VALUE,
10
+ resource: resource
11
11
  }
12
12
  end
13
13
 
14
14
  shared_examples_for :discover_provider do
15
15
  it "should succeed" do
16
- mock_json :get, endpoint, 'discovery/swd', params: query do
16
+ mock_json :get, endpoint, 'discovery/webfinger', params: query do
17
17
  res = discover
18
- res.should be_a SWD::Response
19
- res.location.should == provider
18
+ res.should be_a WebFinger::Response
19
+ res.issuer.should == provider
20
20
  end
21
21
  end
22
22
  end
23
23
 
24
24
  describe '#discover!' do
25
+ let(:host) { 'server.example.com' }
25
26
 
26
27
  context 'when URI is given' do
27
- let(:principal) { identifier }
28
+ let(:resource) { identifier }
28
29
 
29
30
  context 'when scheme included' do
30
- let(:host) { URI.parse(identifier).host }
31
-
32
31
  context 'when HTTPS' do
33
- let(:identifier) { 'https://server.example.com' }
32
+ let(:identifier) { "https://#{host}" }
34
33
  it_behaves_like :discover_provider
35
34
  end
36
35
 
37
36
  context 'otherwise' do
38
- let(:identifier) { 'http://server.example.com' }
37
+ let(:identifier) { "http://#{host}" }
39
38
  it_behaves_like :discover_provider
40
39
  it 'should access to https://**' do
41
40
  endpoint.should match /^https:\/\//
@@ -44,19 +43,28 @@ describe OpenIDConnect::Discovery::Provider do
44
43
  end
45
44
 
46
45
  context 'when only host is given' do
47
- let(:identifier) { 'server.example.com' }
48
- let(:host) { identifier }
49
- let(:principal) { "https://#{identifier}" }
46
+ let(:identifier) { host }
47
+ let(:resource) { "https://#{host}" }
50
48
  it_behaves_like :discover_provider
51
49
  end
52
50
  end
53
51
 
54
52
  context 'when Email is given' do
55
53
  let(:identifier) { "nov@#{host}" }
56
- let(:host) { 'server.example.com' }
57
- let(:principal) { identifier }
54
+ let(:resource) { identifier }
58
55
  it_behaves_like :discover_provider
59
56
  end
60
57
 
58
+ context 'when error occured' do
59
+ let(:identifier) { host }
60
+ let(:resource) { "https://#{host}" }
61
+ it 'should raise OpenIDConnect::Discovery::DiscoveryFailed' do
62
+ mock_json :get, endpoint, 'discovery/webfinger', params: query, status: [404, 'Not Found'] do
63
+ expect do
64
+ discover
65
+ end.to raise_error OpenIDConnect::Discovery::DiscoveryFailed
66
+ end
67
+ end
68
+ end
61
69
  end
62
70
  end
metadata CHANGED
@@ -1,222 +1,209 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openid_connect
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
5
- prerelease:
4
+ version: 0.5.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - nov matake
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-12-12 00:00:00.000000000 Z
11
+ date: 2013-03-02 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: json
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: 1.4.3
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: 1.4.3
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: tzinfo
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: attr_required
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: 0.0.5
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: 0.0.5
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: activemodel
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - '>='
68
60
  - !ruby/object:Gem::Version
69
61
  version: '3'
70
62
  type: :runtime
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - '>='
76
67
  - !ruby/object:Gem::Version
77
68
  version: '3'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: validate_url
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ! '>='
73
+ - - '>='
84
74
  - !ruby/object:Gem::Version
85
75
  version: '0'
86
76
  type: :runtime
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ! '>='
80
+ - - '>='
92
81
  - !ruby/object:Gem::Version
93
82
  version: '0'
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: validate_email
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
- - - ! '>='
87
+ - - '>='
100
88
  - !ruby/object:Gem::Version
101
89
  version: '0'
102
90
  type: :runtime
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
- - - ! '>='
94
+ - - '>='
108
95
  - !ruby/object:Gem::Version
109
96
  version: '0'
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: json-jwt
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
- - - ! '>='
101
+ - - '>='
116
102
  - !ruby/object:Gem::Version
117
103
  version: 0.3.3
118
104
  type: :runtime
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
- - - ! '>='
108
+ - - '>='
124
109
  - !ruby/object:Gem::Version
125
110
  version: 0.3.3
126
111
  - !ruby/object:Gem::Dependency
127
112
  name: swd
128
113
  requirement: !ruby/object:Gem::Requirement
129
- none: false
130
114
  requirements:
131
- - - ! '>='
115
+ - - '>='
132
116
  - !ruby/object:Gem::Version
133
117
  version: 0.1.2
134
118
  type: :runtime
135
119
  prerelease: false
136
120
  version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
121
  requirements:
139
- - - ! '>='
122
+ - - '>='
140
123
  - !ruby/object:Gem::Version
141
124
  version: 0.1.2
125
+ - !ruby/object:Gem::Dependency
126
+ name: webfinger
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '>='
130
+ - !ruby/object:Gem::Version
131
+ version: 0.0.2
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '>='
137
+ - !ruby/object:Gem::Version
138
+ version: 0.0.2
142
139
  - !ruby/object:Gem::Dependency
143
140
  name: rack-oauth2
144
141
  requirement: !ruby/object:Gem::Requirement
145
- none: false
146
142
  requirements:
147
- - - ! '>='
143
+ - - '>='
148
144
  - !ruby/object:Gem::Version
149
145
  version: 1.0.0
150
146
  type: :runtime
151
147
  prerelease: false
152
148
  version_requirements: !ruby/object:Gem::Requirement
153
- none: false
154
149
  requirements:
155
- - - ! '>='
150
+ - - '>='
156
151
  - !ruby/object:Gem::Version
157
152
  version: 1.0.0
158
153
  - !ruby/object:Gem::Dependency
159
154
  name: rake
160
155
  requirement: !ruby/object:Gem::Requirement
161
- none: false
162
156
  requirements:
163
- - - ! '>='
157
+ - - '>='
164
158
  - !ruby/object:Gem::Version
165
159
  version: '0.8'
166
160
  type: :development
167
161
  prerelease: false
168
162
  version_requirements: !ruby/object:Gem::Requirement
169
- none: false
170
163
  requirements:
171
- - - ! '>='
164
+ - - '>='
172
165
  - !ruby/object:Gem::Version
173
166
  version: '0.8'
174
167
  - !ruby/object:Gem::Dependency
175
168
  name: rspec
176
169
  requirement: !ruby/object:Gem::Requirement
177
- none: false
178
170
  requirements:
179
- - - ! '>='
171
+ - - '>='
180
172
  - !ruby/object:Gem::Version
181
173
  version: '2'
182
174
  type: :development
183
175
  prerelease: false
184
176
  version_requirements: !ruby/object:Gem::Requirement
185
- none: false
186
177
  requirements:
187
- - - ! '>='
178
+ - - '>='
188
179
  - !ruby/object:Gem::Version
189
180
  version: '2'
190
181
  - !ruby/object:Gem::Dependency
191
182
  name: webmock
192
183
  requirement: !ruby/object:Gem::Requirement
193
- none: false
194
184
  requirements:
195
- - - ! '>='
185
+ - - '>='
196
186
  - !ruby/object:Gem::Version
197
187
  version: 1.6.2
198
188
  type: :development
199
189
  prerelease: false
200
190
  version_requirements: !ruby/object:Gem::Requirement
201
- none: false
202
191
  requirements:
203
- - - ! '>='
192
+ - - '>='
204
193
  - !ruby/object:Gem::Version
205
194
  version: 1.6.2
206
195
  - !ruby/object:Gem::Dependency
207
196
  name: cover_me
208
197
  requirement: !ruby/object:Gem::Requirement
209
- none: false
210
198
  requirements:
211
- - - ! '>='
199
+ - - '>='
212
200
  - !ruby/object:Gem::Version
213
201
  version: 1.2.0
214
202
  type: :development
215
203
  prerelease: false
216
204
  version_requirements: !ruby/object:Gem::Requirement
217
- none: false
218
205
  requirements:
219
- - - ! '>='
206
+ - - '>='
220
207
  - !ruby/object:Gem::Version
221
208
  version: 1.2.0
222
209
  description: OpenID Connect Server & Client Library
@@ -243,9 +230,6 @@ files:
243
230
  - lib/openid_connect/debugger.rb
244
231
  - lib/openid_connect/debugger/request_filter.rb
245
232
  - lib/openid_connect/discovery.rb
246
- - lib/openid_connect/discovery/principal.rb
247
- - lib/openid_connect/discovery/principal/email.rb
248
- - lib/openid_connect/discovery/principal/uri.rb
249
233
  - lib/openid_connect/discovery/provider.rb
250
234
  - lib/openid_connect/discovery/provider/config.rb
251
235
  - lib/openid_connect/discovery/provider/config/resource.rb
@@ -281,6 +265,7 @@ files:
281
265
  - spec/mock_response/client/updated.json
282
266
  - spec/mock_response/discovery/config.json
283
267
  - spec/mock_response/discovery/swd.json
268
+ - spec/mock_response/discovery/webfinger.json
284
269
  - spec/mock_response/errors/insufficient_scope.json
285
270
  - spec/mock_response/errors/invalid_access_token.json
286
271
  - spec/mock_response/errors/invalid_request.json
@@ -295,9 +280,6 @@ files:
295
280
  - spec/openid_connect/client_spec.rb
296
281
  - spec/openid_connect/connect_object_spec.rb
297
282
  - spec/openid_connect/debugger/request_filter_spec.rb
298
- - spec/openid_connect/discovery/principal/email_spec.rb
299
- - spec/openid_connect/discovery/principal/uri_spec.rb
300
- - spec/openid_connect/discovery/principal_spec.rb
301
283
  - spec/openid_connect/discovery/provider/config/resource_spec.rb
302
284
  - spec/openid_connect/discovery/provider/config/response_spec.rb
303
285
  - spec/openid_connect/discovery/provider/config_spec.rb
@@ -318,33 +300,26 @@ files:
318
300
  - spec/spec_helper.rb
319
301
  homepage: https://github.com/nov/openid_connect
320
302
  licenses: []
303
+ metadata: {}
321
304
  post_install_message:
322
305
  rdoc_options: []
323
306
  require_paths:
324
307
  - lib
325
308
  required_ruby_version: !ruby/object:Gem::Requirement
326
- none: false
327
309
  requirements:
328
- - - ! '>='
310
+ - - '>='
329
311
  - !ruby/object:Gem::Version
330
312
  version: '0'
331
- segments:
332
- - 0
333
- hash: -3886993201268064457
334
313
  required_rubygems_version: !ruby/object:Gem::Requirement
335
- none: false
336
314
  requirements:
337
- - - ! '>='
315
+ - - '>='
338
316
  - !ruby/object:Gem::Version
339
317
  version: '0'
340
- segments:
341
- - 0
342
- hash: -3886993201268064457
343
318
  requirements: []
344
319
  rubyforge_project:
345
- rubygems_version: 1.8.24
320
+ rubygems_version: 2.0.0
346
321
  signing_key:
347
- specification_version: 3
322
+ specification_version: 4
348
323
  summary: OpenID Connect Server & Client Library
349
324
  test_files:
350
325
  - spec/helpers/crypto_spec_helper.rb
@@ -358,6 +333,7 @@ test_files:
358
333
  - spec/mock_response/client/updated.json
359
334
  - spec/mock_response/discovery/config.json
360
335
  - spec/mock_response/discovery/swd.json
336
+ - spec/mock_response/discovery/webfinger.json
361
337
  - spec/mock_response/errors/insufficient_scope.json
362
338
  - spec/mock_response/errors/invalid_access_token.json
363
339
  - spec/mock_response/errors/invalid_request.json
@@ -372,9 +348,6 @@ test_files:
372
348
  - spec/openid_connect/client_spec.rb
373
349
  - spec/openid_connect/connect_object_spec.rb
374
350
  - spec/openid_connect/debugger/request_filter_spec.rb
375
- - spec/openid_connect/discovery/principal/email_spec.rb
376
- - spec/openid_connect/discovery/principal/uri_spec.rb
377
- - spec/openid_connect/discovery/principal_spec.rb
378
351
  - spec/openid_connect/discovery/provider/config/resource_spec.rb
379
352
  - spec/openid_connect/discovery/provider/config/response_spec.rb
380
353
  - spec/openid_connect/discovery/provider/config_spec.rb
@@ -1,33 +0,0 @@
1
- module OpenIDConnect
2
- module Discovery
3
- class Principal
4
- attr_reader :identifier, :host, :port
5
-
6
- def self.parse(identifier)
7
- raise InvalidIdentifier.new('Identifier Required') if identifier.blank?
8
- type = case identifier
9
- when /@/
10
- Email
11
- else
12
- URI
13
- end
14
- type.new identifier
15
- end
16
-
17
- def discover!(cache_options = {})
18
- SWD.discover!(
19
- principal: identifier,
20
- service: Provider::SERVICE_URI,
21
- host: host,
22
- port: port,
23
- cache: cache_options
24
- )
25
- rescue SWD::Exception => e
26
- raise DiscoveryFailed.new(e.message)
27
- end
28
- end
29
- end
30
- end
31
-
32
- require 'openid_connect/discovery/principal/email'
33
- require 'openid_connect/discovery/principal/uri'
@@ -1,12 +0,0 @@
1
- module OpenIDConnect
2
- module Discovery
3
- class Principal
4
- class Email < Principal
5
- def initialize(identifier)
6
- @identifier = identifier
7
- @host = identifier.split('@').last
8
- end
9
- end
10
- end
11
- end
12
- end
@@ -1,25 +0,0 @@
1
- module OpenIDConnect
2
- module Discovery
3
- class Principal
4
- class URI < Principal
5
- def initialize(identifier)
6
- uri = normalize(identifier)
7
- @identifier = uri.to_s
8
- @host = uri.host
9
- @port = uri.port unless [80, 443].include?(uri.port)
10
- end
11
-
12
- private
13
-
14
- def normalize(identifier)
15
- identifier = "https://#{identifier}" unless identifier.include?('://')
16
- uri = ::URI.parse(identifier)
17
- uri.fragment = nil
18
- uri
19
- rescue ::URI::Error => e
20
- raise InvalidIdentifier.new('Invalid URI')
21
- end
22
- end
23
- end
24
- end
25
- end
@@ -1,10 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe OpenIDConnect::Discovery::Principal::Email do
4
- subject { email }
5
- let(:email) { OpenIDConnect::Discovery::Principal::Email.new identifier }
6
- let(:identifier) { 'nov@server.example.com' }
7
-
8
- its(:identifier) { should == identifier }
9
- its(:host) { should == 'server.example.com' }
10
- end
@@ -1,55 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe OpenIDConnect::Discovery::Principal::URI do
4
- subject { uri }
5
- let(:uri) { OpenIDConnect::Discovery::Principal::URI.new identifier }
6
-
7
- {
8
- 'server.example.com' => 'https://server.example.com',
9
- 'server.example.com/' => 'https://server.example.com/',
10
- 'server.example.com/nov' => 'https://server.example.com/nov',
11
- 'server.example.com/nov/' => 'https://server.example.com/nov/',
12
- 'server.example.com/nov#id' => 'https://server.example.com/nov',
13
- 'server.example.com/nov?k=v' => 'https://server.example.com/nov?k=v',
14
- 'server.example.com/nov?k=v#id' => 'https://server.example.com/nov?k=v',
15
- 'http://server.example.com' => 'http://server.example.com',
16
- 'http://server.example.com/' => 'http://server.example.com/',
17
- 'http://server.example.com/nov' => 'http://server.example.com/nov',
18
- 'http://server.example.com/nov/' => 'http://server.example.com/nov/',
19
- 'http://server.example.com/nov#id' => 'http://server.example.com/nov',
20
- 'http://server.example.com/nov?k=v' => 'http://server.example.com/nov?k=v',
21
- 'http://server.example.com/nov?k=v#id' => 'http://server.example.com/nov?k=v',
22
- 'https://server.example.com' => 'https://server.example.com',
23
- 'https://server.example.com/' => 'https://server.example.com/',
24
- 'https://server.example.com/nov' => 'https://server.example.com/nov',
25
- 'https://server.example.com/nov/' => 'https://server.example.com/nov/',
26
- 'https://server.example.com/nov#id' => 'https://server.example.com/nov',
27
- 'https://server.example.com/nov?k=v' => 'https://server.example.com/nov?k=v',
28
- 'https://server.example.com/nov?k=v#id' => 'https://server.example.com/nov?k=v',
29
- }.each do |input, output|
30
- context "when '#{input}' is given" do
31
- let(:identifier) { input }
32
- its(:identifier) { should == output }
33
- its(:host) { should == 'server.example.com' }
34
- its(:port) { should be_nil }
35
- end
36
- end
37
-
38
- {
39
- 'server.example.com:8080' => 'https://server.example.com:8080'
40
- }.each do |input, output|
41
- context "when '#{input}' is given" do
42
- let(:identifier) { input }
43
- its(:identifier) { should == output }
44
- its(:host) { should == 'server.example.com' }
45
- its(:port) { should == 8080 }
46
- end
47
- end
48
-
49
- describe 'error handling' do
50
- let(:identifier) { '**' }
51
- it do
52
- expect { uri }.to raise_error OpenIDConnect::Discovery::InvalidIdentifier
53
- end
54
- end
55
- end
@@ -1,46 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe OpenIDConnect::Discovery::Principal do
4
- describe '.parse' do
5
- {
6
- 'server.example.com' => OpenIDConnect::Discovery::Principal::URI,
7
- 'http://server.example.com' => OpenIDConnect::Discovery::Principal::URI,
8
- 'nov@server.example.com' => OpenIDConnect::Discovery::Principal::Email
9
- }.each do |input, klass|
10
- describe input do
11
- it do
12
- OpenIDConnect::Discovery::Principal.parse(input).should be_a klass
13
- end
14
- end
15
- end
16
- end
17
-
18
- describe '#discover!' do
19
- let(:request) { OpenIDConnect::Discovery::Principal.new.discover! }
20
-
21
- it 'should do SWD discovery' do
22
- SWD.should_receive(:discover!)
23
- request
24
- end
25
-
26
- context 'when port specified' do
27
- it do
28
- SWD.should_receive(:discover!).with(
29
- principal: "https://example.com:8080",
30
- service: "http://openid.net/specs/connect/1.0/issuer",
31
- host: "example.com",
32
- port: 8080,
33
- cache: {}
34
- )
35
- OpenIDConnect::Discovery::Principal.parse('example.com:8080').discover!
36
- end
37
- end
38
-
39
- context 'when discovery failed' do
40
- it do
41
- SWD.should_receive(:discover!).and_raise(SWD::Exception)
42
- expect { request }.to raise_error OpenIDConnect::Discovery::DiscoveryFailed
43
- end
44
- end
45
- end
46
- end