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

[Security] Add support for dynamic CSRF id with Expression in #[IsCsrfTokenValid] #19870

Merged
merged 1 commit into from May 10, 2024

Conversation

alamirault
Copy link
Contributor

Fix #19753

@rcsofttech85
Copy link
Contributor

rcsofttech85 commented May 8, 2024

you may consider changing your code to this...

    #[IsCsrfTokenValid(new Expression('"delete-item-" ~ args["post"].id'), tokenKey: 'token')]
    public function delete(Post $post): Response
    {
        // ... do something, like deleting an object
    }

post argument is mandatory in this case

@alamirault
Copy link
Contributor Author

You're right, updated

security/csrf.rst Outdated Show resolved Hide resolved
@OskarStark
Copy link
Contributor

Thank you Antoine.

@OskarStark OskarStark merged commit f35eec7 into symfony:7.1 May 10, 2024
3 checks passed
@alamirault alamirault deleted the 19753/dynamic-csrf branch May 10, 2024 12:42
@yguedidi
Copy link
Contributor

Thank you @alamirault

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

Successfully merging this pull request may close these issues.

[Security] Add support for dynamic CSRF id with Expression in `#[IsCsrf…
6 participants