Skip to content
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

Compatibility with Symfony 3.3+, with backwards compatibility #70

Merged
merged 7 commits into from May 30, 2017

Conversation

fideloper
Copy link
Owner

See #68


/**
* Retrieve trusted header names
* @return mixed
Copy link
Contributor

Choose a reason for hiding this comment

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

we can probably be more specific here

Copy link
Owner Author

Choose a reason for hiding this comment

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

Thinking something like "get trusted header names, falling back to defaults if not found in config" ?

Copy link
Contributor

Choose a reason for hiding this comment

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

I was meaning with the return type. :)

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 could technically return anything, we should document it to return what we actually expect it to return.

@@ -83,36 +86,59 @@ protected function setTrustedProxyIpAddresses($request)
}
}

/**
* We specify the IP addresses to trust explicitly
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing newline and full stop in each case.

@GrahamCampbell
Copy link
Contributor

Other than cs, this looks good. Symfony 3.3 is out now, so people's apps will break when they upgrade. Probably would be good to merge and tag soon. :P

@Vassard
Copy link

Vassard commented May 30, 2017

I need this, my app is down.

@LKaemmerling
Copy link

Yeahr, really soon! My App is down too!

* Set the trusted header names based on teh content of trustedproxy.headers
*
* Set the trusted header names based on the content of trustedproxy.headers
* Note: Depreciated in Symfony 3.3+, but available for backwards compatibility
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo (Depreciated) 😄

Copy link

Choose a reason for hiding this comment

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

You can use the deprecated tag for this kind of info
https://phpdoc.org/docs/latest/references/phpdoc/tags/deprecated.html

@sergiq
Copy link

sergiq commented May 30, 2017

well done guys! Let's see when this PR is merged :)

@fideloper
Copy link
Owner Author

Merging today I think!

Sidenote: your apps are down? Are y'all using Laravel 5.5 before it's released? (latest stable Laravel seems to use Symfony 3.2 specifically, based on the composer.json file). Just wondering if there's another way people end up with Symfony 3.3.

@jarnovanleeuwen
Copy link
Contributor

jarnovanleeuwen commented May 30, 2017

~3.2 allows the last digit to go up, so people with Laravel 5.4 also get Symfony 3.3 starting from today, maybe 3.2.* (like Laravel 5.3) was a more safe option.

Request expects a bitfield of headers rather than array.
@fideloper
Copy link
Owner Author

I'm pulling in #73 which builds on top of this, fixes tests, and passes the correct argument into $request->setTrustedProxies().

Add getTrustedHeaderSet(), fix tests.
@fideloper fideloper closed this May 30, 2017
@fideloper fideloper reopened this May 30, 2017
@fideloper fideloper merged commit c70165b into master May 30, 2017
@fideloper fideloper deleted the bug/symfony33 branch May 30, 2017 14:27
@Keoghan
Copy link
Contributor

Keoghan commented May 31, 2017

Thanks @fideloper

@jarnovanleeuwen
Copy link
Contributor

jarnovanleeuwen commented Jun 6, 2017

Before Symfony 3.3 we could distrust headers by setting them to null in the config. However, with this PR all header names are processed by the getTrustedHeaderSet method, despite their values. I started retrieving the following exception on some requests:

Symfony\Component\HttpFoundation\Exception\ConflictingHeadersException: The request has both a trusted "FORWARDED" header and a trusted "X_FORWARDED_FOR" header, conflicting with each other. You should either configure your proxy to remove one of them, or configure your project to distrust the offending one.

Instead of nulling, I removed \Illuminate\Http\Request::HEADER_FORWARDED from the headers array in the config, which resolved the problem.

Not sure if this is the right "fix" or this needs to be fixed in getTrustedHeaderSet. If this is the right way, the docs might need an update on distrusting header names.

@fideloper
Copy link
Owner Author

fideloper commented Jun 6, 2017 via email

@fideloper
Copy link
Owner Author

@jarnovanleeuwen See PR #77 which I've pulled in, it should address that issue.

@jarnovanleeuwen
Copy link
Contributor

Looks great! Thank you for the quick response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants