Skip to content

[6.x] Retire CSRF configuration to legacy GeneralConfig#18806

Merged
brandonkelly merged 4 commits into6.xfrom
feature/retire-csrf-config
May 8, 2026
Merged

[6.x] Retire CSRF configuration to legacy GeneralConfig#18806
brandonkelly merged 4 commits into6.xfrom
feature/retire-csrf-config

Conversation

@riasvdv
Copy link
Copy Markdown
Contributor

@riasvdv riasvdv commented May 7, 2026

Description

In Laravel, PreventRequestForgery (used to be CSRF) is always enabled, the token name is always _token and csrf_token() returns a string whenever the session is set.

This is no longer a concern of Craft and we should let the framework deal with it.

Users and plugins can use PreventRequestForgery::except() in their service providers to exclude urls from the protection.

The middleware is only present in the web middleware stack. Registering routes with api is what's advised for things like webhooks or API routes that don't require CSRF protection. (@AugustMiller might be worth putting in documentation somewhere)

@riasvdv riasvdv force-pushed the feature/retire-csrf-config branch from fd4ee1c to ce2fdb2 Compare May 7, 2026 10:50
@riasvdv riasvdv requested a review from brandonkelly May 7, 2026 10:59
@riasvdv riasvdv marked this pull request as ready for review May 7, 2026 10:59
@craftcms craftcms deleted a comment from semanticdiff-com Bot May 8, 2026
@brandonkelly brandonkelly merged commit f72c230 into 6.x May 8, 2026
@brandonkelly brandonkelly deleted the feature/retire-csrf-config branch May 8, 2026 18:27
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