Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

CanCan auth? #287

Closed
cj opened this Issue · 3 comments

3 participants

@cj
cj commented

Hi,

Has anyone got CanCan authentication working? I have config.admin_auth = 'CmsCanCanAuth' but it fails with This action failed the check_authorization because it does not authorize_resource. Add skip_authorization_check to bypass this check. before it even reaches the custom auth module. Any help would be great!

@GBH
Owner

I never used CanCan. But what's happening exactly? It's not allowing access to authenticate before_filter?

@cj
cj commented

@GBH Yes, it's checking for CanCan auth before it. Turns out you need to turn off check_authorization for comfy. You can do this by adding these lines to your application_controller:

  check_authorization unless: :do_not_check_authorization?

private

  def do_not_check_authorization?
    controller_path.include? 'cms_admin' or controller_path.include? 'cms_content'
  end
@cj cj closed this
@asgeo1

I think it's better to do the skip the check this way:

  check_authorization :unless => :skip_authorization_check?

private

  def skip_authorization_check?
      self.kind_of?(Comfy::Admin::Cms::BaseController) or
      self.kind_of?(Comfy::Cms::BaseController)
  end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.