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

Warden::Manager#initialize clobbers default_strategies #141

Closed
ginjo opened this issue Sep 15, 2016 · 0 comments
Closed

Warden::Manager#initialize clobbers default_strategies #141

ginjo opened this issue Sep 15, 2016 · 0 comments

Comments

@ginjo
Copy link

ginjo commented Sep 15, 2016

When passing a hash of options, or a Warden::Config instance to Warden::Manager#initialize (where the 'use' method eventually hits in a middleware instance), any passed :default_strategies are clobbered - or rather corrupted - and end up breaking the authenticate! method. This also happens when passing :scope_defaults into Warden::Manager#initialize. The only workable way to send config into Warden::Manager#initialize is with the block in the 'use' method. The expected behavior would seem to be that a hash, a Warden::Config instance, or a block passed to Warden::Manager#initialize would result in a manager instance with identical configuration.

Breaking example:

new_manager = Warden::Manager.new(Proc.new{}, :default_strategies=>{:default=>[:password]})
puts new_manager.to_yaml

--- !ruby/object:Warden::Manager
config: !ruby/hash:Warden::Config
  :default_scope: :default
  :scope_defaults: {}
  :default_strategies:
    :_all:
    - :default
    - :password
  :intercept_401: true
app: !ruby/object:Proc {}

Notice that default_strategies now has a key :_all, and worse, is now looking for a strategy called :default, which will raise an exception (unless skip_missing_strategies is always set, or unless a strategy named :default is explicitly defined).

Another breaking example:

new_manager = Warden::Manager.new(Proc.new{}, :scope_defaults=>{:default => {:strategies=>[:password]}})
puts new_manager.to_yaml

--- !ruby/object:Warden::Manager
config: !ruby/hash:Warden::Config
  :scope_defaults:
    :default:
      :strategies:
      - :password
  :default_scope: :default
  :default_strategies: {}
  :intercept_401: true
app: !ruby/object:Proc {}

In this case, the default_strategies are not being constructed by Warden::Config, and Warden::Manager does not correct the missing data. Is this intended behavior, or is this an issue with Warden::Config?

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

No branches or pull requests

2 participants