Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[DX] [FrameworkBundle] Added Crontoller::isCsrfTokenValid #11602

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

Merged
merged 1 commit into from
Aug 13, 2014

Conversation

lyrixx
Copy link
Member

@lyrixx lyrixx commented Aug 7, 2014

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets
License MIT
Doc PR

@lyrixx lyrixx changed the title [FrameworkBundle] Added Crontoller::isCsrfTokenValid [DX] [FrameworkBundle] Added Crontoller::isCsrfTokenValid Aug 7, 2014
@inelgnu
Copy link
Contributor

inelgnu commented Aug 7, 2014

👍

use Symfony\Component\Form\Form;
use Symfony\Component\Form\FormBuilder;
use Symfony\Component\Form\FormTypeInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
Copy link
Member

Choose a reason for hiding this comment

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

Please don't reorder use statements. It makes merging maintenance branches harder

@saro0h
Copy link
Contributor

saro0h commented Aug 7, 2014

👍

public function isCsrfTokenValid($id, $token)
{
if (!$this->container->has('security.csrf.token_manager')) {
throw new \LogicException('The SecurityBundle is not registered in your application.');
Copy link
Member

Choose a reason for hiding this comment

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

The CSRF protection is not configured by SecurityBundle but by FrameworkBundle. A better error message would be CSRF protection is not enabled in your application

@juliendidier
Copy link
Contributor

👍

@@ -168,6 +169,23 @@ public function createAccessDeniedException($message = 'Access Denied', \Excepti
}

/**
* Checks the validity of a CsrfToken
Copy link
Member

Choose a reason for hiding this comment

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

I would say of a CSRF token. the way you wrote it looks like it is a class name, and the method does not accept a CsrfToken instance as argument

@stof stof added the DX label Aug 7, 2014
@lyrixx
Copy link
Member Author

lyrixx commented Aug 7, 2014

@stof fixed. (thanks)

@stof
Copy link
Member

stof commented Aug 7, 2014

👍

2 similar comments
@sstok
Copy link
Contributor

sstok commented Aug 7, 2014

👍

@nicolas-grekas
Copy link
Member

👍

*
* @return boolean
*/
public function isCsrfTokenValid($id, $token)
Copy link
Member

Choose a reason for hiding this comment

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

This method should be protected, right?

Copy link
Member

Choose a reason for hiding this comment

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

yes (even if all existing helpers are protected for a weird reason)

Copy link
Member Author

Choose a reason for hiding this comment

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

@stof you mean public right?

@fabpot Fixed

@romainneutron
Copy link
Contributor

👍

* @param string $id The id used when generating the token
* @param string $token The actual token sent with the request that should be validated
*
* @return boolean
Copy link
Member

Choose a reason for hiding this comment

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

should be bool

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed.

@stof
Copy link
Member

stof commented Aug 13, 2014

👍

@stof
Copy link
Member

stof commented Aug 13, 2014

Can you add it in the CHANGELOG file of FrameworkBundle ?

@lyrixx
Copy link
Member Author

lyrixx commented Aug 13, 2014

@stof I wanted to do that, But I see this file is never update for a new method: https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

So Should I update the file, or it's OK?

@stof
Copy link
Member

stof commented Aug 13, 2014

@lyrixx IMO, the fact that we add a new helper method should be part of the changelog (improving DX without telling it to our users is bad from a DX point of view)

@lyrixx
Copy link
Member Author

lyrixx commented Aug 13, 2014

@stof ok. I just pushed a new commit.

@nicolas-grekas
Copy link
Member

Thank you @lyrixx.

@nicolas-grekas nicolas-grekas merged commit 479c833 into symfony:master Aug 13, 2014
nicolas-grekas added a commit that referenced this pull request Aug 13, 2014
…lid (lyrixx)

This PR was merged into the 2.6-dev branch.

Discussion
----------

[DX] [FrameworkBundle] Added Crontoller::isCsrfTokenValid

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

Commits
-------

479c833 [FrameworkBundle] Added Crontoller::isCsrfTokenValid
@lyrixx lyrixx deleted the csrf-made-easy branch August 13, 2014 21:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DX DX = Developer eXperience (anything that improves the experience of using Symfony)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Morty Proxy This is a proxified and sanitized view of the page, visit original site.