Skip to content

[Security] Fix the retrieval of the last username when using forwarding #19334

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
Jul 13, 2016

Conversation

stof
Copy link
Member

@stof stof commented Jul 11, 2016

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

When using forwarding to render the login page (which is not the default), the info are stored in the subrequest attributes rather than the session. getLastAuthenticationError was handling this properly but getLastUsername was not checking the attributes.
This fixes it by checking the attributes (I'm checking them before the session, to be consistent with getLastAuthenticationError)

@stof stof changed the title Fix the retrieval of the last username when using forwarding [Security] Fix the retrieval of the last username when using forwarding Jul 11, 2016
return $request->attributes->get(Security::LAST_USERNAME);
}

$session = $request->getSession();

return null === $session ? '' : $session->get(Security::LAST_USERNAME);
Copy link
Contributor

Choose a reason for hiding this comment

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

Here, If session does not store Security::LAST_USERNAME then?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't understand what you mean

Copy link
Contributor

Choose a reason for hiding this comment

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

If $session have not contain "Security::LAST_USERNAME" in this case it should be null.

Copy link
Contributor

Choose a reason for hiding this comment

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

$session->get() already return null if the key is not set.

@fabpot
Copy link
Member

fabpot commented Jul 13, 2016

Thank you @stof.

@fabpot fabpot merged commit e041365 into symfony:2.7 Jul 13, 2016
fabpot added a commit that referenced this pull request Jul 13, 2016
…ng forwarding (stof)

This PR was merged into the 2.7 branch.

Discussion
----------

[Security] Fix the retrieval of the last username when using forwarding

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

When using forwarding to render the login page (which is not the default), the info are stored in the subrequest attributes rather than the session. ``getLastAuthenticationError`` was handling this properly but ``getLastUsername`` was not checking the attributes.
This fixes it by checking the attributes (I'm checking them before the session, to be consistent with ``getLastAuthenticationError``)

Commits
-------

e041365 Fix the retrieval of the last username when using forwarding
@stof stof deleted the fix_last_username_retrieval branch July 15, 2016 16:53
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.

5 participants