Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Security] Deprecate AnonymousToken, non-UserInterface users, and token credentials#42423

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fabpot merged 1 commit intosymfony:5.4fromwouterj:pull-41613/token-user
Aug 13, 2021

Conversation

@wouterj
Copy link
Member

@wouterjwouterj commentedAug 8, 2021
edited
Loading

QA
Branch?5.4
Bug fix?no
New feature?no
Deprecations?yes
TicketsRef#41613,#34909
LicenseMIT
Doc PR-

This is a continuation of@xabbuh's experiment in#34909 and@chalasr's work in#42050. This hopefully is the last cleanup ofTokenInterface:

  • As tokens now always represent an authenticated user (and no longer e.g. the "username" input of the form), we can finally remove the weirdstring|\Stringable union fromToken::getUser() and other helper methods and require a user to be an instance ofUserInterface.
  • For the same reason, we can also deprecate token credentials. I didn't deprecateToken::eraseCredentials() as this is still used to remove credentials fromUserInterface.
  • Meanwhile, this also deprecated theAnonymousToken, which we forgot in 5.3. This token is not used anymore in the new system (anonymous does no longer exists). This was also the only token in core that didn't fulfill theUserInterface requirement for authenticated tokens.

@wouterjwouterj changed the title[Security] Deprecate AnonymousToken and non-UserInterface users[Security] [WIP] Deprecate AnonymousToken and non-UserInterface usersAug 8, 2021
@wouterjwouterj changed the title[Security] [WIP] Deprecate AnonymousToken and non-UserInterface users[Security] [WIP] Deprecate AnonymousToken, non-UserInterface users, and token credentialsAug 8, 2021
@wouterjwouterjforce-pushed thepull-41613/token-user branch frombe5dd61 tof1b28f4CompareAugust 8, 2021 15:30
@wouterjwouterj requested a review fromlyrixx as acode ownerAugust 8, 2021 15:30
@wouterjwouterj changed the title[Security] [WIP] Deprecate AnonymousToken, non-UserInterface users, and token credentials[Security] Deprecate AnonymousToken, non-UserInterface users, and token credentialsAug 8, 2021
@wouterjwouterjforce-pushed thepull-41613/token-user branch fromf1b28f4 to8cced53CompareAugust 8, 2021 15:37
@wouterj
Copy link
MemberAuthor

Psalm disliking the old signatures in the legacy integrations/tests is to be expected, this PR is ready imho

@wouterjwouterjforce-pushed thepull-41613/token-user branch from8cced53 tob451883CompareAugust 8, 2021 16:40
@wouterjwouterjforce-pushed thepull-41613/token-user branch fromb451883 to8554c93CompareAugust 8, 2021 17:51
Copy link
Member

@chalasrchalasr left a comment

Choose a reason for hiding this comment

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

Thanks! Just minor comments.
The CHANGELOG and UPGRADE files need to be updated also

Copy link
Member

@NyholmNyholm left a comment

Choose a reason for hiding this comment

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

Thank you.

I just have a few questions/comments.

Can you also confirm that all the psalm errors on unmodified files are false positives?

$originalToken =newUsernamePasswordToken(newInMemoryUser('original_user','password', ['ROLE_SUPER_ADMIN']),'provider', ['ROLE_SUPER_ADMIN']);
$switchUserToken =newSwitchUserToken(newInMemoryUser('user','passsword', ['ROLE_USER']),'provider', ['ROLE_USER'],$originalToken);
}else {
$originalToken =newUsernamePasswordToken(newUser('original_user','password', ['ROLE_SUPER_ADMIN']),null,'provider', ['ROLE_SUPER_ADMIN']);
Copy link
Member

Choose a reason for hiding this comment

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

Maybe make a comment here so it is more easily found when we remove code in Symfony 6.0.

(or you maybe have added this code to your list of future PRs)

$user =$token->getUser();

// in case it's not an object we cannot do anything with it; E.g. "anon."
// @deprecated since 5.4
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// @deprecated since 5.4
// @deprecated since 5.4, $user will always be an UserInterface in 6.0

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// @deprecated since 5.4
// @deprecated since 5.4 , $user will always be a UserInterface in 6.0

:)

Copy link
Member

Choose a reason for hiding this comment

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

Yes. You are correct.

@fabpotfabpotforce-pushed thepull-41613/token-user branch fromba70257 to44b843aCompareAugust 13, 2021 16:23
@fabpot
Copy link
Member

Thank you@wouterj.

@fabpotfabpot merged commit76a7fe7 intosymfony:5.4Aug 13, 2021
@wouterjwouterj deleted the pull-41613/token-user branchAugust 13, 2021 18:37
fabpot added a commit that referenced this pull requestAug 14, 2021
This PR was merged into the 5.4 branch.Discussion----------[Security] Deprecate remaining anonymous checks| Q             | A| ------------- | ---| Branch?       | 5.4| Bug fix?      | no| New feature?  | yes| Deprecations? | yes| Tickets       | Ref#41613| License       | MIT| Doc PR        | tbdDeprecates the remaining checks for anonymous found in#41613.  It's WIP because the tests are failing until#42423 is merged and this PR is rebased (didn't update one test to avoid merge conflicts).Besides this, it also introduced `IS_AUTHENTICATED` and `AuthenticationTrustResolver::isAutenticated()`. Previously, `IS_AUTHENTICATED_ANONYMOUSLY` was considered to be the "bottom type" for authenticated requests. As this is no longer true, `IS_AUTHENTICATED_REMEMBERME` is now the new "bottom type". I suggest we use an explicit bottom type (the ones introduced) instead to avoid another such update if we change something with remember me. It's also more clear on the exact intent of the check.Commits-------e3aca7f [Security] Deprecate remaining anonymous checks
This was referencedNov 5, 2021
* @param string[] $roles
*/
publicfunction__construct($user,$credentials,string$firewallName,array$roles = [])
publicfunction__construct($user,/*string*/$firewallName,/*array*/$roles = [])

Choose a reason for hiding this comment

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

Hi guys, I'm not sure how to useUsernamePasswordToken without$credentials as this change is not explained in documentation:https://symfony.com/doc/current/components/security/authentication.html

janbarasek reacted with thumbs up emoji
Copy link
MemberAuthor

@wouterjwouterjDec 10, 2021
edited
Loading

Choose a reason for hiding this comment

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

You probably get faster answers if you use one of the support channels:https://symfony.com/support (e.g. GitHub discussions) Not a lot of people are watching already merged PRs.

The security component is refactored during Symfony 5. Tokens now only represent authenticated tokens/sessions, so they no longer have credentials. The "pre authentication tokens" are now called passports.

We haven't updated the components docs yet, but the framework docs are upgraded to the new system. Hopefully, you'll be able to figure stuff out using e.g.https://symfony.com/doc/current/security/custom_authenticator.html

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@NyholmNyholmNyholm left review comments

@derrabusderrabusderrabus left review comments

@chalasrchalasrchalasr approved these changes

@fabpotfabpotfabpot approved these changes

@lyrixxlyrixxAwaiting requested review from lyrixxlyrixx is a code owner

+1 more reviewer

@petrofcikmatuspetrofcikmatuspetrofcikmatus left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

5.4

Development

Successfully merging this pull request may close these issues.

7 participants

@wouterj@fabpot@Nyholm@derrabus@chalasr@petrofcikmatus@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp