Merge pull request #6914 from urbit/m/eyre-respect-forwarded-host

eyre: respect host from Forwarded header, if set
This commit is contained in:
Pyry Kovanen 2024-02-19 04:40:53 -08:00 committed by GitHub
commit da7ed92577
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -798,14 +798,15 @@
=* headers header-list.request =* headers header-list.request
:: for requests from localhost, respect the "forwarded" header :: for requests from localhost, respect the "forwarded" header
:: ::
=/ [secure=? =^address] =/ [secure=? host=(unit @t) =^address]
=* same [secure address] =/ host=(unit @t) (get-header:http 'host' headers)
=* same [secure host address]
?. =([%ipv4 .127.0.0.1] address) same ?. =([%ipv4 .127.0.0.1] address) same
?~ forwards=(forwarded-params headers) same ?~ forwards=(forwarded-params headers) same
:- (fall (forwarded-secure u.forwards) secure) :+ (fall (forwarded-secure u.forwards) secure)
(clap (forwarded-host u.forwards) host head)
(fall (forwarded-for u.forwards) address) (fall (forwarded-for u.forwards) address)
:: ::
=/ host (get-header:http 'host' headers)
=/ [=action suburl=@t] =/ [=action suburl=@t]
(get-action-for-binding host url.request) (get-action-for-binding host url.request)
:: ::
@ -3241,6 +3242,12 @@
%https `& %https `&
== ==
:: ::
++ forwarded-host
|= forwards=(list (map @t @t))
^- (unit @t)
?. ?=(^ forwards) ~
(~(get by i.forwards) 'host')
::
++ parse-request-line ++ parse-request-line
|= url=@t |= url=@t
^- [[ext=(unit @ta) site=(list @t)] args=(list [key=@t value=@t])] ^- [[ext=(unit @ta) site=(list @t)] args=(list [key=@t value=@t])]