5

I'm just wondering of there is any option where i can turn off CSRF in a specific controller/method. I've got another site that pings my site, but getting blocked because of the CSRF.

Is there any way i can get around this?

2
  • 1
    You can consider to generally disable CI CSRF "protection" because it's broken. Instead know what you do and provide sanity checks on your own to be on the safe side (which you need to do anyway for the controllers in question). Commented Sep 22, 2011 at 0:08
  • 6
    Got a link to how it is broken? first I heard is all. Commented Sep 22, 2011 at 1:23

1 Answer 1

7

Create a pre_system hook then put the following code inside your hook controller:

if(stripos($_SERVER["REQUEST_URI"],'/controller/function') !== FALSE)
{
    $CFG =& load_class('Config', 'core');
    $CFG->set_item('csrf_protection', FALSE);
}

Reference: http://codeigniter.com/forums/viewreply/869900/

Sign up to request clarification or add additional context in comments.

1 Comment

I hate to bump this but I just wanted to say that while this works, it isn't all that safe and people should be aware. For example, if your controller is api and function is dosomething you have "www.site.com/api/dosomething" disabled. But what's to stop someone going to "www.site.com/account/killkitten/api/dosomething"? CSRF disabled. Kitten killed. No?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.