Problem/Motivation

A request can set Referrer policy through a metatag
<meta name="referrer" content="strict-origin-when-cross-origin" />

Or through a HTTP header:
$response->headers->set('Referrer-Policy', 'strict-origin-when-cross-origin');

Proposed resolution

Document these implementations are functionally identical in the Referrer metatag plugin.

Remaining tasks

  1. Write a patch
  2. Review
  3. Commit

User interface changes

None.

API changes

None.

Data model changes

None.

Original issue summary

Problem/Motivation
The Metatag module provides a 'referrer' plugin. This plugin was implemented in #2708511: Referrer metatag support in Drupal 8
However, the allowed values are actually Referrer-policy values. The field description indicates these are actually the intended values, so the HTTP header name should be set accordingly.

The Referer HTTP request header contains the absolute or partial address from which a resource has been requested

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referer

The Referrer-Policy HTTP header controls how much referrer information (sent with the Referer header) should be included with requests. Aside from the HTTP header, you can set this policy in HTML.

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referrer-Policy

Output on metatag 8.x-1.x:
<meta name="referrer" content="strict-origin-when-cross-origin" />

Proposed resolution
Update the output name attribute to Referrer-Policy to match the allowed values for this field:
<meta name="Referrer-Policy" content="strict-origin-when-cross-origin" />

CommentFileSizeAuthor
#9 3335688-9.patch561 bytesidebr
#2 3335688-2.patch1.18 KBidebr

Comments

idebr created an issue. See original summary.

idebr’s picture

Status: Active » Needs review
StatusFileSize
new1.18 KB

Attached patch update the output name attribute to Referrer-Policy to match the allowed values for this field:
<meta name="Referrer-Policy" content="strict-origin-when-cross-origin" />

damienmckenna’s picture

Issue summary: View changes
Status: Needs review » Needs work
Parent issue: » #3313052: Plan for Metatag 8.x-1.23

This meta tag was originally created in #2451271: Add new meta tags: referrer, which refers to the following pages:

https://stories.jotform.com/how-a-simple-update-to-medium-com-will-now-a...
https://w3c.github.io/webappsec-referrer-policy/#referrer-policy-deliver...

The last one refers to this page:

https://html.spec.whatwg.org/multipage/semantics.html#meta-referrer

There's also this one:

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta/name

Search for "referrer".

These indicate that "referrer" is a valid meta tag.

idebr’s picture

Interesting that these headers can be each be used and neither seems to be preferable?

The <meta name="referrer"> implementation is not picked up by our internal tooling as well as external scans such as https://securityheaders.io, so there maybe there are other who can benefit from the patch

damienmckenna’s picture

It might be worth extending the plugin to output the HTTP header instead of the valid meta tag?

idebr’s picture

Status: Needs work » Closed (works as designed)

Ooh I see, I mixed up the html meta head syntax with http headers. Sorry for the noise; consider this issue "works as designed"

damienmckenna’s picture

Component: Code » Documentation
Category: Bug report » Task
Status: Closed (works as designed) » Needs work

No problem at all, I appreciate the sincere questioning of what's currently in place - we all make mistakes and I've made plenty with this module over the years, it was worth taking a look into it.

Let's take a moment to add some extra documentation to the Referrer plugin to make this more clear.

idebr’s picture

Title: Referrer metatag actually implements Referrer-policy » Document meta name="referrer" relationship with Referrer-policy HTTP header
idebr’s picture

Issue summary: View changes
Status: Needs work » Needs review
StatusFileSize
new561 bytes

Attached patch adds documentation to the Referrer plugin to explain the difference between the html <meta name="referrer"> and Referrer-policy HTTP header.

Updated the issue summary accordingly.

  • DamienMcKenna committed e0766d9d on 8.x-1.x authored by idebr
    Issue #3335688 by idebr, DamienMcKenna: Document meta name="referrer"...
damienmckenna’s picture

Status: Needs review » Fixed

Committed with some refinements. Thanks!

  • DamienMcKenna committed aaa44959 on 2.0.x authored by idebr
    Issue #3335688 by idebr, DamienMcKenna: Document meta name="referrer"...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.