test_openid_connect 0.1.5 → 0.1.9

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 803e3b58bb96ce31dda914c5e0a2c222064aca3066fafa3350d79995c33a8e49
4
- data.tar.gz: 14f43a4f33a3e0fb1ae546baae6e637adacc7388a42f3fe79766ad8ac973ec54
3
+ metadata.gz: d4b398f43e088c3757e8ce589e355b58ab932c723273014ade850c93217d9973
4
+ data.tar.gz: ce72e257826144230f21f8bcec635d21e228eabd615fc96682875d7705e0f51e
5
5
  SHA512:
6
- metadata.gz: 4a3de9a01cad7fcfc5bc9f71477d4eeca44f9f41ee4b9bb4d9b6f462c1d8989d96c78aa0e9064a994b87f3d3779a44b971a8e1d8aacc1b4436e61d3435aec2e6
7
- data.tar.gz: 573c05062ae2795f33fd7a98d4a20d11b3af2cd7dae726888b3912e3ff75fc74410fbec4ca974d49cb100d6b62bde1067837befa3d82ac653b5fe3981b0e7b44
6
+ metadata.gz: e66652f2b0092cdbfba5b0b50657dfdce1fa69391b6df003ce2eabe6f962e1156efd89aaac87f0a641db787137c87fcef3a408441221f13a3c8c6b07def3540d
7
+ data.tar.gz: 31a7d846190a604040c789b6d8fb82555bda989f7e51ce0dae6f1017ecb6356964fe2a011a9e3035360ecbb14710f7543ca93c98b50cbdce416bd1c2b57f9b16
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- test_openid_connect (0.1.0)
4
+ test_openid_connect (0.1.6)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'omniauth-oauth2'
4
4
 
5
- module OmniAuth
5
+ module ::OmniAuth
6
6
  module OpenIDConnect
7
7
  class DiscoveryError < Error; end
8
8
  end
@@ -13,9 +13,9 @@ module OmniAuth
13
13
  option :scope, "openid"
14
14
  option :discovery, true
15
15
  option :use_userinfo, true
16
- option :cache, lambda { |key, &blk| blk.call } # Default no-op cache
17
- option :error_handler, lambda { |error, message| nil } # Default no-op handler
18
- option :verbose_logger, lambda { |message| nil } # Default no-op handler
16
+ # option :cache, lambda { |key, &blk| blk.call } # Default no-op cache
17
+ # option :error_handler, lambda { |error, message| nil } # Default no-op handler
18
+ # option :verbose_logger, lambda { |message| nil } # Default no-op handler
19
19
  option :passthrough_authorize_options, [:p]
20
20
  option :passthrough_token_options, [:p]
21
21
 
@@ -27,17 +27,17 @@ module OmniAuth
27
27
  userinfo_endpoint: nil,
28
28
  auth_scheme: :basic_auth
29
29
 
30
- def verbose_log(message)
31
- options.verbose_logger.call(message)
32
- end
30
+ # def verbose_log(message)
31
+ # options.verbose_logger.call(message)
32
+ # end
33
33
 
34
34
  def discover!
