Skip to content

change: use skip_forgery_protection instead of manually set skip_before_action#1212

Merged
excid3 merged 2 commits intopay-rails:mainfrom
luizkowalski:forgery-protection-fix
Dec 23, 2025
Merged

change: use skip_forgery_protection instead of manually set skip_before_action#1212
excid3 merged 2 commits intopay-rails:mainfrom
luizkowalski:forgery-protection-fix

Conversation

@luizkowalski
Copy link
Contributor

@luizkowalski luizkowalski commented Dec 13, 2025

Pull Request

Summary:

in Rails edge, the CSRF verification has changed from authenticity token to header-based (Sec-Fetch-Site).

This breaks skip_before_action as verify_authenticity_token was removed (here and here)

A simple fix is to use the helper skip_forgery_protection as it is a wrapper for skip_before_action :verify_authenticity_token already and it works for both versions of the code

Related Issue:

Description:

Testing:

  • Tests should still pass

Screenshots (if applicable):

Checklist:

  • Code follows the project's coding standards
  • Tests have been added or updated to cover the changes
  • Documentation has been updated (if applicable)
  • All existing tests pass
  • Conforms to the contributing guidelines

@luizkowalski luizkowalski force-pushed the forgery-protection-fix branch from 808c165 to fb805b3 Compare December 13, 2025 10:50
@luizkowalski luizkowalski marked this pull request as ready for review December 13, 2025 10:52
@excid3 excid3 merged commit 198fe13 into pay-rails:main Dec 23, 2025
46 checks passed
@excid3
Copy link
Collaborator

excid3 commented Dec 23, 2025

I just realized, we should probably just inherit from ActionController::API for webhooks controllers since they do not include forgery protection and other unnecessary features.

I will refactor this in another PR.

@luizkowalski
Copy link
Contributor Author

What's interesting now is that I'm getting NameError: undefined local variable or method 'skip_forgery_protection' for class Pay::Webhooks::StripeController when running tests on my app (which was previously using my fork).

it's weird because the method is present in the stable and edge API.

I'm trying to understad what's going on

@luizkowalski
Copy link
Contributor Author

ah, just realized you already changed the inheritance in the new version, sorry! I think skip_forgery_protection should be deleted from these controllers

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