Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined method `symbolize_keys' for Warden::JWTAuth:Module (NoMethodError) #159

Closed
r6m opened this issue Feb 16, 2020 · 7 comments
Closed
Labels

Comments

@r6m
Copy link

r6m commented Feb 16, 2020

Please, for a bug report fill in the following template. Before that, make sure to read the whole README and check if your issue is not related with CORS.

Feature requests and questions about devise-jwt are also accepted. It isn't the place for generic questions about using devise with an API. For that, read our wiki page or ask somewhere else like stackoverflow

Expected behavior

Actual behavior

/Users/reza/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/warden-jwt_auth-0.3.6/lib/warden/jwt_auth.rb:38:in `block in <module:JWTAuth>': undefined method `symbolize_keys' for Warden::JWTAuth:Module (NoMethodError)

Steps to Reproduce the Problem

  1. add gem 'devise' and gem 'devise-jwt', '~> 0.5.9' to Gemfile, then run bundle
  2. do any generate like bundle exec rake secret

Debugging information

Provide following information. Please, format pasted output as code. Feel free to remove the secret key value.

  • Version of ruby: 2.6.5
  • Version of devise-jwt in use: '~> 0.5.9'
  • Version of rails in use: 6.0.2.1
  • Output of Devise::JWT.config
  • Output of Warden::JWTAuth.config
  • Output of Devise.mappings
  • If your issue is related with not getting a JWT from the server:
    • Involved request path, method and request headers
    • Response headers for that request
  • If your issue is related with not being able to revoke a JWT:
    • Involved request path, method and request headers
@Mansh05
Copy link

Mansh05 commented Feb 16, 2020

Saw this after posting it myself, I have provided more details here. If anyone could help.

@waiting-for-dev
Copy link
Owner

For now lock you dry-configurable version to 0.9. I'll take a look as soon as possible.

@waiting-for-dev
Copy link
Owner

Fixed. It was a regression in dry-configurable and it has been fixed there. I've released v0.4.1 of warden-jwt_auth (which is the core engine for devise-jwt) depending on a version at least equal that the one containing the fix. So, in order to fix it for devise-jwt users, you just need to update warden-jwt:

bundle update --source warden-jwt_auth

@waiting-for-dev
Copy link
Owner

Hold on, there're still some issues to be resolved. So keep with the version of dry-configurable locked. I'll report on news.

@marclennox
Copy link

Still seeing the following error when I don't freeze dry-configurable

Traceback (most recent call last):
	58: from bin/rails:6:in `<main>'
	57: from /usr/local/lib/ruby/bundler/ruby/2.7.0/gems/activesupport-6.0.2.1/lib/active_support/dependencies.rb:325:in `require'
	56: from /usr/local/lib/ruby/bundler/ruby/2.7.0/gems/activesupport-6.0.2.1/lib/active_support/dependencies.rb:291:in `load_dependency'
	55: from /usr/local/lib/ruby/bundler/ruby/2.7.0/gems/activesupport-6.0.2.1/lib/active_support/dependencies.rb:325:in `block in require'
	54: from /usr/local/lib/ruby/bundler/ruby/2.7.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
	53: from /usr/local/lib/ruby/bundler/ruby/2.7.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
	52: from /usr/local/lib/ruby/bundler/ruby/2.7.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
	51: from /usr/local/lib/ruby/bundler/ruby/2.7.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
	50: from /usr/local/lib/ruby/bundler/ruby/2.7.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
	49: from /usr/local/lib/ruby/bundler/ruby/2.7.0/gems/railties-6.0.2.1/lib/rails/commands.rb:18:in `<main>'
	48: from /usr/local/lib/ruby/bundler/ruby/2.7.0/gems/railties-6.0.2.1/lib/rails/command.rb:46:in `invoke'
	47: from /usr/local/lib/ruby/bundler/ruby/2.7.0/gems/railties-6.0.2.1/lib/rails/command/base.rb:69:in `perform'
	46: from /usr/local/lib/ruby/bundler/ruby/2.7.0/gems/thor-1.0.1/lib/thor.rb:392:in `dispatch'
	45: from /usr/local/lib/ruby/bundler/ruby/2.7.0/gems/thor-1.0.1/lib/thor/invocation.rb:127:in `invoke_command'
	44: from /usr/local/lib/ruby/bundler/ruby/2.7.0/gems/thor-1.0.1/lib/thor/command.rb:27:in `run'
	43: from /usr/local/lib/ruby/bundler/ruby/2.7.0/gems/railties-6.0.2.1/lib/rails/commands/console/console_command.rb:101:in `perform'
	42: from /usr/local/lib/ruby/bundler/ruby/2.7.0/gems/railties-6.0.2.1/lib/rails/command/actions.rb:15:in `require_application_and_environment!'
	41: from /usr/local/lib/ruby/bundler/ruby/2.7.0/gems/railties-6.0.2.1/lib/rails/command/actions.rb:28:in `require_environment!'
	40: from /usr/local/lib/ruby/bundler/ruby/2.7.0/gems/railties-6.0.2.1/lib/rails/application.rb:339:in `require_environment!'
	39: from /usr/local/lib/ruby/bundler/ruby/2.7.0/gems/activesupport-6.0.2.1/lib/active_support/dependencies.rb:325:in `require'
	38: from /usr/local/lib/ruby/bundler/ruby/2.7.0/gems/activesupport-6.0.2.1/lib/active_support/dependencies.rb:291:in `load_dependency'
	37: from /usr/local/lib/ruby/bundler/ruby/2.7.0/gems/activesupport-6.0.2.1/lib/active_support/dependencies.rb:325:in `block in require'
	36: from /usr/local/lib/ruby/bundler/ruby/2.7.0/gems/zeitwerk-2.2.2/lib/zeitwerk/kernel.rb:23:in `require'
	35: from /usr/local/lib/ruby/bundler/ruby/2.7.0/gems/skylight-core-4.2.2/lib/skylight/core/probes.rb:118:in `require'
	34: from /usr/local/lib/ruby/bundler/ruby/2.7.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
	33: from /usr/local/lib/ruby/bundler/ruby/2.7.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
	32: from /usr/local/lib/ruby/bundler/ruby/2.7.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
	31: from /usr/local/lib/ruby/bundler/ruby/2.7.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
	30: from /usr/local/lib/ruby/bundler/ruby/2.7.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
	29: from /usr/src/app/config/environment.rb:7:in `<main>'
	28: from /usr/local/lib/ruby/bundler/ruby/2.7.0/gems/railties-6.0.2.1/lib/rails/application.rb:363:in `initialize!'
	27: from /usr/local/lib/ruby/bundler/ruby/2.7.0/gems/railties-6.0.2.1/lib/rails/initializable.rb:60:in `run_initializers'
	26: from /usr/local/lib/ruby/2.7.0/tsort.rb:205:in `tsort_each'
	25: from /usr/local/lib/ruby/2.7.0/tsort.rb:226:in `tsort_each'
	24: from /usr/local/lib/ruby/2.7.0/tsort.rb:347:in `each_strongly_connected_component'
	23: from /usr/local/lib/ruby/2.7.0/tsort.rb:347:in `call'
	22: from /usr/local/lib/ruby/2.7.0/tsort.rb:347:in `each'
	21: from /usr/local/lib/ruby/2.7.0/tsort.rb:349:in `block in each_strongly_connected_component'
	20: from /usr/local/lib/ruby/2.7.0/tsort.rb:431:in `each_strongly_connected_component_from'
	19: from /usr/local/lib/ruby/2.7.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
	18: from /usr/local/lib/ruby/2.7.0/tsort.rb:228:in `block in tsort_each'
	17: from /usr/local/lib/ruby/bundler/ruby/2.7.0/gems/railties-6.0.2.1/lib/rails/initializable.rb:61:in `block in run_initializers'
	16: from /usr/local/lib/ruby/bundler/ruby/2.7.0/gems/railties-6.0.2.1/lib/rails/initializable.rb:32:in `run'
	15: from /usr/local/lib/ruby/bundler/ruby/2.7.0/gems/railties-6.0.2.1/lib/rails/initializable.rb:32:in `instance_exec'
	14: from /usr/local/lib/ruby/bundler/ruby/2.7.0/gems/railties-6.0.2.1/lib/rails/application/finisher.rb:129:in `block in <module:Finisher>'
	13: from /usr/local/lib/ruby/bundler/ruby/2.7.0/gems/activesupport-6.0.2.1/lib/active_support/lazy_load_hooks.rb:51:in `run_load_hooks'
	12: from /usr/local/lib/ruby/bundler/ruby/2.7.0/gems/activesupport-6.0.2.1/lib/active_support/lazy_load_hooks.rb:51:in `each'
	11: from /usr/local/lib/ruby/bundler/ruby/2.7.0/gems/activesupport-6.0.2.1/lib/active_support/lazy_load_hooks.rb:52:in `block in run_load_hooks'
	10: from /usr/local/lib/ruby/bundler/ruby/2.7.0/gems/activesupport-6.0.2.1/lib/active_support/lazy_load_hooks.rb:67:in `execute_hook'
	 9: from /usr/local/lib/ruby/bundler/ruby/2.7.0/gems/activesupport-6.0.2.1/lib/active_support/lazy_load_hooks.rb:62:in `with_execution_control'
	 8: from /usr/local/lib/ruby/bundler/ruby/2.7.0/gems/activesupport-6.0.2.1/lib/active_support/lazy_load_hooks.rb:69:in `block in execute_hook'
	 7: from /usr/local/lib/ruby/bundler/ruby/2.7.0/gems/devise-jwt-0.6.0/lib/devise/jwt/railtie.rb:15:in `block (2 levels) in <class:Railtie>'
	 6: from /usr/local/lib/ruby/bundler/ruby/2.7.0/gems/dry-configurable-0.11.3/lib/dry/configurable/methods.rb:15:in `configure'
	 5: from /usr/local/lib/ruby/bundler/ruby/2.7.0/gems/devise-jwt-0.6.0/lib/devise/jwt/railtie.rb:19:in `block (3 levels) in <class:Railtie>'
	 4: from /usr/local/lib/ruby/bundler/ruby/2.7.0/gems/dry-configurable-0.11.3/lib/dry/configurable/config.rb:112:in `method_missing'
	 3: from /usr/local/lib/ruby/bundler/ruby/2.7.0/gems/dry-configurable-0.11.3/lib/dry/configurable/setting.rb:67:in `value'
	 2: from /usr/local/lib/ruby/bundler/ruby/2.7.0/gems/dry-configurable-0.11.3/lib/dry/configurable/setting.rb:116:in `evaluate'
	 1: from /usr/local/lib/ruby/bundler/ruby/2.7.0/gems/warden-jwt_auth-0.4.1/lib/warden/jwt_auth.rb:53:in `block in <module:JWTAuth>'
/usr/local/lib/ruby/bundler/ruby/2.7.0/gems/warden-jwt_auth-0.4.1/lib/warden/jwt_auth.rb:92:in `upcase_first_items': undefined method `map' for nil:NilClass (NoMethodError)

@Ryuday
Copy link

Ryuday commented Mar 18, 2020

Well I'm new to ruby ​​on rails, however in my case you can fix that error by replacing the file
gems > warden-jwt_auth-0.4.1 > lib > warden > jwt_auth.rb

value by [['POST', %r{^/login$}]] in:

52  setting(:dispatch_requests, []) do |value|
53    upcase_first_items(value)
54  end

and value by [['DELETE', %r{^/logout$}]] in:

63  setting :revocation_requests, [] do |value|
64    upcase_first_items(value)
65  end

However, I don't know what consequences it has on the proper functioning of the gem.

The error comes from this method in the file
gems > dry-configurable-0.11.4 > lib > dry > configurable > setting.rb

115  def evaluate
116    @value = constructor[input.equal?(Undefined) ? nil : input]
117  end

when the input variable equals undefined, it loads the null value giving the following error

jwt_auth.rb:92:in `upcase_first_items': undefined method `map' for nil:NilClass (NoMethodError)

@waiting-for-dev
Copy link
Owner

As it's taking longer than expected to be fixed upstream in dry-configurable, I have released a new version of warden-jwt_auth 0.4.2 which locks itself dry-configurable version. This way, once it's updated there I'll just release a new version and it'll be transparent for the user.

So, to fix it when using devise-jwt, just run bundle update --source warden-jwt_auth

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants