Skip to content

No more support for custom anon/remember tokens based on FQCN #26981

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
May 27, 2018
Merged

No more support for custom anon/remember tokens based on FQCN #26981

merged 1 commit into from
May 27, 2018

Conversation

linaori
Copy link
Contributor

@linaori linaori commented Apr 19, 2018

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

This PR deprecates the ability to configure a custom anonymous and remember me token class, via the AuthenticationTrustResolver. The only change required if you have changed the token classes like this, is to extend the Anonymous/RememberMe token classes.

return $token instanceof $this->anonymousClass;
if (null !== $this->anonymousClass) {
if ($isAnonymous = ($token instanceof $this->anonymousClass)) {
@trigger_error(sprintf('Configuring a custom anonymous token class is deprecated as of 4.2 and will not be possible in 5.0. To fix this, please extend the %s instead.', AnonymousToken::class), E_USER_DEPRECATED);
Copy link
Member

Choose a reason for hiding this comment

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

...extend the %s instead -> ...extend the %s class instead ? (in other messages too)

return $token instanceof $this->anonymousClass;
if (null !== $this->anonymousClass) {
if ($isAnonymous = ($token instanceof $this->anonymousClass)) {
@trigger_error(sprintf('Configuring a custom anonymous token class is deprecated as of 4.2 and will not be possible in 5.0. To fix this, please extend the %s instead.', AnonymousToken::class), E_USER_DEPRECATED);
Copy link
Member

Choose a reason for hiding this comment

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

In the first occurrence of a Symfony version we add Symfony to not mistake this deprecation message with any other bundle. The format would be:

Configuring a custom anonymous token class is deprecated since Symfony 4.1 and will throw an exception in 5.0. To fix this, extend the %s class instead.

Also, the "...please..." is not necessary. We usually don't put "please" in this kind of messages.

return $token instanceof $this->anonymousClass;
if (null !== $this->anonymousClass) {
if (($isAnonymous = ($token instanceof $this->anonymousClass)) && !$token instanceof AnonymousToken) {
@trigger_error(sprintf('Configuring a custom anonymous token class is deprecated since Symfony 4.2 and will not be possible in 5.0. To fix this, have the %s class extend the %s class instead.', \get_class($token), AnonymousToken::class), E_USER_DEPRECATED);
Copy link
Contributor

Choose a reason for hiding this comment

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

how about making this check in the constructor with a is_a or somehting like that ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You mean checking the type of the string passed into the constructor? I think that's an option

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, maybe we should have 2 deprecations: trigger one when you pass a custom class in the constructor; and trigger another when you pass a token that doesn't extend AnonymousToken/RememberMeToken.
Early triggering of deprecations makes the upgrade path probably easier.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah @iltar I meant checking the type in the constructor. Two deprecations as suggested by @wouterj looks good too.

@linaori
Copy link
Contributor Author

linaori commented Apr 23, 2018

I've moved the deprecation to the constructor, I don't think it's needed runtime as it's the same check.

@nicolas-grekas
Copy link
Member

rebase needed

@linaori
Copy link
Contributor Author

linaori commented May 22, 2018

done

UPGRADE-4.2.md Outdated
@@ -5,3 +5,15 @@ Security
--------

* Using the `has_role()` function in security expressions is deprecated, use the `is_granted()` function instead.
* Passing custom class names for to the
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 for should be removed here.

UPGRADE-4.2.md Outdated
@@ -5,3 +5,15 @@ Security
--------

* Using the `has_role()` function in security expressions is deprecated, use the `is_granted()` function instead.
* Passing custom class names for to the
`Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolver` to define
custom anonymouse and remember me token classes, is deprecated as of 4.2 and will be
Copy link
Member

Choose a reason for hiding this comment

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

typo anonymous

UPGRADE-4.2.md Outdated
* Passing custom class names for to the
`Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolver` to define
custom anonymouse and remember me token classes, is deprecated as of 4.2 and will be
removed in 5.0. To use custom tokens extend the existing AnonymousToken and RememberMeToken.
Copy link
Member

Choose a reason for hiding this comment

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

The "and will be removed in 5.0" should be removed (same in the other paragraph). We decided to remove them all in deprecation as this should be "obvious".

UPGRADE-4.2.md Outdated
* Passing custom class names for to the
`Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolver` to define
custom anonymouse and remember me token classes, is deprecated as of 4.2 and will be
removed in 5.0. To use custom tokens extend the existing AnonymousToken and RememberMeToken.
Copy link
Member

Choose a reason for hiding this comment

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

Can you use the FQCN here instead?


* Using the `security.authentication.trust_resolver.anonymous_class` and
`security.authentication.trust_resolver.rememberme_class` parameters to define
the token classes, is deprecated as of 4.2 and will be removed in 5.0. To use
Copy link
Member

Choose a reason for hiding this comment

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

and will be removed in 5.0 to be removed: )

* Using the `security.authentication.trust_resolver.anonymous_class` and
`security.authentication.trust_resolver.rememberme_class` parameters to define
the token classes, is deprecated as of 4.2 and will be removed in 5.0. To use
custom tokens extend the existing AnonymousToken and RememberMeToken.
Copy link
Member

Choose a reason for hiding this comment

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

FQCN?

* Passing custom class names for to the
`Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolver` to define
custom anonymouse and remember me token classes, is deprecated as of 4.2 and will be
removed in 5.0. To use custom tokens extend the existing AnonymousToken
Copy link
Member

Choose a reason for hiding this comment

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

missing comma after tokens and missing end dot.

{
$this->anonymousClass = $anonymousClass;
$this->rememberMeClass = $rememberMeClass;

if (null !== $anonymousClass && !is_a($anonymousClass, AnonymousToken::class, true)) {
@trigger_error(sprintf('Configuring a custom anonymous token class is deprecated since Symfony 4.2 and will not be possible in 5.0. To fix this, have the %s class extend the %s class instead, and remove the %s constructor argument.', $anonymousClass, AnonymousToken::class, self::class), E_USER_DEPRECATED);
Copy link
Member

Choose a reason for hiding this comment

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

Same here, the "will be removed" part must be, well, removed.

Copy link
Member

@fabpot fabpot left a comment

Choose a reason for hiding this comment

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

Sorry, I missed some more changes during my first review. Hopefully, that's the last round of CS tweaks.

UPGRADE-4.2.md Outdated
@@ -5,3 +5,16 @@ Security
--------

* Using the `has_role()` function in security expressions is deprecated, use the `is_granted()` function instead.
* Passing custom class names to the
`Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolver` to define
custom anonymous and remember me token classes, is deprecated as of 4.2. To
Copy link
Member

Choose a reason for hiding this comment

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

sorry, forget one thing: we don't need the "as of 4.2" here as the file is specifically for 4.2.

UPGRADE-4.2.md Outdated
`Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolver` to define
custom anonymous and remember me token classes, is deprecated as of 4.2. To
use custom tokens, extend the existing `Symfony\Component\Security\Core\Authentication\Token\AnonymousToken`
and `Symfony\Component\Security\Core\Authentication\Token\RememberMeToken`.
Copy link
Member

Choose a reason for hiding this comment

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

and/or?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

as in "and/or", or replace the and by or?

UPGRADE-4.2.md Outdated

* Using the `security.authentication.trust_resolver.anonymous_class` and
`security.authentication.trust_resolver.rememberme_class` parameters to define
the token classes, is deprecated as of 4.2. To use
Copy link
Member

Choose a reason for hiding this comment

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

same here


* Using the `security.authentication.trust_resolver.anonymous_class` and
`security.authentication.trust_resolver.rememberme_class` parameters to define
the token classes, is deprecated as of 4.2. To use
Copy link
Member

Choose a reason for hiding this comment

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

same

@@ -6,6 +6,11 @@ CHANGELOG

* added the `is_granted()` function in security expressions
* deprecated the `has_role()` function in security expressions, use `is_granted()` instead
* Passing custom class names to the
`Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolver` to define
custom anonymous and remember me token classes, is deprecated as of 4.2. To
Copy link
Member

Choose a reason for hiding this comment

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

same here as the section if for 4.2 anyway.

{
$this->anonymousClass = $anonymousClass;
$this->rememberMeClass = $rememberMeClass;

if (null !== $anonymousClass && !is_a($anonymousClass, AnonymousToken::class, true)) {
@trigger_error(sprintf('Configuring a custom anonymous token class is deprecated since Symfony 4.2. To fix this, have the %s class extend the %s class instead, and remove the %s constructor argument.', $anonymousClass, AnonymousToken::class, self::class), E_USER_DEPRECATED);
Copy link
Member

Choose a reason for hiding this comment

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

We try to have only one sentence for deprecations: Configuring a custom anonymous token class is deprecated since Symfony 4.2; have the "%s" class extend the "%s" class instead, and remove the "%s" constructor argument. (note the quotes around class names and parameters).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That makes sense, I'll update it 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Noticed that the first argument of the sprintf was the wrong one of for the remember me as well, it received the $anonymousClass instead (fixed)

@fabpot
Copy link
Member

fabpot commented May 27, 2018

Thank you @iltar.

@fabpot fabpot merged commit 860d454 into symfony:master May 27, 2018
fabpot added a commit that referenced this pull request May 27, 2018
…on FQCN (Iltar van der Berg)

This PR was squashed before being merged into the 4.2-dev branch (closes #26981).

Discussion
----------

No more support for custom anon/remember tokens based on FQCN

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

This PR deprecates the ability to configure a custom anonymous and remember me token class, via the AuthenticationTrustResolver. The only change required _if_ you have changed the token classes like this, is to extend the Anonymous/RememberMe token classes.

Commits
-------

860d454 No more support for custom anon/remember tokens based on FQCN
@nicolas-grekas nicolas-grekas modified the milestones: next, 4.2 Nov 1, 2018
This was referenced Nov 3, 2018
@linaori linaori deleted the feature/trust-resolver-tokens branch February 8, 2019 13:37
symfony-splitter pushed a commit to symfony/security-core that referenced this pull request Jun 25, 2019
This PR was squashed before being merged into the 5.0-dev branch (closes #32160).

Discussion
----------

Removed legacy code and cleanup

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

See symfony/symfony#32074, symfony/symfony#26981

labels: `HttpFoundation`, `Form`, `Security`, `SecurityBundle`, `Validator`

Commits
-------

7b99fb45bb Removed legacy code and cleanup
fabpot added a commit that referenced this pull request Jun 25, 2019
This PR was squashed before being merged into the 5.0-dev branch (closes #32160).

Discussion
----------

Removed legacy code and cleanup

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

See #32074, #26981

labels: `HttpFoundation`, `Form`, `Security`, `SecurityBundle`, `Validator`

Commits
-------

7b99fb4 Removed legacy code and cleanup
javiereguiluz added a commit to symfony/symfony-docs that referenced this pull request Nov 30, 2019
…esolver (jzawadzki)

This PR was submitted for the 5.0 branch but it was merged into the 4.3 branch instead (closes #12721).

Discussion
----------

Removed constructor parameters from AuthenticationTrustResolver

As per symfony/symfony#26981 there are no constructor arguments in `AuthenticationTrustResolver`.

Commits
-------

f046117 Removed constructor parameters from AuthenticationTrustResolver
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