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] Custom authentication error messages #5736

Closed
xabbuh opened this issue Sep 28, 2015 · 3 comments
Closed

[Security] Custom authentication error messages #5736

xabbuh opened this issue Sep 28, 2015 · 3 comments
Labels
hasPR A Pull Request has already been submitted for this issue. Security
Milestone

Comments

@xabbuh
Copy link
Member

xabbuh commented Sep 28, 2015

Starting with Symfony 2.8, we can easily throw an AuthenticationException in the Security subsystem with a custom error message thanks to the new CustomUserMessageAuthenticationException (see symfony/symfony#15882).

It must be made clear that the message configured here is likely to be shown to the user, so no sensitive information should be included in this message.

@xabbuh xabbuh added good first issue Ideal for your first contribution! (some Symfony experience may be required) actionable Clear and specific issues ready for anyone to take them. Security labels Sep 28, 2015
@xabbuh xabbuh added this to the 2.8 milestone Sep 28, 2015
@weaverryan
Copy link
Member

@xabbuh thanks for adding this issue :)

@diasgab
Copy link

diasgab commented Sep 29, 2015

Hi, i want to make my first contribution to symfony project so i'm looking for the easy pick issues. I wonder if this issue is related to "How to Build a Traditional Login Form" recipe from the security cookbook chapter:
screen shot 2015-09-29 at 10 37 54

Is it possible to show sensitive information just in dev environment and show a safe fixed message in prod?

@weaverryan
Copy link
Member

Hi @diasgab!

Actually, if you print the "messageKey" from the object - e.g.

{{ error.messageKey|trans(error.messageData, 'security') }}

Then it is always safe. It's only unsafe if you try to use other things, like maybe error.message - which could contain any information. But the messageKey is always safe.

@weaverryan weaverryan added hasPR A Pull Request has already been submitted for this issue. and removed actionable Clear and specific issues ready for anyone to take them. good first issue Ideal for your first contribution! (some Symfony experience may be required) labels Nov 27, 2015
weaverryan added a commit that referenced this issue Nov 30, 2015
…thenticationException (weaverryan)

This PR was merged into the 2.8 branch.

Discussion
----------

Updating some places to use the new CustomUserMessageAuthenticationException

| Q             | A
| ------------- | ---
| Doc fix?      | no
| New docs?     | yes
| Applies to    | 2.8+
| Fixed tickets | #5736

Commits
-------

3d67202 tweaks thanks to the guys
1eb5f23 Updating some places to use the new CustomUserMessageAuthenticationException
@xabbuh xabbuh closed this as completed Nov 30, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hasPR A Pull Request has already been submitted for this issue. Security
Projects
None yet
Development

No branches or pull requests

3 participants