Это перевод статьи «A new security header: Referrer Policy» Scott Helme, публикуется с разрешения автора. ©
...
Source (откуда ссылка) | Destination (куда) | Referrer (значение заголовка) |
---|---|---|
https://scotthelme.co.uk/blog1/ | http://scotthelme.co.uk/blog2/ | NULL |
https://scotthelme.co.uk/blog1/ | https://scotthelme.co.uk/blog2/ | NULL |
http://scotthelme.co.uk/blog1/ | http://scotthelme.co.uk/blog2/ | NULL |
http://scotthelme.co.uk/blog1/ | http://example.com | NULL |
http://scotthelme.co.uk/blog1/ | https://example.com | NULL |
https://scotthelme.co.uk/blog1/ | http://example.com | NULL |
Если вы не видите отличий между ссылками, то обратите внимание на разницу HTTP и HTTPS. Автор показывает, что нет разницы, переходим мы с защищенного ресурса или нет. В других значениях заголовка эта разница будет
...
Source (откуда ссылка) | Destination (куда) | Referrer (значение заголовка) |
---|---|---|
https://scotthelme.co.uk/blog1/ | http://scotthelme.co.uk/blog2/ | NULL |
https://scotthelme.co.uk/blog1/ | https://scotthelme.co.uk/blog2/ | https://scotthelme.co.uk/blog1/ |
http://scotthelme.co.uk/blog1/ | http://scotthelme.co.uk/blog2/ | http://scotthelme.co.uk/blog1/ |
http://scotthelme.co.uk/blog1/ | http://example.com | http://scotthelme.co.uk/blog1/ |
http://scotthelme.co.uk/blog1/ | https://example.com | http://scotthelme.co.uk/blog1/ |
https://scotthelme.co.uk/blog1/ | http://example.com | NULL |
same-origin
Браузер отправляет значение referer только в том случае, если ссылка ведет на тот же сайт. В любом другом случае значение будет пустое
...
Source (откуда ссылка) | Destination (куда) | Referrer (значение заголовка) |
---|---|---|
https://scotthelme.co.uk/blog1/ | https://scotthelme.co.uk/blog2/ | https://scotthelme.co.uk/blog1/ |
https://scotthelme.co.uk/blog1/ | http://scotthelme.co.uk/blog2/ | NULL |
https://scotthelme.co.uk/blog1/ | http://example.com | NULL |
https://scotthelme.co.uk/blog1/ | https://example.com | NULL |
origin
Браузер всегда отображает в referer только сайт, откуда пришел запрос. Всю дополнительную информацию из URL он вырезает
...
Source (откуда ссылка) | Destination (куда) | Referrer (значение заголовка) |
---|---|---|
https://scotthelme.co.uk/blog1/ | https://scotthelme.co.uk/blog2/ | https://scotthelme.co.uk/ |
https://scotthelme.co.uk/blog1/ | http://scotthelme.co.uk/blog2/ | https://scotthelme.co.uk/ |
https://scotthelme.co.uk/blog1/ | http://example.com | https://scotthelme.co.uk/ |
strict-origin
Аналогично origin, но данный заголовок запрещает слать информацию на HTTP, только на защищенные ссылки: HTTPS
...
Source (откуда ссылка) | Destination (куда) | Referrer (значение заголовка) |
---|---|---|
https://scotthelme.co.uk/blog1/ | https://scotthelme.co.uk/blog2/ | https://scotthelme.co.uk/ |
https://scotthelme.co.uk/blog1/ | http://scotthelme.co.uk/blog2/ | NULL |
https://scotthelme.co.uk/blog1/ | http://example.com | NULL |
http://scotthelme.co.uk/blog1/ | https://scotthelme.co.uk/blog2/ | http://scotthelme.co.uk/ |
http://scotthelme.co.uk/blog1/ | https://scotthelme.co.uk/blog2/ | http://scotthelme.co.uk/ |
http://scotthelme.co.uk/blog1/ | http://example.com | http://scotthelme.co.uk/ |
origin-when-cross-origin
Браузер отправляет полный URL на тот же сайт, и неполный (только название) на все остальные
...
Source (откуда ссылка) | Destination (куда) | Referrer (значение заголовка) |
---|---|---|
https://scotthelme.co.uk/blog1/ | https://scotthelme.co.uk/blog2/ | https://scotthelme.co.uk/blog1/ |
https://scotthelme.co.uk/blog1/ | https://example.com/ | https://scotthelme.co.uk/ |
https://scotthelme.co.uk/blog1/ | http://scotthelme.co.uk/blog2/ | https://scotthelme.co.uk/ |
https://scotthelme.co.uk/blog1/ | http://example.com/ | https://scotthelme.co.uk/ |
http://scotthelme.co.uk/blog1/ | https://scotthelme.co.uk/blog2/ | http://scotthelme.co.uk/ |
strict-origin-when-cross-origin
...
Source (откуда ссылка) | Destination (куда) | Referrer (значение заголовка) |
---|---|---|
https://scotthelme.co.uk/blog1/ | https://scotthelme.co.uk/blog2/ | https://scotthelme.co.uk/blog1/ |
https://scotthelme.co.uk/blog1/ | https://example.com/ | https://scotthelme.co.uk/ |
https://scotthelme.co.uk/blog1/ | http://scotthelme.co.uk/blog2/ | NULL |
https://scotthelme.co.uk/blog1/ | http://example.com/ | NULL |
http://scotthelme.co.uk/blog1/ | http://example.com/ | http://scotthelme.co.uk/ |
unsafe-url
Браузер всегда посылает полный URL, с любого сайта.
...
Source (откуда ссылка) | Destination (куда) | Referrer (значение заголовка) |
---|---|---|
https://scotthelme.co.uk/blog1/ | https://scotthelme.co.uk/blog2/ | https://scotthelme.co.uk/blog1/ |
https://scotthelme.co.uk/blog1/ | https://example.com/ | https://scotthelme.co.uk/blog1/ |
https://scotthelme.co.uk/blog1/ | http://scotthelme.co.uk/blog2/ | https://scotthelme.co.uk/blog1/ |
https://scotthelme.co.uk/blog1/ | http://example.com/ | https://scotthelme.co.uk/blog1/ |
http://scotthelme.co.uk/blog1/ | http://example.com/ | http://scotthelme.co.uk/ |
Рекомендации
Какой именно заголовок использовать — зависит от вашего желания или выставленных требований. Но от некоторых лучше держаться подальше. Например, автор не рекомендует использовать unsafe-url, который ничего не скрывает. Аналогично, если вы подумываете взять origin или origin-when-cross-origin, автор рекомендует вместо них присмотреться к strict-origin и strict-origin-when-cross-origin. Это, по крайней мере, заткнет небольшую дыру протекающих данных о ссылающемся домене по опасному каналу HTTP. У самого автора нет ничего секретного в URL сайта, поэтому он предпочитает использовать no-referrer-when-downgrade, чисто для сохранности данных при переходе на HTTP.
...