Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bypass csrf validation #232

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

bvdputte
Copy link

Please first update mzur/kirby-form dependency with mzur/kirby-form#16

Afterwards, with this PR we should be able to bypass CSRF for headless form validation.

Also see: https://forum.getkirby.com/t/uniform-deactivate-csrf-check-for-headless-usecases/20643

Thanks! 🙌

Copy link
Owner

@mzur mzur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I made suggestions for alternative method/variable names. Also, please add a test case for this. You could take the code of testValidateCsrfException(), remove the expectException() and add the new disableCsrfProtection().

@@ -192,3 +192,21 @@ if (kirby()->request()->is('POST')) {
}
}
```

## withoutCSRF()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to call this disableCsrfProtection() to make sure that you are disabling an important protection mechanism.

*
* @var boolean
*/
protected $shouldValidateCSRF;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename to $shouldValidateCsrfToken.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants