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

Skip to content

[Security] Deprecate onAuthenticationSuccess() #18135

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

Conversation

weaverryan
Copy link
Member

Q A
Branch master
Bug fix? yes
New feature? yes
BC breaks? no
Deprecations? yes
Tests pass? yes
Fixed tickets #18027
License MIT
Doc PR not yet - the existing feature is not currently documented

Because of the new TargetPathTrait, implementing onAuthenticationSuccess yourself is quite easy. I think we should just remove it. This also will fix #18027.

Thanks!

public function checkCredentials($credentials, UserInterface $user)
{
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Missing newline here.

Copy link
Member Author

Choose a reason for hiding this comment

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

got it now!

Copy link
Member

Choose a reason for hiding this comment

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

looks like there is now one additional newline

@@ -72,6 +77,8 @@ public function onAuthenticationFailure(Request $request, AuthenticationExceptio
*/
public function onAuthenticationSuccess(Request $request, TokenInterface $token, $providerKey)
{
@trigger_error(sprintf('The AbstractFormLoginAuthenticator::onAuthenticationSuccess() implementation was deprecated in Symfony 3.1 and will be removed in Symfony 4.0. You should implement this method yourself in %s and remove getDefaultSuccessRedirectUrl().', get_class($this)), E_USER_DEPRECATED);

// if the user hit a secure page and start() was called, this was
Copy link
Contributor

Choose a reason for hiding this comment

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

hit => hits

@weaverryan
Copy link
Member Author

Comments done! Thanks guys :)

@weaverryan weaverryan force-pushed the guard_form_deprecate_method branch from 6188f9e to 7cd1a13 Compare March 29, 2016 13:02
@weaverryan
Copy link
Member Author

Comments made - the failure seems unrelated

Status: Needs review

* @return string
*/
abstract protected function getDefaultSuccessRedirectUrl();
protected function getDefaultSuccessRedirectUrl()
Copy link
Member

Choose a reason for hiding this comment

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

As this one was abstract, it was always implemented, so this code is never going to be executed, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

It will get executed if the user doesn't implement onAuthenticationSuccess or getDefaultSuccessRedirectURL(). In that case, this would be called here: 87. Since onAuthenticationSuccess is still implemented for BC, new users might not initially implement either, since there no interface/abstract method forces them to. It catches that case.

Also, deprecations are hard :).

Copy link
Member

Choose a reason for hiding this comment

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

Not sure I understand. Currently, the getDefaultSuccessRedirectUrl() method is abstract which means that nobody can use the AbstractFormLoginAuthenticator class without implementing it. In the wild, there is no code without a concrete implementation of this method. So, making it concrete now won't change anything as your code will always be overridden by user code, right?

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 with @fabpot. I guess we should remove the method here. Then we can check below if the method exists, trigger a deprecation in that case and optionally call it (not sure right now if that is needed for backwards compatibility).

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, I've removed it :). The problem is purely for new users of this class: they technically won't be required at a PHP-level to implement getDefaultSuccessRedirectUrl or onAuthenticationSuccess. I was just trying to avoid an ugly "method not found" call. I've actually still handled this, with an if statement check.

@fabpot
Copy link
Member

fabpot commented Mar 31, 2016

Thank you @weaverryan.

@fabpot fabpot closed this in 93e09fe Mar 31, 2016
@billsworld
Copy link

@weaverryan I am confused, this PR seems to show that the Guard component is part of Symfony but I don't see it in any of the branches. The only way to get to it is through https://github.com/symfony/security-guard. Can this be used directly from a Symfony component or do I need to source it from security-guard repo?

Also, in order to get this change I would have to use "symfony/security-guard": "dev-master", when will this make it into the 3.0 branch?

@xabbuh
Copy link
Member

xabbuh commented Apr 1, 2016

Deprecations are only done in development versions. This means that this change will be first available in the release of Symfony 3.1.

The other part of your question I did not understand. You can use Guard as a stand-alone component, but it is also part of the symfony/symfony package since 2.8.

@weaverryan weaverryan deleted the guard_form_deprecate_method branch April 1, 2016 15:38
@fabpot fabpot mentioned this pull request May 13, 2016
@lyrixx
Copy link
Member

lyrixx commented Oct 5, 2017

Hello. It looks like you forgot to add a not in the UPGRADE-3.1.md file

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.

[Security] getDefaultSuccessRedirectUrl should have access to the token