square / rails-auth

Modular resource-based authentication and authorization for Rails/Rack
Apache License 2.0
291 stars 26 forks source link

ConfigBuilder.application helper function not working #49

Open hablutzel1 opened 6 years ago

hablutzel1 commented 6 years ago

Following configuration method is not working, https://github.com/square/rails-auth/wiki/Rails-Usage#user-content-configapplicationrb.

It seems to me that the reason is a wrong variable name around https://github.com/square/rails-auth/blob/master/lib/rails/auth/config_builder.rb#L9:

def application(config, acl_file: Rails.root.join("config/acl.yml"), matchers: {})
        config.x.rails_auth.acl = Rails::Auth::ACL.from_yaml(
          File.read(acl_file.to_s),
          matchers: matchers
        )
        config.middleware.use Rails::Auth::ACL::Middleware, acl: config.x.acl
end

Where I think that config.x.rails_auth.acl = Rails::Auth::ACL.from_yaml(... should be config.x.acl = Rails::Auth::ACL.from_yaml(... (without the rails_auth) as later you are doing config.middleware.use Rails::Auth::ACL::Middleware, acl: config.x.acl.

hablutzel1 commented 6 years ago

Take a look too at https://github.com/square/rails-auth/pull/32#pullrequestreview-123590698.