35
- verbose_log("Fetching discovery document from #{options[:client_options][:discovery_document]}")
36
- discovery_document = options.cache.call("openid_discovery_#{options[:client_options][:discovery_document]}") do
37
- client.request(:get, options[:client_options][:discovery_document], parse: :json).parsed
38
- end
39
- verbose_log("Discovery document loaded\n\n#{discovery_document.to_yaml}")
40
-
35
+ # verbose_log("Fetching discovery document from #{options[:client_options][:discovery_document]}")
36
+ discovery_document = client.request(:get, options[:client_options][:discovery_document], parse: :json).parsed
37
+ # verbose_log("Discovery document loaded\n\n#{discovery_document.to_yaml}")
38
+ puts "****************"
39
+ puts discovery_document
40
+ puts "****************"
41
41
  discovery_params = {
42
42
  authorize_url: "authorization_endpoint",
43
43
  token_url: "token_endpoint",
@@ -54,14 +54,18 @@ module OmniAuth
54
54
  options.use_userinfo = false if userinfo_endpoint.nil? || userinfo_endpoint.empty?
55
55
  end
56
56
 
57
- def request_phase
58
- begin
59
- discover! if options[:discovery]
60
- rescue ::OmniAuth::OpenIDConnect::DiscoveryError => e
61
- fail!(:openid_connect_discovery_error, e)
62
- end
57
+ # def request_phase
58
+ # begin
59
+ # discover! if options[:discovery]
60
+ # rescue ::OmniAuth::OpenIDConnect::DiscoveryError => e
61
+ # fail!(:openid_connect_discovery_error, e)
62
+ # end
63
+
64
+ # super
65
+ # end
63
66
 
64
- super
67
+ def request_phase
68
+ redirect client.auth_code.authorize_url({:redirect_uri => callback_url}.merge(options.authorize_params))
65
69
  end
66
70
 
67
71
  def authorize_params
@@ -88,28 +92,28 @@ module OmniAuth
88
92
  super.merge(params)
89
93
  end
90
94
 
91
- def callback_phase
92
- if request.params["error"] && request.params["error_description"] && response = options.error_handler.call(request.params["error"], request.params["error_description"])
93
- verbose_log("Error handled, redirecting\n\n#{response.to_yaml}")
94
- return redirect(response)
95
- end
96
-
97
- begin
98
- discover! if options[:discovery]
99
-
100
- oauth2_callback_phase = super
101
- return oauth2_callback_phase if env['omniauth.error']
102
-
103
- if id_token_info["nonce"].nil? || id_token_info["nonce"].empty? || id_token_info["nonce"] != session.delete("omniauth.nonce")
104
- return fail!(:csrf_detected, CallbackError.new(:csrf_detected, "CSRF detected"))
105
- end
106
- oauth2_callback_phase
107
- rescue ::OmniAuth::OpenIDConnect::DiscoveryError => e
108
- fail!(:openid_connect_discovery_error, e)
109
- rescue JWT::DecodeError => e
110
- fail!(:jwt_decode_failed, e)
111
- end
112
- end
95
+ # def callback_phase
96
+ # if request.params["error"] && request.params["error_description"]
97
+ # # verbose_log("Error handled, redirecting\n\n#{response.to_yaml}")
98
+ # return redirect(response)
99
+ # end
100
+
101
+ # begin
102
+ # discover! if options[:discovery]
103
+
104
+ # oauth2_callback_phase = super
105
+ # return oauth2_callback_phase if env['omniauth.error']
106
+
107
+ # if id_token_info["nonce"].nil? || id_token_info["nonce"].empty? || id_token_info["nonce"] != session.delete("omniauth.nonce")
108
+ # return fail!(:csrf_detected, CallbackError.new(:csrf_detected, "CSRF detected"))
109
+ # end
110
+ # oauth2_callback_phase
111
+ # rescue ::OmniAuth::OpenIDConnect::DiscoveryError => e
112
+ # fail!(:openid_connect_discovery_error, e)
113
+ # rescue JWT::DecodeError => e
114
+ # fail!(:jwt_decode_failed, e)
115
+ # end
116
+ # end
113
117
 
114
118
  def id_token_info
115
119
  # Verify the claims in the JWT
@@ -117,7 +121,7 @@ module OmniAuth
117
121
  # token was acquired via a direct server-server connection to the issuer
118
122
  @id_token_info ||= begin
119
123
  decoded = JWT.decode(access_token['id_token'], nil, false).first
120
- verbose_log("Loaded JWT\n\n#{decoded.to_yaml}")
124
+ # verbose_log("Loaded JWT\n\n#{decoded.to_yaml}")
121
125
  JWT::Verify.verify_claims(decoded,
122
126
  verify_iss: true,
123
127
  iss: options[:client_options][:site],
@@ -129,7 +133,7 @@ module OmniAuth
129
133
  verify_iat: false,
130
134
  verify_jti: false
131
135
  )
132
- verbose_log("Verified JWT\n\n#{decoded.to_yaml}")
136
+ # verbose_log("Verified JWT\n\n#{decoded.to_yaml}")
133
137
 
134
138
  decoded
135
139
  end
@@ -138,7 +142,7 @@ module OmniAuth
138
142
  def userinfo_response
139
143
  @raw_info ||= begin
140
144
  info = access_token.get(options[:client_options][:userinfo_endpoint]).parsed
141
- verbose_log("Fetched userinfo response\n\n#{info.to_yaml}")
145
+ # verbose_log("Fetched userinfo response\n\n#{info.to_yaml}")
142
146
  info
143
147
  end
144
148
 
@@ -202,7 +206,7 @@ end
202
206
 
203
207
  OmniAuth.config.add_camelization 'oauth2', 'OpenIDConnect'
204
208
 
205
- module OmniAuth
209
+ module ::OmniAuth
206
210
  module Strategies
207
211
  autoload :OpenIDConnect, "lib/omniauth/test_openid_connect.rb"
208
212
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "test_openid_connect"
5
- spec.version = "0.1.5"
5
+ spec.version = "0.1.9"
6
6
  spec.required_ruby_version = ">= 2.4.0"
7
7
  spec.authors = ["Burak Akça"]
8
8
  spec.email = ["burak.akca834@gmail.com"]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test_openid_connect
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Burak Akça
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-08-31 00:00:00.000000000 Z
11
+ date: 2021-09-01 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: 'desc desc desc desc '
14
14
  email: