-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Change referrer policy to be controlled by header in web UI #33214
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
Conversation
ClearlyClaire
left a comment
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.
This looks fine overall, with maybe the caveat that the moderation interface should have its own referrer policy to not leak information about moderators.
|
I would prefer this to be a setting and not an environment variable, so it can be enabled more easily on managed hosting. We should maybe (in a later PR?) add a way to configure it from the admin settings. We could explain that we do not recommend enabling it for servers with < X active users because it can leak some data (if you have 3 users, it can be very obvious who clicked on the link, so this is some data leak), and maybe even show a hint near the option to recommend enabling/disabling it depending on on the number of users on the instance? |
3ea1f76 to
910f280
Compare
|
I also think this should be an admin setting but it's easier to introduce as an environment variable first. |
What about keeping it unchanged in this PR, and adding it as an admin setting in a second PR? My concern is having having to maintain awkward code (like for |
|
Also, I think this is lacking changes to |
6fd7667 to
320f373
Compare
|
Thanks, updated. I don't see a problem with future maintenance if the admin setting is added before a stable release. The reason I would like to add this as an environment variable is so we can immediately enable it on mastodon.social. |
|
This pull request has merge conflicts that must be resolved before it can be merged. |
79b7b2c to
b877844
Compare
b877844 to
bff750c
Compare
|
This pull request has resolved merge conflicts and is ready for review. |
Follow up on mastodon#33214 Having this as a setting will allow exposing it as an admin setting. There is a slight drawback here as reading the setting for every request makes a Redis call, but I am not sure if we have a way to cache it in memory for the Rails process for a few seconds. Not sure if this additional Redis query will have any impact at all.
|
Wouldn’t some people (e.g. journalists) want link targets to see the full URLs of their posts? |
|
Checking in to make sure I understand the configuration: as it is implemented right now, this is something server infra admins can enable or disable for the server, but not something that users can toggle themselves? e.g. if a server were to "enable the feature" would all users be opted in (or out) with the ability to change to the reverse via their own tools, or is it just globally on or off for the server? |
They might want that, but realistically, one would often not be on the specific post, but on a timeline, when clicking a link. And this may reveal more information than we are confident with.
This is a server setting end-users do not have control over. |
Thank you! |
|
Brief note for anyone finding this via Trunk and Tidbits - the browser ultimately decides what referrers get sent, so end users do have control in that sense. If this is a concern for someone and their instance admins prefer having referrers on, I'd encourage looking into browser configuration and/or extensions (discussion on that is better held elsewhere) so you have control over this with any website, not just the Mastodon instance you're on. |
@Gargron: Very nice that you made this configurable. However, instead of According to For more details see: https://www.w3.org/TR/referrer-policy/#referrer-policies |
|
|
A couple of changes here, ultimately with the goal of making it easier to control the referrer policy by setting
ALLOW_REFERRER_ORIGINtotruein the environment.The abundance of
rel="noreferrer"in the code is due to thejsx-no-target-blankeslint rule, which however has been disabled for a while. The rule actually has a purpose in terms of security; however, the important bit isrel="noopener", while thenoreferrerbit is only relevant for outdated Internet Explorer browsers.On one hand, I am re-enabling the eslint rule to ensure external links don't allow JavaScript access to the previous page, on the other, I am removing
noreferrerfrom all links. The browser behaviour can (and is) controlled by theReferrer-Policyheader we already set, so this change just makes it controllable from one place instead of two dozen different ones.Our default
Referrer-Policyissame-origin, which means the referrer header will only be sent when navigating within your Mastodon server, however, withALLOW_REFERRER_ORIGIN=true,Referrer-Policy: originwill be used, which will send the referrer header to external websites with only the domain of the referrer and no specific page.