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] added userChecker to SimpleAuthenticationProvider#26370

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

Closed
i3or1s wants to merge4 commits intosymfony:2.8fromi3or1s:26314

Conversation

@i3or1s
Copy link
Contributor

[Security] added userChecker to SimpleAuthenticationProvider
[SecurityBundle] [DependencyInjection] updated SimpleFormFactory

QA
Branch?2.8
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#26314
LicenseMIT
Doc PRno

Introduces user checker to the simple authentication provider.

private$userChecker;

publicfunction__construct(SimpleAuthenticatorInterface$simpleAuthenticator,UserProviderInterface$userProvider,$providerKey)
publicfunction__construct(SimpleAuthenticatorInterface$simpleAuthenticator,UserProviderInterface$userProvider,$providerKey,UserCheckerInterface$userChecker)
Copy link
Member

Choose a reason for hiding this comment

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

must be default null for BC

Copy link
ContributorAuthor

@i3or1si3or1sMar 2, 2018
edited
Loading

Choose a reason for hiding this comment

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

@chalasr Should it useSymfony\Component\Security\Core\User\UserChecker as default if null is present?
This would leave the method as is (without if statements)?

Added UserChecker to SimpleAuthenticationProvider and updated SimpleFormFactory
{
$user =$this->userProvider->loadUserByUsername($token->getUsername());
$this->userChecker->checkPreAuth($user);
$authToken =$this->simpleAuthenticator->authenticateToken($token,$this->userProvider,$this->providerKey);
Copy link
Contributor

Choose a reason for hiding this comment

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

While I understand the need to have the user here, it would be loaded twice now

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

@iltar maybe then skip the pre auth check since it can be done during authentication of the token.

Copy link
Contributor

Choose a reason for hiding this comment

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

What if you do$this->userChecker->checkPreAuth($authToken->getUser())? I know it's not exactly correct flow wise, but it beats fetching the user twice 🤔

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

@iltar I was thinking about it but it sounds strange to me to pre authenticate authenticated token.
Changin interface to exclude the userProvider would cause BC breaks.
You are correct about twice loading the user and simple authenticator could do the pre-check if needed.
Maybe best is to remove thecheckPreAuth

Copy link
Contributor

Choose a reason for hiding this comment

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

While it might seem strange, guard does it before/after the credentials check:

$this->userChecker->checkPreAuth($user);
if (true !==$guardAuthenticator->checkCredentials($token->getCredentials(),$user)) {
thrownewBadCredentialsException(sprintf('Authentication failed because %s::checkCredentials() did not return true.',get_class($guardAuthenticator)));
}
$this->userChecker->checkPostAuth($user);

I don't see another option to be honest, leaving it out would be as not having it at all.

retrieve user from authToken, rather then fetching it from userProvider
{
$authToken =$this->simpleAuthenticator->authenticateToken($token,$this->userProvider,$this->providerKey);
$this->userChecker->checkPreAuth($authToken->getUser());
$this->userChecker->checkPostAuth($authToken->getUser());
Copy link
Member

Choose a reason for hiding this comment

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

should be moved after the instanceof check below

apply userChecker after authToken is authenticated
}

thrownewAuthenticationException('Simple authenticator failed to return an authenticated token.');
$this->userChecker->checkPreAuth($authToken->getUser());
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to call$authToken->getUser() twice ?

@Simperfit
Copy link
Contributor

Can we add a test for this class ?

test for userChecker postAuth and preAuth
@chalasr
Copy link
Member

For 2.7

@chalasrchalasr modified the milestones:2.8,2.7Mar 6, 2018
@nicolas-grekas
Copy link
Member

Thank you@i3or1s.

nicolas-grekas added a commit that referenced this pull requestMar 19, 2018
…er (i3or1s)This PR was submitted for the 2.8 branch but it was squashed and merged into the 2.7 branch instead (closes#26370).Discussion----------[Security] added userChecker to SimpleAuthenticationProvider[Security] added userChecker to SimpleAuthenticationProvider[SecurityBundle] [DependencyInjection] updated SimpleFormFactory| Q             | A| ------------- | ---| Branch?       | 2.8| Bug fix?      | yes| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets |#26314| License       | MIT| Doc PR        | noIntroduces user checker to the simple authentication provider.Commits-------cb9c92d [Security] added userChecker to SimpleAuthenticationProvider
This was referencedApr 2, 2018
@fabpotfabpot mentioned this pull requestApr 3, 2018
@Arthur-min
Copy link

Hello,

I have an issue with this update:

Service "security.authentication.provider.simple_form.main": The index "3" is not in the range [0, 2].
in Definition.php (line 263)

Any idea how to fix that?

Thanks!

@nicolas-grekas
Copy link
Member

@Arthur-min see#26762 (please don't comment on closed issues/PRs)

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

Reviewers

@chalasrchalasrchalasr approved these changes

+2 more reviewers

@linaorilinaorilinaori left review comments

@SimperfitSimperfitSimperfit left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

2.7

Development

Successfully merging this pull request may close these issues.

7 participants

@i3or1s@Simperfit@chalasr@nicolas-grekas@Arthur-min@linaori@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp