openid_connect 0.0.14 → 0.0.15

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.
data/Gemfile.lock CHANGED
@@ -1,13 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- openid_connect (0.0.13)
4
+ openid_connect (0.0.14)
5
5
  activemodel (>= 3)
6
6
  attr_required (>= 0.0.3)
7
7
  json (>= 1.4.3)
8
8
  jwt (>= 0.1.3)
9
9
  rack-oauth2 (>= 0.9)
10
- swd (>= 0.0.1)
10
+ swd (>= 0.0.3)
11
11
  tzinfo
12
12
  validate_email
13
13
  validate_url
@@ -54,7 +54,7 @@ GEM
54
54
  rspec-expectations (2.6.0)
55
55
  diff-lcs (~> 1.1.2)
56
56
  rspec-mocks (2.6.0)
57
- swd (0.0.1)
57
+ swd (0.0.3)
58
58
  activesupport (>= 3)
59
59
  attr_required (>= 0.0.3)
60
60
  httpclient (>= 2.2.1)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.14
1
+ 0.0.15
@@ -18,11 +18,12 @@ module OpenIDConnect
18
18
  type.new identifier
19
19
  end
20
20
 
21
- def discover!
21
+ def discover!(cache_options = {})
22
22
  SWD.discover!(
23
23
  :principal => identifier,
24
24
  :service => Provider::SERVICE_URI,
25
- :host => host
25
+ :host => host,
26
+ :cache => cache_options
26
27
  )
27
28
  rescue SWD::Exception => e
28
29
  raise DiscoveryFailed.new(e.message)
@@ -6,7 +6,7 @@ module OpenIDConnect
6
6
  @identifier = identifier
7
7
  end
8
8
 
9
- def discover!
9
+ def discover!(cache_options = {})
10
10
  raise NotImplementedError.new('XRI is not supported yet')
11
11
  end
12
12
  end
@@ -3,8 +3,8 @@ module OpenIDConnect
3
3
  module Provider
4
4
  SERVICE_URI = 'http://openid.net/specs/connect/1.0/issuer'
5
5
 
6
- def self.discover!(identifier)
7
- Principal.parse(identifier).discover!
6
+ def self.discover!(identifier, cache_options = {})
7
+ Principal.parse(identifier).discover!(cache_options)
8
8
  end
9
9
  end
10
10
  end
@@ -2,10 +2,16 @@ module OpenIDConnect
2
2
  module Discovery
3
3
  module Provider
4
4
  class Config
5
- def self.discover!(host)
6
- # TODO
5
+ def self.discover!(identifier, cache_options = {})
6
+ principal = Principal.parse(identifier)
7
+ Resource.new(principal.host).discover!(cache_options)
8
+ rescue SWD::Exception => e
9
+ raise DiscoveryFailed.new(e.message)
7
10
  end
8
11
  end
9
12
  end
10
13
  end
11
- end
14
+ end
15
+
16
+ require 'openid_connect/discovery/provider/config/resource'
17
+ require 'openid_connect/discovery/provider/config/response'
@@ -0,0 +1,39 @@
1
+ module OpenIDConnect
2
+ module Discovery
3
+ module Provider
4
+ class Config
5
+ class Resource < SWD::Resource
6
+ # NOTE: principal and service are required in SWD::Resource and should not exist here.
7
+ undef_method :principal, :principal=, :service, :service=
8
+ @required_attributes.delete :principal
9
+ @required_attributes.delete :service
10
+
11
+ class Expired < SWD::Resource::Expired; end
12
+
13
+ def initialize(host)
14
+ @host = host
15
+ @path ||= '/.well-known/openid-configuration'
16
+ attr_missing!
17
+ end
18
+
19
+ def endpoint
20
+ URI::HTTPS.build [nil, host, 443, path, nil, nil]
21
+ rescue URI::Error => e
22
+ raise SWD::Exception.new(e.message)
23
+ end
24
+
25
+ private
26
+
27
+ def to_response_object(hash)
28
+ Response.new hash
29
+ end
30
+
31
+ def cache_key
32
+ md5 = Digest::MD5.hexdigest host
33
+ "swd:resource:opneid-conf:#{md5}"
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,23 @@
1
+ module OpenIDConnect
2
+ module Discovery
3
+ module Provider
4
+ class Config
5
+ class Response < SWD::Resource
6
+ include AttrOptional
7
+
8
+ attr_reader :raw
9
+ attr_optional :authorization_endpoint, :token_endpoint, :registration_endpoint
10
+ attr_optional :user_info_endpoint, :check_session_endpoint, :refresh_session_endpoint, :end_session_endpoint
11
+ attr_optional :jwk_document, :scopes_supported, :flows_supported, :iso29115_supported
12
+
13
+ def initialize(hash)
14
+ optional_attributes.each do |key|
15
+ self.send "#{key}=", hash[key]
16
+ end
17
+ @raw = hash
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
17
17
  s.add_runtime_dependency "validate_url"
18
18
  s.add_runtime_dependency "validate_email"
19
19
  s.add_runtime_dependency "jwt", ">= 0.1.3"
20
- s.add_runtime_dependency "swd", ">= 0.0.1"
20
+ s.add_runtime_dependency "swd", ">= 0.0.3"
21
21
  s.add_runtime_dependency "rack-oauth2", ">= 0.9"
22
22
  s.add_development_dependency "rake", ">= 0.8"
23
23
  s.add_development_dependency "rcov", ">= 0.9"
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: openid_connect
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.14
5
+ version: 0.0.15
6
6
  platform: ruby
7
7
  authors:
8
8
  - nov matake
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-08-19 00:00:00 Z
13
+ date: 2011-08-20 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: json
@@ -97,7 +97,7 @@ dependencies:
97
97
  requirements:
98
98
  - - ">="
99
99
  - !ruby/object:Gem::Version
100
- version: 0.0.1
100
+ version: 0.0.3
101
101
  type: :runtime
102
102
  version_requirements: *id008
103
103
  - !ruby/object:Gem::Dependency
@@ -183,6 +183,8 @@ files:
183
183
  - lib/openid_connect/discovery/principal/xri.rb
184
184
  - lib/openid_connect/discovery/provider.rb
185
185
  - lib/openid_connect/discovery/provider/config.rb
186
+ - lib/openid_connect/discovery/provider/config/resource.rb
187
+ - lib/openid_connect/discovery/provider/config/response.rb
186
188
  - lib/openid_connect/exception.rb
187
189
  - lib/openid_connect/response_object.rb
188
190
  - lib/openid_connect/response_object/id_token.rb