openid_connect 0.8.0 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 35d71b7a3743bd72c3f58f3ec42cb738154713ed
4
- data.tar.gz: 5937a7527d73fb7a304da639aec619db2cbe3954
3
+ metadata.gz: 5e37ffd0520ec832d81226c3bb752af77b099c5a
4
+ data.tar.gz: 3159b95aa6e9a6b26951464af00cf0eaf0cf4eff
5
5
  SHA512:
6
- metadata.gz: 9618737dec9685e33637aa65dad56f2b8d8392156459f93ae3f157bf54fe6332f07e9007778ebfe17b6279bd6e30a50ceea8ae56c2d75272b5cbcbb7cda24692
7
- data.tar.gz: c5f72442ebc141bdbeaf8c7f1b0a1036a5b74d345411bf593cf2c9f21c79aecd44d56ef9df07e97dc1027495f6c0dbfbf54da191667013fb3d760133ec3111f9
6
+ metadata.gz: d3ff447fd53557c27c760d6d5d9428173d6aac275a326738e4cb339769ad4d8f4e27b138e48fb543006f952719bc7c734601a1645f867773a07259e59176d3df
7
+ data.tar.gz: b306bc902f3da7901216861a3e55affaa3a8855d45781ef04b00b64d1f1b0a309a1c7f4e258dd6efed256e7e257e77dfaa0057ddfb62933e078037aeb61afaba
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.8.0
1
+ 0.8.1
@@ -15,7 +15,7 @@ require 'rack/oauth2/server/id_token_response'
15
15
  module OpenIDConnect
16
16
  VERSION = ::File.read(
17
17
  ::File.join(::File.dirname(__FILE__), '../VERSION')
18
- )
18
+ ).chomp
19
19
 
20
20
  def self.logger
21
21
  @@logger
@@ -83,4 +83,4 @@ require 'openid_connect/access_token'
83
83
  require 'openid_connect/jwtnizable'
84
84
  require 'openid_connect/connect_object'
85
85
  require 'openid_connect/discovery'
86
- require 'openid_connect/debugger'
86
+ require 'openid_connect/debugger'
@@ -5,7 +5,7 @@ module OpenIDConnect
5
5
 
6
6
  class RegistrationFailed < HttpError; end
7
7
 
8
- cattr_accessor :plurar_uri_attributes, :metadata_attributes
8
+ cattr_accessor :plural_uri_attributes, :metadata_attributes
9
9
  singular_uri_attributes = [
10
10
  :logo_uri,
11
11
  :client_uri,
@@ -34,17 +34,17 @@ module OpenIDConnect
34
34
  :default_max_age,
35
35
  :require_auth_time
36
36
  ] + singular_uri_attributes
