openid_connect 0.6.1 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +5 -5
  2. data/.github/FUNDING.yml +3 -0
  3. data/.github/workflows/spec.yml +31 -0
  4. data/.gitignore +1 -0
  5. data/CHANGELOG.md +23 -0
  6. data/LICENSE +3 -1
  7. data/README.rdoc +10 -3
  8. data/Rakefile +6 -6
  9. data/TODOs +12 -0
  10. data/VERSION +1 -1
  11. data/lib/openid_connect/access_token/mtls.rb +9 -0
  12. data/lib/openid_connect/access_token.rb +14 -6
  13. data/lib/openid_connect/client/registrar.rb +69 -130
  14. data/lib/openid_connect/client.rb +7 -12
  15. data/lib/openid_connect/discovery/provider/config/resource.rb +5 -3
  16. data/lib/openid_connect/discovery/provider/config/response.rb +73 -78
  17. data/lib/openid_connect/discovery/provider/config.rb +5 -2
  18. data/lib/openid_connect/discovery/provider.rb +6 -2
  19. data/lib/openid_connect/discovery.rb +0 -2
  20. data/lib/openid_connect/jwtnizable.rb +6 -4
  21. data/lib/openid_connect/request_object/claimable.rb +4 -6
  22. data/lib/openid_connect/request_object.rb +6 -13
  23. data/lib/openid_connect/response_object/id_token.rb +38 -37
  24. data/lib/openid_connect/response_object/user_info/address.rb +10 -0
  25. data/lib/openid_connect/response_object/user_info.rb +64 -2
  26. data/lib/openid_connect.rb +26 -11
  27. data/lib/rack/oauth2/server/authorize/extension/code_and_id_token.rb +5 -1
  28. data/lib/rack/oauth2/server/authorize/extension/code_and_id_token_and_token.rb +1 -1
  29. data/lib/rack/oauth2/server/authorize/extension/id_token.rb +1 -1
  30. data/lib/rack/oauth2/server/authorize/extension/id_token_and_token.rb +1 -1
  31. data/lib/rack/oauth2/server/authorize/request_with_connect_params.rb +17 -14
  32. data/lib/rack/oauth2/server/id_token_response.rb +11 -13
  33. data/openid_connect.gemspec +19 -13
  34. data/spec/helpers/crypto_spec_helper.rb +2 -2
  35. data/spec/helpers/webmock_helper.rb +14 -9
  36. data/spec/mock_response/access_token/without_token_type.json +3 -0
  37. data/spec/mock_response/discovery/config.json +3 -3
  38. data/spec/mock_response/discovery/config_with_custom_port.json +13 -0
  39. data/spec/mock_response/discovery/config_with_invalid_issuer.json +13 -0
  40. data/spec/mock_response/discovery/config_with_path.json +13 -0
  41. data/spec/mock_response/discovery/config_without_issuer.json +12 -0
  42. data/spec/mock_response/errors/unknown.json +3 -1
  43. data/spec/mock_response/public_keys/{jwk.json → jwks.json} +1 -1
  44. data/spec/mock_response/public_keys/jwks_with_private_key.json +8 -0
  45. data/spec/mock_response/public_keys/private_key.pem +27 -0
  46. data/spec/openid_connect/access_token_spec.rb +11 -20
  47. data/spec/openid_connect/client/registrar_spec.rb +93 -208
  48. data/spec/openid_connect/client_spec.rb +79 -22
  49. data/spec/openid_connect/connect_object_spec.rb +1 -1
  50. data/spec/openid_connect/discovery/provider/config/response_spec.rb +76 -284
  51. data/spec/openid_connect/discovery/provider/config_spec.rb +64 -27
  52. data/spec/openid_connect/discovery/provider_spec.rb +2 -2
  53. data/spec/openid_connect/request_object_spec.rb +4 -4
  54. data/spec/openid_connect/response_object/id_token_spec.rb +94 -52
  55. data/spec/openid_connect/response_object/user_info/{open_id/address_spec.rb → address_spec.rb} +3 -3
  56. data/spec/openid_connect/response_object/{user_info/open_id_spec.rb → user_info_spec.rb} +13 -12
  57. data/spec/openid_connect_spec.rb +19 -19
  58. data/spec/rack/oauth2/server/authorize/extension/code_and_id_token_and_token_spec.rb +11 -0
  59. data/spec/rack/oauth2/server/authorize/extension/code_and_id_token_spec.rb +11 -0
  60. data/spec/rack/oauth2/server/authorize/extension/id_token_and_token_spec.rb +11 -0
  61. data/spec/rack/oauth2/server/authorize/extension/id_token_spec.rb +1 -1
  62. data/spec/rack/oauth2/server/authorize/request_with_connect_params_spec.rb +45 -0
  63. data/spec/spec_helper.rb +12 -1
  64. metadata +155 -90
  65. data/.travis.yml +0 -3
  66. data/Gemfile.lock +0 -102
  67. data/lib/openid_connect/debugger/request_filter.rb +0 -28
  68. data/lib/openid_connect/debugger.rb +0 -3
  69. data/lib/openid_connect/response_object/user_info/open_id/address.rb +0 -12
  70. data/lib/openid_connect/response_object/user_info/open_id.rb +0 -64
  71. data/lib/rack/oauth2/server/resource/error_with_connect_ext.rb +0 -14
  72. data/spec/mock_response/public_keys/x509.pem +0 -21
  73. data/spec/openid_connect/debugger/request_filter_spec.rb +0 -33
  74. data/spec/rack/oauth2/server/resource/error_with_connect_ext_spec.rb +0 -12
  75. /data/spec/mock_response/{user_info → userinfo}/openid.json +0 -0
@@ -1,64 +0,0 @@
1
- module OpenIDConnect
2
- class ResponseObject
3
- module UserInfo
4
- class OpenID < ConnectObject
5
- attr_optional(
6
- :sub,
7
- :name,
8
- :given_name,
9
- :family_name,
10
- :middle_name,
11
- :nickname,
12
- :preferred_username,
13
- :profile,
14
- :picture,
15
- :website,
16
- :email,
17
- :email_verified,
18
- :gender,
19
- :birthdate,
20
- :zoneinfo,
21
- :locale,
22
- :phone_number,
23
- :address,
24
- :updated_time
25
- )
26
- alias_method :subject, :sub
27
- alias_method :subject=, :sub=
28
-
29
- validates :email_verified, inclusion: {in: [true, false]}, allow_nil: true
30
- validates :gender, inclusion: {in: ['male', 'female']}, allow_nil: true
31
- validates :zoneinfo, inclusion: {in: TZInfo::TimezoneProxy.all.collect(&:name)}, allow_nil: true
32
- validates :profile, :picture, :website, url: true, allow_nil: true
33
- validates :email, email: true, allow_nil: true
34
- validate :validate_address
35
- validate :require_at_least_one_attributes
36
- # TODO: validate locale
37
-
38
- def initialize(attributes = {})
39
- super
40
- (all_attributes - [:email_verified, :address]).each do |key|
41
- self.send "#{key}=", self.send(key).try(:to_s)
42
- end
43
- end
44
-
45
- def validate_address
46
- errors.add :address, address.errors.full_messages.join(', ') if address.present? && !address.valid?
47
- end
48
-
49
- def address=(hash_or_address)
50
- @address = case hash_or_address
51
- when Hash
52
- Address.new hash_or_address
53
- when Address
54
- hash_or_address
55
- end
56
- end
57
- end
58
- end
59
- end
60
- end
61
-
62
- Dir[File.dirname(__FILE__) + '/open_id/*.rb'].each do |file|
63
- require file
64
- end
@@ -1,14 +0,0 @@
1
- module Rack
2
- module OAuth2
3
- module Server
4
- class Resource
5
- module ErrorWithConnectExt
6
- def invalid_schema!(description = 'The requested schema is invalid or unsupported', options = {})
7
- bad_request! :invalid_schema, description, options
8
- end
9
- end
10
- Request.send :include, ErrorWithConnectExt
11
- end
12
- end
13
- end
14
- end
@@ -1,21 +0,0 @@
1
- -----BEGIN CERTIFICATE-----
2
- MIIDeDCCAmACCQDFeFSXWEnHxDANBgkqhkiG9w0BAQsFADB+MQswCQYDVQQGEwJK
3
- UDEOMAwGA1UECAwFVG9reW8xEDAOBgNVBAcMB1NoaWJ1eWExITAfBgNVBAoMGElu
4
- dGVybmV0IFdpZGdpdHMgUHR5IEx0ZDEMMAoGA1UEAwwDTm92MRwwGgYJKoZIhvcN
5
- AQkBFg1ub3ZAbWF0YWtlLmpwMB4XDTExMDkxMzEzMjIzNFoXDTEyMDkxMjEzMjIz
6
- NFowfjELMAkGA1UEBhMCSlAxDjAMBgNVBAgMBVRva3lvMRAwDgYDVQQHDAdTaGli
7
- dXlhMSEwHwYDVQQKDBhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQxDDAKBgNVBAMM
8
- A05vdjEcMBoGCSqGSIb3DQEJARYNbm92QG1hdGFrZS5qcDCCASIwDQYJKoZIhvcN
9
- AQEBBQADggEPADCCAQoCggEBAKSsm7NFmh1P8uHB8Vm5vFs4+uh7XMhZ+xYd5/vf
10
- ak17ucjWt9DEWCGH0g8HvSVXNSVKBsONcqtkrXRgSeNB8YnIYxPmKKX7twefEJYC
11
- b06FG1g+IJkwxoDBsUMbb9RJ9snnWsp0O97A6SCvtdiSQ2Oeab3/jwokkPTo8WS4
12
- lRipQpQ7rOOP7r9t+9G/SDdiYhDhfmuyQamkxGCz6V2qClg0pyTaJ6+/bS9E+4ri
13
- ZjtZe9OaDt2NE0PiDS2Oo5yhv0abL8rxjZ8D/aTL3D9aYSrFmddKH7roSRkafCMU
14
- C/UX80/OzrxdEQUjtVO94dPWD/nKK1g7JyiIuk280aTeWA8CAwEAATANBgkqhkiG
15
- 9w0BAQsFAAOCAQEAdiNDw9z6U8lIF0NWVObeGqoxn/MSp/W5S56ts3agw0meqc1J
16
- gUPkncXbpjZ/wX0Y3pupmGBIO0XAHPhjyCu3HhplhaVxSNqKEg9wB3huYaMZ2Kbi
17
- +Wy77hLO2hOYk8vI/ok5oW0lhhpA0o4GzbyV4SA3nZgT0u8YXC7cqAHqI9KsBU5z
18
- 62mjlptCR/b10xTlC13AtbdDM6s1hWP9XpDrm6Kxgfu7nKQ1Q31ag1Ukm9Gw8qcl
19
- ILxZxqbqGy/q1C+6ObTmGtiVbJTs+W8u5BPg9S49O6qIhVN5wWCT4lRrlpXpYA3a
20
- TTVBULB1g7Iod2g+kF0qAXnwqGvZ5LOgwFfmcw==
21
- -----END CERTIFICATE-----
@@ -1,33 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe OpenIDConnect::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) { OpenIDConnect::Debugger::RequestFilter.new }
8
-
9
- describe '#filter_request' do
10
- it 'should log request' do
11
- [
12
- "======= [OpenIDConnect] HTTP REQUEST STARTED =======",
13
- request.dump
14
- ].each do |output|
15
- OpenIDConnect.logger.should_receive(:info).with output
16
- end
17
- request_filter.filter_request(request)
18
- end
19
- end
20
-
21
- describe '#filter_response' do
22
- it 'should log response' do
23
- [
24
- "--------------------------------------------------",
25
- response.dump,
26
- "======= [OpenIDConnect] HTTP REQUEST FINISHED ======="
27
- ].each do |output|
28
- OpenIDConnect.logger.should_receive(:info).with output
29
- end
30
- request_filter.filter_response(request, response)
31
- end
32
- end
33
- end
@@ -1,12 +0,0 @@
1
- require 'spec_helper.rb'
2
-
3
- describe Rack::OAuth2::Server::Resource::ErrorWithConnectExt do
4
- let(:env) { Rack::MockRequest.env_for("/authorize?client_id=client_id") }
5
- let(:request) { Rack::OAuth2::Server::Resource::Request.new env }
6
-
7
- describe 'invalid_schema!' do
8
- it do
9
- expect { request.invalid_schema! }.to raise_error Rack::OAuth2::Server::Resource::BadRequest
10
- end
11
- end
12
- end