Skip to content

[Security] [Translator] Add translation to 'Bad credentials' message #13437

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

Closed
wants to merge 1 commit into from
Closed

[Security] [Translator] Add translation to 'Bad credentials' message #13437

wants to merge 1 commit into from

Conversation

linniksa
Copy link
Contributor

Q A
Fixed tickets -
License MIT

For 2.6 source message should be updated (add dot to the end, see #11215)

linniksa referenced this pull request in FriendsOfSymfony/FOSUserBundle Jan 17, 2015
The authentication exception messages are not translated using the
translations shipped with Symfony itself.
@stof
Copy link
Member

stof commented Jan 18, 2015

This looks wrong to me. The message key of the BadCredentialsException is Invalid credentials. (which is already translated), not Bad credentials.

It looks to me that you are rendering the security exceptions using their unsafe message rather than their safe message key (the exception message itself can leak informations about your DB structure for instance, in case it comes from a PDO exception. It is not safe to display it for end users)

👎

@linniksa
Copy link
Contributor Author

We use https://github.com/FriendsOfSymfony/FOSUserBundle/blob/1.3.x/Controller/SecurityController.php#L38
Bad credentials has more sense for user than Invalid credentials, it mean in most cases "You sent wrong username or password" instead of "Something wrong"
But you are right, i missed the standard way to translate error messages of authentication.

@linniksa linniksa closed this Jan 18, 2015
@linniksa linniksa deleted the patch-translate-bad-credential-message branch January 18, 2015 15:42
@stof
Copy link
Member

stof commented Jan 18, 2015

@linniksa if you are using FOSUserBundle 1.3, you are not using the Symfony translation messages

@linniksa
Copy link
Contributor Author

@stof Why not? I can change the default template.

@stof
Copy link
Member

stof commented Jan 18, 2015

Well, FOSUserBundle 1.3 does not give you the Symfony translation key. This means that you are translating other stuff, expecting them to be provided by the Symfony translations

@linniksa
Copy link
Contributor Author

I know that the default translation domain is FosUserBundle https://github.com/FriendsOfSymfony/FOSUserBundle/blob/1.3.x/Resources/views/Security/login.html.twig#L5
Bad credentials a string in symfony code, and the meaning of my pull request is to put a translation in symfony.
You point me standart way of translate auth exceptions (as described in docs) and i agree that in this case, my PR has little meaning

@stof
Copy link
Member

stof commented Jan 18, 2015

@linniksa Symfony does not provide translation for exception messages. It provides only translations for strings it considers as translation keys. Exception messages are not because they are targetted at developers, not at being displayed in the interface for end users (they are not safe to be displayed there as they might leak internal implementation details)

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.

2 participants