![]() |
So, when I hit "Create new item" in the tutorial, CI throws an exception error due to, I guess, missing/invalid CSRF information.
Just to get a grip of what was actually generated, I put this in create.php: Code: <h2><?= esc($title) ?></h2> Code: COOKIE [..] I cannot for the life of me figure out why it generates a "CodeIgniter\Security\Exceptions\SecurityException #403 (The action you requested is not allowed)". Within the <form></form> data on the page, there's a correct hidden input field like this: Code: <input type="hidden" name="ltest2_csrf_token_name" value="a9a4c863be8f4c0877ee68f440027a77"> The exception points to this block in Security.php: Code: 304 // Do the tokens match? What did I miss? Could this have something to do with URL validation, index.php handling, or something else? -joho
It seems your code is okay. So I don't know why you got the CSRF error.
Try this: https://github.com/kenjis/ci4-news
04-03-2023, 04:00 AM
(This post was last modified: 04-03-2023, 04:11 AM by joho. Edit Reason: Formatting )
I've checked "my" code against the code at the URL you prevented, and I can't see any differences.
Could this have something to do with these settings in .env? Do I need to modify them elsewhere to match this perhaps? Code: security.csrfProtection = 'cookie' Or, could it have something to do with me using https://my.host.name/sub-directory/ for the tutorial? OK. Found it. Duh! Apparently, PHP does not mind if you enter a pool configuration value as "MB" instead of "M", it just silently ignores it and sets it to zero. So I had post_max_size set to 10MB instead of 10M, so no post data was getting through at all. This became obvious when checking the PHP error log file. So, my bad, all is well for now :-) (04-01-2023, 04:46 AM)kenjis Wrote: It seems your code is okay. So I don't know why you got the CSRF error. @kenjis it looks like CI4.3+ has a CSRF problem as he has said this has happened for me also but only in CI 4.3.1+ For example, if one sends a form post and you try to repeat instead of firing the message = Code: The action you requested is not allowed it does Exceptions= PHP Code: ( "CodeIgniter\Security\Exceptions\SecurityException #403 (The action you requested is not allowed)".) Codeigniter First, Codeigniter Then You!!
yekrinaDigitals
(04-03-2023, 07:51 AM)luckmoshy Wrote: For example, if one sends a form post and you try to repeat instead of firing the message = But isn't this a setting in CI, that it should throw exceptions instead of printing/displaying errors? |
Welcome Guest, Not a member yet? Register Sign In |