8000 [Cookbook][Security] don't output message from AuthenticationException by xabbuh · Pull Request #4761 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content

[Cookbook][Security] don't output message from AuthenticationException #4761

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
Jan 16, 2015

Conversation

xabbuh
Copy link
Member
@xabbuh xabbuh commented Jan 4, 2015
Q A
Doc fix? yes
New docs? no
Applies to all
Fixed tickets

Displaying the message of an AuthenticationException might expose
sensitive data to the user.

@xabbuh
Copy link
Member Author
xabbuh commented Jan 4, 2015

@stof I assumed you meant the getMessageData() method here. getMessageParameters() does not exist.

@xabbuh
Copy link
Member Author
xabbuh commented Jan 11, 2015

ping @weaverryan @wouterj I think this is something we should merge as soon as possible to avoid giving insecure advices.

@weaverryan
Copy link
Member

Thanks @xabbuh. I'm actually not familiar with this - I knew this approach could leak info, but had the approach you suggested always worked, or is it new? Where did the idea come from? Forgive my lack of knowledge here :)

@xabbuh
Copy link
Member Author
xabbuh commented Jan 12, 2015

@stof made the suggestion in #4723 (comment). These methods are present in Symfony 2.3 too: http://api.symfony.com/2.3/Symfony/Component/Security/Core/Exception/AuthenticationException.html

@stof
Copy link
Member
stof commented Jan 12, 2015

@weaverryan this is a feature added in Symfony 2.2

@stof
Copy link
Member
stof commented Jan 12, 2015

@xabbuh indeed, I made a mistake when giving the method name (I haven't checked the code or the api doc when commenting)

@xabbuh
Copy link
Member Author
xabbuh commented Jan 12, 2015

@stof No problem, was not hard to guess the right method name. ;)

// ADD THIS use STATEMENT above your class
use Symfony\Component\Security\Core\SecurityContextInterface;

public function loginAction(Request $request)
{
$session = $request->getSession();
$error = null;
Copy link
Member

Choose a reason for hiding this comment

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

I think having this in the else is more clear

Copy link
Member Author

Choose a reason for hiding this comment

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

Good suggestion, this might not be the way it would usually be done in the Symfony core, but it's actually more readable. Changed it.

Displaying the message of an `AuthenticationException` might expose
sensitive data to the user.
@xabbuh xabbuh force-pushed the replace-get-message branch from b4d986b to 44277c7 Compare January 16, 2015 16:14
@weaverryan
Copy link
Member

Thanks guys! I can't believe I had missed this. I used it recently in Silex in a KnpU tutorial, without even realizing how it fits into Symfony. I'm very happy to have this improved!

@weaverryan weaverryan merged commit 44277c7 into symfony:2.3 Jan 16, 2015
weaverryan added a commit that referenced this pull request Jan 16, 2015
…cationException (xabbuh)

This PR was merged into the 2.3 branch.

Discussion
----------

[Cookbook][Security] don't output message from AuthenticationException

| Q             | A
| ------------- | ---
| Doc fix?      | yes
| New docs?     | no
| Applies to    | all
| Fixed tickets |

Displaying the message of an `AuthenticationException` might expose
sensitive data to the user.

Commits
-------

44277c7 don't output message from AuthenticationException
@xabbuh xabbuh deleted the replace-get-message branch January 16, 2015 21:38
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.

4 participants
0