-
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鈥檒l 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') { | ||
|
vidarl marked this conversation as resolved.
|
||
| 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
Contributor
Author
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. The previous implementation enabled With my change, the requests is now trusted if it comes via Fastly. My idea was this simply that this enables site integrators to enable the trusted headers they need - it makes that part possible. Then it is up to site integrators to decide what headers to enable. We could of course make things more convenient and add some default trusted headers. But this should then be treated as BC and be documented IMO. |
||
| } | ||
|
|
||
| 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?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.
@ViniTou IbexaCloud is on Upsun, and only there. We could call it
FastlyOnIbexaCloudTrustedProxiesEventSubscriberor something if you like? Personally, I preferIbexaCloudTrustedProxiesEventSubscriberthoughThere 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.
@ViniTou : You are good and thread can be closed, or you still want changes?