Skip to content

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

Open
riasvdv wants to merge 1 commit into6.xfrom
feature/retire-csrf-config
Open

[6.x] Retire CSRF configuration to legacy GeneralConfig#18806
riasvdv wants to merge 1 commit 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)

@semanticdiff-com
Copy link
Copy Markdown

Review changes with  SemanticDiff

@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
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.

1 participant