omniauth / omniauth_openid_connect

MIT License
170 stars 187 forks source link

NoMethodError: undefined method `count' for nil:NilClass #59

Closed ecylmz closed 4 years ago

ecylmz commented 4 years ago

Hi,

After upgrading Gem to 0.3.4, we started getting the following error:

NoMethodError: undefined method `count' for nil:NilClass
  File "/app/vendor/bundle/ruby/2.7.0/gems/json-jwt-1.11.0/lib/json/jwt.rb", line 102, in decode_compact_serialized
  File "/app/vendor/bundle/ruby/2.7.0/gems/json-jwt-1.11.0/lib/json/jose.rb", line 63, in decode
  File "/app/vendor/bundle/ruby/2.7.0/gems/openid_connect-1.2.0/lib/openid_connect/response_object/id_token.rb", line 70, in decode
  File "/app/vendor/bundle/ruby/2.7.0/gems/omniauth_openid_connect-0.3.4/lib/omniauth/strategies/openid_connect.rb", line 221, in decode_id_token
  File "/app/vendor/bundle/ruby/2.7.0/gems/omniauth_openid_connect-0.3.4/lib/omniauth/strategies/openid_connect.rb", line 215, in access_token
  File "/app/vendor/bundle/ruby/2.7.0/gems/omniauth_openid_connect-0.3.4/lib/omniauth/strategies/openid_connect.rb", line 125, in callback_phase
  File "/app/vendor/bundle/ruby/2.7.0/gems/omniauth-1.9.1/lib/omniauth/strategy.rb", line 238, in callback_call
  File "/app/vendor/bundle/ruby/2.7.0/gems/omniauth-1.9.1/lib/omniauth/strategy.rb", line 189, in call!
  File "/app/vendor/bundle/ruby/2.7.0/gems/omniauth-1.9.1/lib/omniauth/strategy.rb", line 169, in call
  File "/app/vendor/bundle/ruby/2.7.0/gems/rack-attack-6.3.1/lib/rack/attack.rb", line 97, in call
  File "/app/vendor/bundle/ruby/2.7.0/gems/rack-attack-6.3.1/lib/rack/attack.rb", line 111, in call
  File "/app/vendor/bundle/ruby/2.7.0/gems/warden-1.2.8/lib/warden/manager.rb", line 36, in block in call
  File "/app/vendor/bundle/ruby/2.7.0/gems/warden-1.2.8/lib/warden/manager.rb", line 34, in catch
  File "/app/vendor/bundle/ruby/2.7.0/gems/warden-1.2.8/lib/warden/manager.rb", line 34, in call
  File "/app/vendor/bundle/ruby/2.7.0/gems/rack-2.2.2/lib/rack/tempfile_reaper.rb", line 15, in call
  File "/app/vendor/bundle/ruby/2.7.0/gems/rack-2.2.2/lib/rack/etag.rb", line 27, in call
  File "/app/vendor/bundle/ruby/2.7.0/gems/rack-2.2.2/lib/rack/conditional_get.rb", line 27, in call
  File "/app/vendor/bundle/ruby/2.7.0/gems/rack-2.2.2/lib/rack/head.rb", line 12, in call
  File "/app/vendor/bundle/ruby/2.7.0/gems/actionpack-6.0.3.1/lib/action_dispatch/http/content_security_policy.rb", line 18, in call
  File "/app/vendor/bundle/ruby/2.7.0/gems/rack-2.2.2/lib/rack/session/abstract/id.rb", line 266, in context
  File "/app/vendor/bundle/ruby/2.7.0/gems/rack-2.2.2/lib/rack/session/abstract/id.rb", line 260, in call
  File "/app/vendor/bundle/ruby/2.7.0/gems/actionpack-6.0.3.1/lib/action_dispatch/middleware/cookies.rb", line 648, in call
  File "/app/vendor/bundle/ruby/2.7.0/gems/actionpack-6.0.3.1/lib/action_dispatch/middleware/callbacks.rb", line 27, in block in call
  File "/app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.1/lib/active_support/callbacks.rb", line 101, in run_callbacks
  File "/app/vendor/bundle/ruby/2.7.0/gems/actionpack-6.0.3.1/lib/action_dispatch/middleware/callbacks.rb", line 26, in call
  File "/app/vendor/bundle/ruby/2.7.0/gems/actionpack-6.0.3.1/lib/action_dispatch/middleware/actionable_exceptions.rb", line 17, in call
  File "/app/vendor/bundle/ruby/2.7.0/gems/rollbar-2.25.0/lib/rollbar/middleware/rails/rollbar.rb", line 25, in block in call
  File "/app/vendor/bundle/ruby/2.7.0/gems/rollbar-2.25.0/lib/rollbar.rb", line 145, in scoped
  File "/app/vendor/bundle/ruby/2.7.0/gems/rollbar-2.25.0/lib/rollbar/middleware/rails/rollbar.rb", line 22, in call
  File "/app/vendor/bundle/ruby/2.7.0/gems/actionpack-6.0.3.1/lib/action_dispatch/middleware/debug_exceptions.rb", line 32, in call
  File "/app/vendor/bundle/ruby/2.7.0/gems/rollbar-2.25.0/lib/rollbar/middleware/rails/show_exceptions.rb", line 22, in call_with_rollbar
  File "/app/vendor/bundle/ruby/2.7.0/gems/actionpack-6.0.3.1/lib/action_dispatch/middleware/show_exceptions.rb", line 33, in call
  File "/app/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.1/lib/rails/rack/logger.rb", line 37, in call_app
  File "/app/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.1/lib/rails/rack/logger.rb", line 26, in block in call
  File "/app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.1/lib/active_support/tagged_logging.rb", line 80, in block in tagged
  File "/app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.1/lib/active_support/tagged_logging.rb", line 28, in tagged
  File "/app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.1/lib/active_support/tagged_logging.rb", line 80, in tagged
  File "/app/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.1/lib/rails/rack/logger.rb", line 26, in call
  File "/app/vendor/bundle/ruby/2.7.0/gems/actionpack-6.0.3.1/lib/action_dispatch/middleware/remote_ip.rb", line 81, in call
  File "/app/vendor/bundle/ruby/2.7.0/gems/request_store-1.5.0/lib/request_store/middleware.rb", line 19, in call
  File "/app/vendor/bundle/ruby/2.7.0/gems/actionpack-6.0.3.1/lib/action_dispatch/middleware/request_id.rb", line 27, in call
  File "/app/vendor/bundle/ruby/2.7.0/gems/rack-2.2.2/lib/rack/method_override.rb", line 24, in call
  File "/app/vendor/bundle/ruby/2.7.0/gems/rack-2.2.2/lib/rack/runtime.rb", line 22, in call
  File "/app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.1/lib/active_support/cache/strategy/local_cache_middleware.rb", line 29, in call
  File "/app/vendor/bundle/ruby/2.7.0/gems/actionpack-6.0.3.1/lib/action_dispatch/middleware/executor.rb", line 14, in call
  File "/app/vendor/bundle/ruby/2.7.0/gems/actionpack-6.0.3.1/lib/action_dispatch/middleware/static.rb", line 126, in call
  File "/app/vendor/bundle/ruby/2.7.0/gems/rack-2.2.2/lib/rack/sendfile.rb", line 110, in call
  File "/app/vendor/bundle/ruby/2.7.0/gems/actionpack-6.0.3.1/lib/action_dispatch/middleware/ssl.rb", line 74, in call
  File "/app/vendor/bundle/ruby/2.7.0/gems/actionpack-6.0.3.1/lib/action_dispatch/middleware/host_authorization.rb", line 76, in call
  File "/app/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.1/lib/rails/engine.rb", line 527, in call
  File "/app/vendor/bundle/ruby/2.7.0/gems/puma-4.3.5/lib/puma/configuration.rb", line 228, in call
  File "/app/vendor/bundle/ruby/2.7.0/gems/puma-4.3.5/lib/puma/server.rb", line 713, in handle_request
  File "/app/vendor/bundle/ruby/2.7.0/gems/puma-4.3.5/lib/puma/server.rb", line 472, in process_client
  File "/app/vendor/bundle/ruby/2.7.0/gems/puma-4.3.5/lib/puma/server.rb", line 328, in block in run
  File "/app/vendor/bundle/ruby/2.7.0/gems/puma-4.3.5/lib/puma/thread_pool.rb", line 134, in block in spawn_thread

