8000 [Security] Fix fatal error on non string username by chalasr · Pull Request #25657 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Security] Fix fatal error on non string username #25657

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
Jan 16, 2018

Conversation

chalasr
Copy link
Member
@chalasr chalasr commented Jan 2, 2018
Q A
Branch? 2.7
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #25612
License MIT
Doc PR n/a

That's consistent with what #22569 did for the json_login listener.

@xabbuh
Copy link
Member
xabbuh commented Jan 2, 2018

I think we should do the same with the provided password.

$password = $requestBag->get($this->options['password_parameter'], null, true);

if (!is_string($username)) {
throw new BadRequestHttpException(sprintf('The key "%s" must be a string.', $this->options['username_parameter']));
Copy link
Member

Choose a reason for hiding this comment

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

This kind of messages in Symfony are usually like:

sprintf('The XXX must be a string, "%s" given.', gettype($XXX))

Is it necessary to do the same 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.

done

$password = $requestBag->get($this->options['password_parameter'], null, true);

if (!is_string($username)) {
throw new BadRequestHttpException(sprintf('The key "%s" must be a string.', $this->options['username_parameter']));
Copy link
Contributor

Choose a reason for hiding this comment

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

as javiere said I think we should change both message too.

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 :) needs work

@xabbuh
Copy link
Member
xabbuh commented Jan 11, 2018

@chalasr tests are failing

@chalasr
Copy link
Member Author
chalasr commented Jan 11, 2018

@xabbuh done. Objects implementing __toString() do work for both username and password before this PR, and the UsernamePasswordToken $credentials argument (password) allows for mixed, should we care?

@chalasr chalasr force-pushed the username-non-string branch from a3e17da to 15ecf24 Compare January 11, 2018 12:52
@xabbuh
Copy link
Member
xabbuh commented Jan 11, 2018

@chalasr I also wonder if not passing credentials at all must be supported here.

@chalasr chalasr force-pushed the username-non-string branch 5 times, most recently from e9e6818 to d7e615f Compare January 12, 2018 14:46
@acasademont
Copy link
Contributor

Thanks for the patch! I was going to submit the same issue ;)

@chalasr
Copy link
Member Author
chalasr commented Jan 12, 2018

@xabbuh I think so, password part reverted and __toString handling added for username.

array('require_previous_session' => false)
);

$event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock();
Copy link
Member

Choose a reason for hiding this comment

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

I would not mock the event

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

@chalasr chalasr force-pushed the username-non-string branch from d7e615f to 8f09568 Compare January 13, 2018 12:27
@chalasr
Copy link
Member Author
chalasr commented Jan 15, 2018

Ready

@fabpot
Copy link
Member
fabpot commented Jan 16, 2018

Thank you @chalasr.

@fabpot fabpot merged commit 8f09568 into symfony:2.7 Jan 16, 2018
fabpot added a commit that referenced this pull request Jan 16, 2018
This PR was merged into the 2.7 branch.

Discussion
----------

[Security] Fix fatal error on non string username

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #25612
| License       | MIT
| Doc PR        | n/a

That's consistent with what #22569 did for the `json_login` listener.

Commits
-------

8f09568 [Security] Fix fatal error on non string username
@chalasr chalasr deleted the username-non-string branch January 16, 2018 07:49
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.

8 participants
0