37
- self.plurar_uri_attributes = [
37
+ self.plural_uri_attributes = [
38
38
  :redirect_uris,
39
39
  :request_uris
40
40
  ]
41
- plurar_attributes = [
41
+ plural_attributes = [
42
42
  :response_types,
43
43
  :grant_types,
44
44
  :contacts,
45
45
  :default_acr_values,
46
- ] + plurar_uri_attributes
47
- self.metadata_attributes = singular_attributes + plurar_attributes
46
+ ] + plural_uri_attributes
47
+ self.metadata_attributes = singular_attributes + plural_attributes
48
48
  required_metadata_attributes = [
49
49
  :redirect_uris
50
50
  ]
@@ -56,7 +56,7 @@ module OpenIDConnect
56
56
  validates *required_attributes, presence: true
57
57
  validates :sector_identifier_uri, presence: {if: :sector_identifier_required?}
58
58
  validates *singular_uri_attributes, url: true, allow_nil: true
59
- validate :validate_plurar_uri_attributes
59
+ validate :validate_plural_uri_attributes
60
60
  validate :validate_contacts
61
61
 
62
62
  def initialize(endpoint, attributes = {})
@@ -135,8 +135,8 @@ module OpenIDConnect
135
135
  end
136
136
  end
137
137
 
138
- def validate_plurar_uri_attributes
139
- self.class.plurar_uri_attributes.each do |_attr_|
138
+ def validate_plural_uri_attributes
139
+ self.class.plural_uri_attributes.each do |_attr_|
140
140
  if (uris = self.send(_attr_))
141
141
  include_invalid = uris.any? do |uri|
142
142
  !valid_uri?(uri, nil)
@@ -183,4 +183,4 @@ module OpenIDConnect
183
183
  end
184
184
  end
185
185
  end
186
- end
186
+ end
@@ -1,12 +1,14 @@
1
1
  module OpenIDConnect
2
2
  module JWTnizable
3
3
  def to_jwt(key, algorithm = :RS256, &block)
4
+ as_jwt(key, algorithm, &block).to_s
5
+ end
6
+
7
+ def as_jwt(key, algorithm = :RS256, &block)
4
8
  token = JSON::JWT.new as_json
5
9
  yield token if block_given?
6
- if algorithm != :none
7
- token = token.sign key, algorithm
8
- end
9
- token.to_s
10
+ token = token.sign key, algorithm if algorithm != :none
11
+ token
10
12
  end
11
13
  end
12
14
  end
@@ -48,7 +48,7 @@ module OpenIDConnect
48
48
  private
49
49
 
50
50
  def left_half_hash_of(string, hash_length)
51
- digest = OpenSSL::Digest::Digest.new("SHA#{hash_length}").digest string
51
+ digest = OpenSSL::Digest.new("SHA#{hash_length}").digest string
52
52
  UrlSafeBase64.encode64 digest[0, hash_length / (2 * 8)]
53
53
  end
54
54
 
@@ -27,7 +27,6 @@ module OpenIDConnect
27
27
  alias_method :subject=, :sub=
28
28
 
29
29
  validates :email_verified, :phone_number_verified, allow_nil: true, inclusion: {in: [true, false]}
30
- validates :gender, allow_nil: true, inclusion: {in: ['male', 'female']}
31
30
  validates :zoneinfo, allow_nil: true, inclusion: {in: TZInfo::TimezoneProxy.all.collect(&:name)}
32
31
  validates :profile, :picture, :website, allow_nil: true, url: true
33
32
  validates :email, allow_nil: true, email: true
@@ -22,8 +22,9 @@ Gem::Specification.new do |s|
22
22
  s.add_runtime_dependency "swd", ">= 0.1.2"
23
23
  s.add_runtime_dependency "webfinger", ">= 0.0.2"
24
24
  s.add_runtime_dependency "rack-oauth2", ">= 1.0.0"
25
- s.add_development_dependency "rake", ">= 0.8"
26
- s.add_development_dependency "rspec", ">= 2"
27
- s.add_development_dependency "webmock", ">= 1.6.2"
25
+ s.add_development_dependency "rake"
26
+ s.add_development_dependency "rspec"
27
+ s.add_development_dependency "rspec-its"
28
+ s.add_development_dependency "webmock"
28
29
  s.add_development_dependency "simplecov"
29
30
  end
@@ -12,7 +12,7 @@ module CryptoSpecHelper
12
12
  end
13
13
 
14
14
  def ec_key
15
- @ec_key ||= OpenSSL::PKey::EC.new('secp256k1').generate_key
15
+ @ec_key ||= OpenSSL::PKey::EC.new('prime256v1').generate_key
16
16
  end
17
17
 
18
18
  def ec_public_key
@@ -30,6 +30,14 @@ describe OpenIDConnect::Client::Registrar do
30
30
  it { should_not be_valid }
31
31
  end
32
32
 
33
+ describe '#initialize' do
34
+ it 'creates attribute writers for all attributes' do
35
+ described_class.metadata_attributes.each do |attr|
36
+ expect(subject).to respond_to("#{attr}=")
37
+ end
38
+ end
39
+ end
40
+
33
41
  describe '#sector_identifier' do
34
42
  context 'when sector_identifier_uri given' do
35
43
  let(:attributes) do
@@ -198,7 +206,9 @@ describe OpenIDConnect::Client::Registrar do
198
206
  it do
199
207
  expect do
200
208
  instance.validate!
201
- end.not_to raise_error OpenIDConnect::ValidationFailed
209
+ end.not_to raise_error { |e|
210
+ e.should be_a OpenIDConnect::ValidationFailed
211
+ }
202
212
  end
203
213
  end
204
214
 
@@ -246,4 +256,4 @@ describe OpenIDConnect::Client::Registrar do
246
256
  it { should be_instance_of HTTPClient }
247
257
  end
248
258
  end
249
- end
259
+ end
@@ -71,7 +71,7 @@ describe OpenIDConnect::ConnectObject do
71
71
  describe '#validate!' do
72
72
  context 'when valid' do
73
73
  subject { instance.validate! }
74
- it { should be_true }
74
+ it { should == true }
75
75
  end
76
76
 
77
77
  context 'otherwise' do
@@ -12,7 +12,7 @@ describe OpenIDConnect::Debugger::RequestFilter do
12
12
  "======= [OpenIDConnect] HTTP REQUEST STARTED =======",
13
13
  request.dump
14
14
  ].each do |output|
15
- OpenIDConnect.logger.should_receive(:info).with output
15
+ expect(OpenIDConnect.logger).to receive(:info).with output
16
16
  end
17
17
  request_filter.filter_request(request)
18
18
  end
@@ -25,7 +25,7 @@ describe OpenIDConnect::Debugger::RequestFilter do
25
25
  response.dump,
26
26
  "======= [OpenIDConnect] HTTP REQUEST FINISHED ======="
27
27
  ].each do |output|
28
- OpenIDConnect.logger.should_receive(:info).with output
28
+ expect(OpenIDConnect.logger).to receive(:info).with output
29
29
  end
30
30
  request_filter.filter_response(request, response)
31
31
  end
@@ -55,7 +55,9 @@ describe OpenIDConnect::Discovery::Provider::Config::Response do
55
55
  it do
56
56
  expect do
57
57
  instance.validate!
58
- end.not_to raise_error OpenIDConnect::ValidationFailed
58
+ end.not_to raise_error{ |e|
59
+ e.should be_a OpenIDConnect::ValidationFailed
60
+ }
59
61
  end
60
62
  end
61
63
  end
@@ -93,15 +93,15 @@ describe OpenIDConnect::RequestObject do
93
93
 
94
94
  describe '#required?' do
95
95
  it do
96
- request_object.userinfo.required?(:name).should be_true
97
- request_object.userinfo.optional?(:name).should be_false
96
+ request_object.userinfo.required?(:name).should == true
97
+ request_object.userinfo.optional?(:name).should == false
98
98
  end
99
99
  end
100
100
 
101
101
  describe '#optional' do
102
102
  it do
103
- request_object.userinfo.required?(:email).should be_false
104
- request_object.userinfo.optional?(:email).should be_true
103
+ request_object.userinfo.required?(:email).should == false
104
+ request_object.userinfo.optional?(:email).should == true
105
105
  end
106
106
  end
107
107
  end
@@ -28,7 +28,7 @@ describe OpenIDConnect::ResponseObject::IdToken do
28
28
  id_token.verify!(
29
29
  issuer: attributes[:iss],
30
30
  client_id: attributes[:aud]
31
- ).should be_true
31
+ ).should == true
32
32
  end
33
33
 
34
34
  context 'when aud(ience) is an array of identifiers' do
@@ -38,7 +38,7 @@ describe OpenIDConnect::ResponseObject::IdToken do
38
38
  id_token.verify!(
39
39
  issuer: attributes[:iss],
40
40
  client_id: client_id
41
- ).should be_true
41
+ ).should == true
42
42
  end
43
43
  end
44
44
 
@@ -106,7 +106,7 @@ describe OpenIDConnect::ResponseObject::IdToken do
106
106
  issuer: attributes[:iss],
107
107
  client_id: attributes[:aud],
108
108
  nonce: attributes[:nonce]
109
- ).should be_true
109
+ ).should == true
110
110
  end
111
111
  end
112
112
 
@@ -20,7 +20,7 @@ describe OpenIDConnect::ResponseObject::UserInfo::Address do
20
20
  let :attributes do
21
21
  {}
22
22
  end
23
- its(:valid?) { should be_false }
23
+ its(:valid?) { should == false }
24
24
  its(:errors) { should include :base }
25
25
  end
26
26
  end
@@ -45,7 +45,7 @@ describe OpenIDConnect::ResponseObject::UserInfo do
45
45
  let :attributes do
46
46
  {}
47
47
  end
48
- its(:valid?) { should be_false }
48
+ its(:valid?) { should == false }
49
49
  its(:errors) { should include :base }
50
50
  end
51
51
 
@@ -53,16 +53,16 @@ describe OpenIDConnect::ResponseObject::UserInfo do
53
53
  let :attributes do
54
54
  {email: 'nov@localhost'}
55
55
  end
56
- its(:valid?) { should be_false }
56
+ its(:valid?) { should == false }
57
57
  its(:errors) { should include :email }
58
58
  end
59
59
 
60
- [:email_verified, :gender, :zoneinfo].each do |one_of_list|
60
+ [:email_verified, :zoneinfo].each do |one_of_list|
61
61
  context "when #{one_of_list} is invalid" do
62
62
  let :attributes do
63
63
  {one_of_list => 'Out of List'}
64
64
  end
65
- its(:valid?) { should be_false }
65
+ its(:valid?) { should == false }
66
66
  its(:errors) { should include one_of_list }
67
67
  end
68
68
  end
@@ -76,7 +76,7 @@ describe OpenIDConnect::ResponseObject::UserInfo do
76
76
  let :attributes do
77
77
  {url => 'Invalid'}
78
78
  end
79
- its(:valid?) { should be_false }
79
+ its(:valid?) { should == false }
80
80
  its(:errors) { should include url }
81
81
  end
82
82
  end
@@ -85,7 +85,7 @@ describe OpenIDConnect::ResponseObject::UserInfo do
85
85
  let :attributes do
86
86
  {address: {}}
87
87
  end
88
- its(:valid?) { should be_false }
88
+ its(:valid?) { should == false }
89
89
  its(:errors) { should include :address }
90
90
  end
91
91
  end
@@ -4,24 +4,24 @@ describe OpenIDConnect do
4
4
  after { OpenIDConnect.debugging = false }
5
5
 
6
6
  its(:logger) { should be_a Logger }
7
- its(:debugging?) { should be_false }
7
+ its(:debugging?) { should == false }
8
8
 
9
9
  describe '.debug!' do
10
10
  before { OpenIDConnect.debug! }
11
- its(:debugging?) { should be_true }
11
+ its(:debugging?) { should == true }
12
12
  end
13
13
 
14
14
  describe '.debug' do
15
15
  it 'should enable debugging within given block' do
16
16
  OpenIDConnect.debug do
17
- SWD.debugging?.should be_true
18
- WebFinger.debugging?.should be_true
19
- Rack::OAuth2.debugging?.should be_true
20
- OpenIDConnect.debugging?.should be_true
17
+ SWD.debugging?.should == true
18
+ WebFinger.debugging?.should == true
19
+ Rack::OAuth2.debugging?.should == true
20
+ OpenIDConnect.debugging?.should == true
21
21
  end
22
- SWD.debugging?.should be_false
23
- Rack::OAuth2.debugging?.should be_false
24
- OpenIDConnect.debugging?.should be_false
22
+ SWD.debugging?.should == false
23
+ Rack::OAuth2.debugging?.should == false
24
+ OpenIDConnect.debugging?.should == false
25
25
  end
26
26
 
27
27
  it 'should not force disable debugging' do
@@ -30,15 +30,15 @@ describe OpenIDConnect do
30
30
  Rack::OAuth2.debug!
31
31
  OpenIDConnect.debug!
32
32
  OpenIDConnect.debug do
33
- SWD.debugging?.should be_true
34
- WebFinger.debugging?.should be_true
35
- Rack::OAuth2.debugging?.should be_true
36
- OpenIDConnect.debugging?.should be_true
33
+ SWD.debugging?.should == true
34
+ WebFinger.debugging?.should == true
35
+ Rack::OAuth2.debugging?.should == true
36
+ OpenIDConnect.debugging?.should == true
37
37
  end
38
- SWD.debugging?.should be_true
39
- WebFinger.debugging?.should be_true
40
- Rack::OAuth2.debugging?.should be_true
41
- OpenIDConnect.debugging?.should be_true
38
+ SWD.debugging?.should == true
39
+ WebFinger.debugging?.should == true
40
+ Rack::OAuth2.debugging?.should == true
41
+ OpenIDConnect.debugging?.should == true
42
42
  end
43
43
  end
44
44
 
@@ -62,7 +62,7 @@ describe Rack::OAuth2::Server::Authorize::Extension::IdToken do
62
62
  let(:env) { Rack::MockRequest.env_for("/authorize?client_id=client_id&scope=openid") }
63
63
  let(:request) { Rack::OAuth2::Server::Authorize::Extension::IdToken::Request.new env }
64
64
  it do
65
- request.openid_connect_request?.should be_true
65
+ request.openid_connect_request?.should == true
66
66
  end
67
67
  end
68
68
  end
data/spec/spec_helper.rb CHANGED
@@ -5,7 +5,14 @@ SimpleCov.start do
5
5
  end
6
6
 
7
7
  require 'rspec'
8
+ require 'rspec/its'
8
9
  require 'openid_connect'
9
10
 
11
+ RSpec.configure do |config|
12
+ config.expect_with :rspec do |c|
13
+ c.syntax = [:should, :expect]
14
+ end
15
+ end
16
+
10
17
  require 'helpers/crypto_spec_helper'
11
18
  require 'helpers/webmock_helper'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openid_connect
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - nov matake
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-25 00:00:00.000000000 Z
11
+ date: 2014-07-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -156,42 +156,56 @@ dependencies:
156
156
  requirements:
157
157
  - - ">="
158
158
  - !ruby/object:Gem::Version
159
- version: '0.8'
159
+ version: '0'
160
160
  type: :development
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
164
  - - ">="
165
165
  - !ruby/object:Gem::Version
166
- version: '0.8'
166
+ version: '0'
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: rspec
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
171
  - - ">="
172
172
  - !ruby/object:Gem::Version
173
- version: '2'
173
+ version: '0'
174
174
  type: :development
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
178
  - - ">="
179
179
  - !ruby/object:Gem::Version
180
- version: '2'
180
+ version: '0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: rspec-its
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
181
195
  - !ruby/object:Gem::Dependency
182
196
  name: webmock
183
197
  requirement: !ruby/object:Gem::Requirement
184
198
  requirements:
185
199
  - - ">="
186
200
  - !ruby/object:Gem::Version
187
- version: 1.6.2
201
+ version: '0'
188
202
  type: :development
189
203
  prerelease: false
190
204
  version_requirements: !ruby/object:Gem::Requirement
191
205
  requirements:
192
206
  - - ">="
193
207
  - !ruby/object:Gem::Version
194
- version: 1.6.2
208
+ version: '0'
195
209
  - !ruby/object:Gem::Dependency
196
210
  name: simplecov
197
211
  requirement: !ruby/object:Gem::Requirement
@@ -314,7 +328,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
314
328
  version: '0'
315
329
  requirements: []
316
330
  rubyforge_project:
317
- rubygems_version: 2.2.0
331
+ rubygems_version: 2.2.2
318
332
  signing_key:
319
333
  specification_version: 4
320
334
  summary: OpenID Connect Server & Client Library