EllisLab text mark
Advanced Search
1 of 2
1
   
CI 2: “The action you have requested is not allowed.”
Posted: 11 August 2010 04:00 PM   [ Ignore ]
Avatar
Joined: 2008-07-31
260 posts

Hey there

I am working into CI 2.0 beta. I have a simple form, which results in following error after sending:

An Error Was Encountered
The action you have requested is not allowed.

This error seems to be generated by Security.php. First I thought it has something to do with the CSRF-token which is generated by form_open(), so I wrote the html manually without token, but same result. What could trigger this behaviour?

Thx for any tipps
sl3dg3

 Signature 

RostElyn - Russian Language in Switzerland
TableEditor: No more tirying CRUD-code

 
Posted: 11 August 2010 05:02 PM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2008-07-31
260 posts

When I set

$config['csrf_protection'FALSE

it works - so yeah, it definitely has something to do with the csrf-token… :/

 Signature 

RostElyn - Russian Language in Switzerland
TableEditor: No more tirying CRUD-code

 
Posted: 11 August 2010 09:13 PM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Joined: 2009-03-30
1303 posts

You are correct. The have finally finished this up in the latest update. When set to true, form_open() will add the hidden token value to the form. If you are creating the <form > tag manually, and have csrf set to TRUE, you will need to add this value in.

This gets a little tricky with some web services like Paypal/JSON/AJAX. If you try using IPN which POSTs data back, you will have problems. I found it best to create a whitelist of IP addresses to turn off the protection. Or use

$this->config->set_item('csrf_protection'TRUE); 
 
Posted: 13 August 2010 06:32 AM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Avatar
Joined: 2008-07-31
260 posts

Hmmmm. Not sure if I have the latest version (can’t find the download-link anymore), most probably not - as a matter of fact, it doesn’t work with form_open() and config set to true.

 Signature 

RostElyn - Russian Language in Switzerland
TableEditor: No more tirying CRUD-code

 
Posted: 13 August 2010 09:58 AM   [ Ignore ]   [ # 4 ]   [ Rating: 0 ]
Joined: 2009-03-30
1303 posts

CI2 Download Link

 
Posted: 11 November 2010 05:58 PM   [ Ignore ]   [ # 5 ]   [ Rating: 0 ]
Joined: 2010-08-27
13 posts
pickupman - 12 August 2010 01:13 AM

This gets a little tricky with some web services like Paypal/JSON/AJAX. If you try using IPN which POSTs data back, you will have problems. I found it best to create a whitelist of IP addresses to turn off the protection.

Sorry to resurrect this, but I am having issues with Paypal IPNs using CI2 and wondered if this could relate. Where would you recommend implementing this whitelist? If I use the above code to disable the protection, is it ok to do it temporarily in my Paypal IPN handler, perform my operations, then re-enable the protection at the end without any issues?

Thanks!

 
Posted: 11 November 2010 10:57 PM   [ Ignore ]   [ # 6 ]   [ Rating: 0 ]
Joined: 2009-03-30
1303 posts

I created a conditional statement in application/config/config.PHP and for turning csfr on and off based on IP address of the request.

 
Posted: 23 November 2010 10:47 PM   [ Ignore ]   [ # 7 ]   [ Rating: 0 ]
Joined: 2010-11-16
1 posts
pickupman - 12 August 2010 01:13 AM

... If you are creating the <form > tag manually, and have csrf set to TRUE, you will need to add this value in.

I stumbled on this via google when I had the same problem. I’m hard-coding my forms without the form helper, which means I miss out on including the token value. To do that, I included the following hidden input item:

<input type="hidden" name="<?php echo $this->security->csrf_token_name?>" value="<?php echo $this->security->csrf_hash?>" /> 

Hope that helps someone! (Or maybe someone could point out any errors with this method?)

 
Posted: 22 February 2011 08:43 AM   [ Ignore ]   [ # 8 ]   [ Rating: 0 ]
Joined: 2010-02-06
3 posts

exactly what i was looking for, thanks.

 
Posted: 01 March 2011 10:47 PM   [ Ignore ]   [ # 9 ]   [ Rating: 0 ]
Joined: 2009-12-11
8 posts

I have a similar problem.
I have a method on a controller, that will receive $_POST data from an external webservice.
How can I disable CSRF only for this method?

I also tried $this->config->set_item(‘csrf_protection’, FALSE); 
but it doesnt work.

Thank you very much

 Signature 

Ricardo Martins
site: http://ricardomartins.net.br/

 
Posted: 06 March 2011 07:46 AM   [ Ignore ]   [ # 10 ]   [ Rating: 0 ]
Joined: 2009-07-24
25 posts

Thank you so very very much! been wondering why my AJAX always returned an error :/

 
Posted: 11 March 2011 04:27 AM   [ Ignore ]   [ # 11 ]   [ Rating: 0 ]
Avatar
Joined: 2007-09-12
205 posts

I also tried adding the $this->config->set_item(‘csrf_protection’,FALSE) but it didn’t work. Where did you place that?

 Signature 

Voltamp Media
Web: PHP, MySQL, PERL, HTML, CSS, Python, Javascript
Linux: FreeBSD, OpenVPN, SMB, SVN, C, Shell

 
Posted: 11 March 2011 09:36 AM   [ Ignore ]   [ # 12 ]   [ Rating: 0 ]
Joined: 2009-12-11
8 posts

Take a look at http://ellislab.com/forums/viewthread/182631/

 Signature 

Ricardo Martins
site: http://ricardomartins.net.br/

 
Posted: 22 March 2011 01:13 AM   [ Ignore ]   [ # 13 ]   [ Rating: 0 ]
Avatar
Joined: 2007-09-12
205 posts

The pre-system hook will work for me. Is there a reason the CSRF wasn’t checked in the form_validation->run()? That seemed like a reasonable place for it, allowing for individual form control as well.

 Signature 

Voltamp Media
Web: PHP, MySQL, PERL, HTML, CSS, Python, Javascript
Linux: FreeBSD, OpenVPN, SMB, SVN, C, Shell

 
Posted: 28 May 2011 05:09 PM   [ Ignore ]   [ # 14 ]   [ Rating: 0 ]
Joined: 2011-05-28
2 posts

The following code worked for me:

<input type=“hidden” name=”<?php echo $this->security->get_csrf_token_name()?>” value=”<?php echo $this->security->get_csrf_hash()?>” >

Hope it helps someone!

 
Posted: 31 May 2011 03:28 PM   [ Ignore ]   [ # 15 ]   [ Rating: 0 ]
Joined: 2009-02-07
10 posts
roark - 28 May 2011 09:09 PM

The following code worked for me:

<input type=“hidden” name=”<?php echo $this->security->get_csrf_token_name()?>” value=”<?php echo $this->security->get_csrf_hash()?>” >

Hope it helps someone!

thank you it helps

but you might better

form_hidden($this->security->get_csrf_token_name(), $this->security->get_csrf_hash()); 
 
1 of 2
1