-
Notifications
You must be signed in to change notification settings - Fork 19
IBX-11181: Trusted Proxies is not set on Ibexa Cloud #699
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
base: 4.6
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,16 +15,6 @@ | |
|
|
||
| final class TrustedHeaderClientIpEventSubscriber implements EventSubscriberInterface | ||
| { | ||
| private const PLATFORM_SH_TRUSTED_HEADER_CLIENT_IP = 'X-Client-IP'; | ||
|
|
||
| private ?string $trustedHeaderName; | ||
|
|
||
| public function __construct( | ||
| ?string $trustedHeaderName | ||
| ) { | ||
| $this->trustedHeaderName = $trustedHeaderName; | ||
| } | ||
|
|
||
| public static function getSubscribedEvents(): array | ||
| { | ||
| return [ | ||
|
|
@@ -36,28 +26,9 @@ public function onKernelRequest(RequestEvent $event): void | |
| { | ||
| $request = $event->getRequest(); | ||
|
|
||
| $trustedProxies = Request::getTrustedProxies(); | ||
| $trustedHeaderSet = Request::getTrustedHeaderSet(); | ||
|
|
||
| $trustedHeaderName = $this->trustedHeaderName; | ||
| if (null === $trustedHeaderName && $this->isPlatformShProxy($request)) { | ||
| $trustedHeaderName = self::PLATFORM_SH_TRUSTED_HEADER_CLIENT_IP; | ||
| if ($this->isPlatformShProxy($request) && $request->headers->get('Client-Cdn') === 'fastly') { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As discussed with Vidar
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Confirmed by Upsun (thanks Vidar for reaching out to them with this question): client can't spoof |
||
| Request::setTrustedProxies(['REMOTE_ADDR'], Request::getTrustedHeaderSet()); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wouldn't that fallback to Symfony's default if
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Via Symfony's code: $trustedHeaderSet = $trustedHeaders ?? (Request::HEADER_X_FORWARDED_FOR | Request::HEADER_X_FORWARDED_PORT | Request::HEADER_X_FORWARDED_PROTO);
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the other hand,
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Additionally, if I understand correctly |
||
| } | ||
|
|
||
| if (null === $trustedHeaderName) { | ||
| return; | ||
| } | ||
|
|
||
| $trustedClientIp = $request->headers->get($trustedHeaderName); | ||
|
|
||
| if (null !== $trustedClientIp) { | ||
| if ($trustedHeaderSet !== -1) { | ||
| $trustedHeaderSet |= Request::HEADER_X_FORWARDED_FOR; | ||
| } | ||
| $request->headers->set('X_FORWARDED_FOR', $trustedClientIp); | ||
| } | ||
|
|
||
| Request::setTrustedProxies($trustedProxies, $trustedHeaderSet); | ||
| } | ||
|
|
||
| private function isPlatformShProxy(Request $request): bool | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or this is considered a BC ? Class is final though, so maybe not a problem?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't care
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isnt
IbexaCloudtoo generic tho? this whole class is about Upsun & Fastly, right?