Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Security] The AuthenticationException should implements Security's ExceptionInterface #25772

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

Conversation

sroze
Copy link
Contributor

@sroze sroze commented Jan 11, 2018

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

Dunno why this is the case right now but this probably should not. Was reported by @paq85.

@@ -19,7 +19,7 @@
* @author Fabien Potencier <[email protected]>
* @author Alexander <[email protected]>
*/
class AuthenticationException extends \RuntimeException implements \Serializable
class AuthenticationException extends \RuntimeException implements \Serializable, ExceptionInterface
Copy link

Choose a reason for hiding this comment

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

This is OK but it's a fix for only one of the sub-exceptions ;)

IMHO it would be better to make all exceptions in \Symfony\Component\Security\Core\Exception\ namespace that extend \RuntimeException extend \Symfony\Component\Security\Core\Exception\RuntimeException instead.

Copy link
Member

Choose a reason for hiding this comment

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

I agree

@xabbuh xabbuh added this to the 2.7 milestone Jan 11, 2018
@linaori
Copy link
Contributor

linaori commented Jan 12, 2018

In 3.4, none of the core features seem to catch this interface. However, I'm not sure about the behavior of custom listeners if people had this check already, it might alter behavior and break code.

Also, this seems to be a new feature 🤔

@Simperfit
Copy link
Contributor

This seems to be a new feature for me too. Like @iltar said it could break people's code.

@paq85
Copy link

paq85 commented Jan 12, 2018

I can imagine a code that would break after this change but this is very unlikely.
I can imagine people having

} catch (\Symfony\Component\Security\Core\Exception\ExceptionInterface $sex) {

expecting it to catch whatever Security component throws and it's not gonna happen because of this issue.
I was expecting such a behaviour because I was quite sure that's how all Symfony components are build.

IMHO BC break is not such a big case here because if anyone is catching a specific sub-exception like \Symfony\Component\Security\Core\Exception\BadCredentialsException it will still get caught.
If anyone is catching the generic \RuntimeException it will still get caught as the \Symfony\Component\Security\Core\Exception\RuntimeException extends \RuntimeException

@linaori
Copy link
Contributor

linaori commented Jan 12, 2018

IMHO BC break is not such a big case

A BC break is still a BC break though.

@sroze sroze force-pushed the bug/authentication-exception-to-implements-its-interface branch from 2f81d28 to 275a293 Compare January 15, 2018 09:34
@sroze
Copy link
Contributor Author

sroze commented Jan 15, 2018

I agree this could be a BC for people misusing the exceptions. However, this is a bug to me as the exceptions are not implementing the intended interface.

@paq85 @chalasr I've updated to PR, so all exceptions are updated.

Status: needs review

@linaori
Copy link
Contributor

linaori commented Jan 15, 2018

I agree this could be a BC for people misusing the exceptions. However, this is a bug to me as the exceptions are not implementing the intended interface.

It doesn't have to be misusing, can be perfectly normal usage.

@chalasr
Copy link
Member

chalasr commented Jan 20, 2018

I can't say if not making these classes implement the interface was done on purpose or not, but I share @iltar concerns, this is a BC break, especially important because it is about security exceptions. Exception handling is often little tested, this could break final applications as well as librairies.
I tend to be -1, letting things as they are. Not for 2.7 anyways. Let's see what others think

@nicolas-grekas
Copy link
Member

AFAIK, we make such changes on master only.

@sroze
Copy link
Contributor Author

sroze commented Feb 3, 2018

That's probably a good tradeoff. It will not break some applications that are potentially misusing the exceptions but will correct the expected behaviour 👍

@sroze sroze force-pushed the bug/authentication-exception-to-implements-its-interface branch from 275a293 to 64518fb Compare February 3, 2018 11:02
@sroze sroze changed the base branch from 2.7 to master February 3, 2018 11:03
@sroze sroze force-pushed the bug/authentication-exception-to-implements-its-interface branch from 64518fb to 0ee4cf1 Compare February 3, 2018 11:03
@sroze
Copy link
Contributor Author

sroze commented Feb 3, 2018

Rebased on master and PR's base changed.

@chalasr chalasr modified the milestones: 2.7, 4.1 Feb 4, 2018
@fabpot
Copy link
Member

fabpot commented Feb 7, 2018

Thank you @sroze.

@fabpot fabpot merged commit 0ee4cf1 into symfony:master Feb 7, 2018
fabpot added a commit that referenced this pull request Feb 7, 2018
…ts Security's ExceptionInterface (sroze)

This PR was merged into the 4.1-dev branch.

Discussion
----------

[Security] The AuthenticationException should implements Security's ExceptionInterface

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

Dunno why this is the case right now but this probably should not. Was reported by @paq85.

Commits
-------

0ee4cf1 The Security Component's exceptions should implements Security's ExceptionInterface
@fabpot fabpot mentioned this pull request May 7, 2018
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.

9 participants