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

Appearance settings

[HttpKernel] Move handling of conflicting origin IPs to catch block #19233

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 2 commits into from
Jun 30, 2016

Conversation

nicolas-grekas
Copy link
Member

@nicolas-grekas nicolas-grekas commented Jun 29, 2016

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

@nicolas-grekas nicolas-grekas changed the title Catch proxy [HttpKernel] Move conflicting origin IPs handling to catch block Jun 29, 2016
@@ -46,5 +46,9 @@
<argument type="service" id="request_stack" />
<tag name="kernel.event_subscriber" />
</service>

<service id="validate_request_listener" class="Symfony\Component\HttpKernel\EventListener\RequestListener">
Copy link
Contributor

@HeahDude HeahDude Jun 29, 2016

Choose a reason for hiding this comment

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

You should also change the id accordingly to the class name, is that a possible BC break?

Copy link
Member

Choose a reason for hiding this comment

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

Not really, as request_listener can easily conflict with an existing service. But having a disconnect between the class name and the id is strange.

Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest, whatever the id is, to add it to the changelog.

@nicolas-grekas nicolas-grekas force-pushed the catch-proxy branch 3 times, most recently from c9fee33 to 65db9ec Compare June 29, 2016 18:45
@@ -63,6 +63,9 @@ public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQ
try {
return $this->handleRaw($request, $type);
} catch (\Exception $e) {
if ($e instanceof ConflictingHeadersException) {
Copy link
Member Author

@nicolas-grekas nicolas-grekas Jun 29, 2016

Choose a reason for hiding this comment

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

To me, this belongs to HttpKernel: it's a low level HttpFoundation exception (the only one), and HttpKernel job's is to map HttpFoundation to event's world, and deal with any kind of events, exceptions included. It's HttpKernel's responsibility to convert HttpFoundation exceptions to HttpKernel's world.
It's not optional at all, and existing HttpKernel users (e.g. Drupal) need to get a BadRequestHttpException that they already know how do deal with. Not this ConflictingHeadersException that comes from lower levels.

The listener below is a nice to have, that adds an early check in the request management process. Totally optional and a smooth feature for the FrameworkBundle.

Thus the split I made here.
That's only my humble opinion and maybe I miss the thing, so I'll move to the listener if you're sure it's the right place.

Copy link
Member

Choose a reason for hiding this comment

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

That's indeed much better now. 👍

@nicolas-grekas nicolas-grekas changed the title [HttpKernel] Move conflicting origin IPs handling to catch block [HttpKernel] Move handling of conflicting origin IPs to catch block Jun 30, 2016
@@ -50,4 +50,4 @@
}
}

file_put_contents('packages.json', json_encode(compact('packages'), $flags));
file_put_contents(dirname(__DIR__).'/packages.json', json_encode(compact('packages'), $flags));
Copy link
Member

Choose a reason for hiding this comment

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

these changes seems unrelated

Copy link
Member Author

Choose a reason for hiding this comment

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

yep, I'm debugging travis right now, this PR triggers situations that are not handled correctly today, please don't merge until it's green. I'll post a notice here.

@nicolas-grekas nicolas-grekas force-pushed the catch-proxy branch 5 times, most recently from e1bc96d to db84101 Compare June 30, 2016 09:16
@fabpot
Copy link
Member

fabpot commented Jun 30, 2016

Thank you @nicolas-grekas.

@fabpot fabpot merged commit db84101 into symfony:2.7 Jun 30, 2016
fabpot added a commit that referenced this pull request Jun 30, 2016
…catch block (magnusnordlander, nicolas-grekas)

This PR was merged into the 2.7 branch.

Discussion
----------

[HttpKernel] Move handling of conflicting origin IPs to catch block

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

Commits
-------

db84101 [HttpKernel] Add listener that checks when request has both Forwarded and X-Forwarded-For
1f00b55 [HttpKernel] Move conflicting origin IPs handling to catch block
@nicolas-grekas nicolas-grekas deleted the catch-proxy branch June 30, 2016 09:31
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
Morty Proxy This is a proxified and sanitized view of the page, visit original site.