There is no problem when we downgrade the gem version to 0.3.3.

Thanks.

Eric-Guo commented 4 years ago

Same issue with another backtrace log.

I, [2020-05-22T07:12:43.318200 #618]  INFO -- : Started GET "/auth/openid_connect/callback?code=CeNwL0llkRK1WMb9ROEv6n8uVoz9sR8trfieMTakTwA&state=02f0ee1c46f7e18f4cf40d42d80da54f" for 180.97.204.251 at 2020-05-22 07:12:43 +0800
F, [2020-05-22T07:12:48.373148 #618] FATAL -- :   
NoMethodError (undefined method `count' for #<OpenIDConnect::ResponseObject::IdToken:0x0000000008d9dde0>):

json-jwt (1.11.0) lib/json/jwt.rb:102:in `decode_compact_serialized'
json-jwt (1.11.0) lib/json/jose.rb:63:in `decode'
openid_connect (1.2.0) lib/openid_connect/response_object/id_token.rb:70:in `decode'
omniauth_openid_connect (0.3.4) lib/omniauth/strategies/openid_connect.rb:221:in `decode_id_token'
omniauth_openid_connect (0.3.4) lib/omniauth/strategies/openid_connect.rb:333:in `verify_id_token!'
omniauth_openid_connect (0.3.4) lib/omniauth/strategies/openid_connect.rb:215:in `access_token'
omniauth_openid_connect (0.3.4) lib/omniauth/strategies/openid_connect.rb:125:in `callback_phase'
omniauth (1.9.1) lib/omniauth/strategy.rb:238:in `callback_call'
omniauth (1.9.1) lib/omniauth/strategy.rb:189:in `call!'
omniauth (1.9.1) lib/omniauth/strategy.rb:169:in `call'
omniauth (1.9.1) lib/omniauth/builder.rb:45:in `call'
warden-jwt_auth (0.4.2) lib/warden/jwt_auth/middleware/token_dispatcher.rb:20:in `call'
warden-jwt_auth (0.4.2) lib/warden/jwt_auth/middleware/revocation_manager.rb:21:in `call'
rack (2.0.9) lib/rack/builder.rb:153:in `call'
warden-jwt_auth (0.4.2) lib/warden/jwt_auth/middleware.rb:23:in `call'
warden (1.2.8) lib/warden/manager.rb:36:in `block in call'
warden (1.2.8) lib/warden/manager.rb:34:in `catch'
warden (1.2.8) lib/warden/manager.rb:34:in `call'
rack (2.0.9) lib/rack/tempfile_reaper.rb:15:in `call'
rack (2.0.9) lib/rack/etag.rb:25:in `call'
rack (2.0.9) lib/rack/conditional_get.rb:25:in `call'
rack (2.0.9) lib/rack/head.rb:12:in `call'
actionpack (6.0.3.1) lib/action_dispatch/http/content_security_policy.rb:18:in `call'
rack (2.0.9) lib/rack/session/abstract/id.rb:259:in `context'
rack (2.0.9) lib/rack/session/abstract/id.rb:253:in `call'
actionpack (6.0.3.1) lib/action_dispatch/middleware/cookies.rb:648:in `call'
actionpack (6.0.3.1) lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'
activesupport (6.0.3.1) lib/active_support/callbacks.rb:101:in `run_callbacks'
actionpack (6.0.3.1) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
actionpack (6.0.3.1) lib/action_dispatch/middleware/actionable_exceptions.rb:17:in `call'
actionpack (6.0.3.1) lib/action_dispatch/middleware/debug_exceptions.rb:32:in `call'
actionpack (6.0.3.1) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
railties (6.0.3.1) lib/rails/rack/logger.rb:37:in `call_app'
railties (6.0.3.1) lib/rails/rack/logger.rb:26:in `block in call'
activesupport (6.0.3.1) lib/active_support/tagged_logging.rb:80:in `block in tagged'
activesupport (6.0.3.1) lib/active_support/tagged_logging.rb:28:in `tagged'
activesupport (6.0.3.1) lib/active_support/tagged_logging.rb:80:in `tagged'
railties (6.0.3.1) lib/rails/rack/logger.rb:26:in `call'
actionpack (6.0.3.1) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
actionpack (6.0.3.1) lib/action_dispatch/middleware/request_id.rb:27:in `call'
rack (2.0.9) lib/rack/method_override.rb:22:in `call'
rack (2.0.9) lib/rack/runtime.rb:22:in `call'
activesupport (6.0.3.1) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
actionpack (6.0.3.1) lib/action_dispatch/middleware/executor.rb:14:in `call'
rack (2.0.9) lib/rack/sendfile.rb:111:in `call'
actionpack (6.0.3.1) lib/action_dispatch/middleware/ssl.rb:74:in `call'
actionpack (6.0.3.1) lib/action_dispatch/middleware/host_authorization.rb:76:in `call'
railties (6.0.3.1) lib/rails/engine.rb:527:in `call'
puma (4.3.5) lib/puma/configuration.rb:228:in `call'
puma (4.3.5) lib/puma/server.rb:713:in `handle_request'
puma (4.3.5) lib/puma/server.rb:472:in `process_client'
puma (4.3.5) lib/puma/server.rb:328:in `block in run'
puma (4.3.5) lib/puma/thread_pool.rb:134:in `block in spawn_thread'
m0n9oose commented 4 years ago

Thanks for the feedback. I'll take a look at this on weekend

bufferoverflow commented 4 years ago

could be related to https://github.com/m0n9oose/omniauth_openid_connect/pull/44

ecylmz commented 4 years ago

Thanks. @m0n9oose Could you publish a new release? The last release is 0.3.4. https://rubygems.org/gems/omniauth_openid_connect/versions

danielweil commented 4 years ago

Yes, a new release with this bug fixed would be very nice.