Added an advanced settings page for referrer policy settings.

Feedback will be welcome, notably on the descriptive content of this
page.
pull/114/head
luccioman 8 years ago
parent 81963a89fe
commit 0173b0bc32

@ -192,7 +192,9 @@
::<!-- 33: Url/Web proxy settings changed -->
<p>URL Proxy settings have been saved.</p>
::<!-- 34: Debug/Analysis settings changed -->
<p>Debug/Analysis settings have been saved.</p>
<p>Debug/Analysis settings have been saved.</p>
::<!-- 35: Referrer policy settings changed -->
<p>Referrer policy settings have been saved.</p>
#(/info)#
<p></p>
#(needsRestart)#

@ -546,6 +546,18 @@ public class SettingsAck_p {
prop.put("info", "34");
return prop;
}
// Referrer Policy settings
if (post.containsKey("referrerPolicySettings")) {
String metaPolicy = post.get("metaPolicy", SwitchboardConstants.REFERRER_META_POLICY_DEFAULT);
env.setConfig(SwitchboardConstants.REFERRER_META_POLICY, metaPolicy);
boolean tickedCheckbox = post.containsKey("searchResultNoReferrer");
env.setConfig(SwitchboardConstants.SEARCH_RESULT_NOREFERRER, tickedCheckbox);
prop.put("info", "35");
return prop;
}
// nothing made
prop.put("info", "1");//no information submitted

@ -0,0 +1,217 @@
<h3>Referrer Policy Settings</h3>
<p>
When loading pages and navigating through links, a web browser sends some information about the origin of the request,
by filling the <a href="https://tools.ietf.org/html/rfc7231#section-5.5.2" title="'Referer' section from the standard IETF specification">"Referer"</a> HTTP header.
Visited websites can process this information as they whish, so this can become a privacy concern, for example when coming from a page which contains searched terms in its URL.
</p>
<p>
This page offers some configuration settings to instruct your browser how it should fill this referrer information.
Beware that every browser behaves differently : some settings may be unsupported by your particular browser and therefore ignored.
If you are really concerned about privacy, please check what is really sent by your browser by using its embedded developers tools network console, or with the network traffic analyzer of your choice.
</p>
<form action="SettingsAck_p.html" method="post" class="form-horizontal">
<fieldset>
<legend>Global policy</legend>
<p>
This referrer policy applies for every page on this peer. It is set by the "meta" HTML tag.
</p>
<p> Values are sorted by decreasing privacy level.
See the related <a href="https://www.w3.org/TR/referrer-policy/#referrer-policies">W3C recommendation</a> for full details and available values.
</p>
<div class="form-group">
<div class="col-sm-4">
<div class="radio">
<label>
<input name="metaPolicy" id="metaPolicyNoReferrer"
type="radio" #(metaPolicyNoReferrerChecked)#::checked#(/metaPolicyNoReferrerChecked)#
value="no-referrer" aria-describedby="metaPolicyNoReferrerInfo"/>
no-referrer
</label>
</div>
</div>
<div class="col-sm-8" id="metaPolicyNoReferrerInfo">
Highest privacy setting : referrer information should never be sent, even when navigating on this peer internal links.
Be careful with this : some websites might reject requests with no referrer.
</div>
</div>
<div class="form-group">
<div class="col-sm-4">
<div class="radio">
<label>
<input name="metaPolicy" id="metaPolicySameOrigin"
type="radio" #(metaPolicySameOriginChecked)#::checked#(/metaPolicySameOriginChecked)#
value="same-origin" aria-describedby="metaPolicySameOriginInfo"/>
same-origin
</label>
</div>
</div>
<div class="col-sm-8" id="metaPolicySameOriginInfo">
Peer internal links : referrer information should be stripped from any private data and contain only this peer host name.<br/>
External links : referrer information should never be sent.
</div>
</div>
<div class="form-group">
<div class="col-sm-4">
<div class="radio">
<label>
<input name="metaPolicy" id="metaPolicyStrictOrigin"
type="radio" #(metaPolicyStrictOriginChecked)#::checked#(/metaPolicyStrictOriginChecked)#
value="strict-origin" aria-describedby="metaPolicyStrictOriginInfo"/>
strict-origin
</label>
</div>
</div>
<div class="col-sm-8" id="metaPolicyStrictOriginInfo">
Peer internal and external links : referrer information should be stripped from any private data and contain only this peer host name.<br/>
Restriction : when a link downgrades from a TLS secured connection (https) on this peer to an unsecured target (http), no referrer information at all should be sent.
</div>
</div>
<div class="form-group">
<div class="col-sm-4">
<div class="radio">
<label>
<input name="metaPolicy" id="metaPolicyOrigin"
type="radio" #(metaPolicyOriginChecked)#::checked#(/metaPolicyOriginChecked)#
value="origin" aria-describedby="metaPolicyOriginInfo"/>
origin
</label>
</div>
</div>
<div class="col-sm-8" id="metaPolicyOriginInfo">
Peer internal and external links : referrer information should be stripped from any private data and contain only this peer host name.<br/>
Note : this value is also compatible with legacy values from the older <a href="https://wiki.whatwg.org/wiki/Meta_referrer">specification draft</a>.
</div>
</div>
<div class="form-group">
<div class="col-sm-4">
<div class="radio">
<label>
<input name="metaPolicy" id="metaPolicyStrictOriginWhenCrossOrigin"
type="radio" #(metaPolicyStrictOriginWhenCrossOriginChecked)#::checked#(/metaPolicyStrictOriginWhenCrossOriginChecked)#
value="strict-origin-when-cross-origin" aria-describedby="metaPolicyStrictOriginWhenCrossOriginInfo"/>
strict-origin-when-cross-origin
</label>
</div>
</div>
<div class="col-sm-8" id="metaPolicyStrictOriginWhenCrossOriginInfo">
Peer internal links : referrer information should contain full URLs.<br/>
External links : referrer information should be stripped from any private data and contain only this peer host name.<br/>
Restriction : when an external link downgrades from a TLS secured connection (https) on this peer to an unsecured target (http), no referrer information at all should be sent.
</div>
</div>
<div class="form-group">
<div class="col-sm-4">
<div class="radio">
<label>
<input name="metaPolicy" id="metaPolicyOriginWhenCrossOrigin"
type="radio" #(metaPolicyOriginWhenCrossOriginChecked)#::checked#(/metaPolicyOriginWhenCrossOriginChecked)#
value="origin-when-cross-origin" aria-describedby="metaPolicyOriginWhenCrossOriginInfo"/>
origin-when-cross-origin
</label>
</div>
</div>
<div class="col-sm-8" id="metaPolicyOriginWhenCrossOriginInfo">
Peer internal links : referrer information should contain full URLs.<br/>
External links : referrer information should be stripped from any private data and contain only this peer host name.
</div>
</div>
<div class="form-group">
<div class="col-sm-4">
<div class="radio">
<label>
<input name="metaPolicy" id="metaPolicyNoReferrerWhenDowngrade"
type="radio" #(metaPolicyNoReferrerWhenDowngradeChecked)#::checked#(/metaPolicyNoReferrerWhenDowngradeChecked)#
value="no-referrer-when-downgrade" aria-describedby="metaPolicyNoReferrerWhenDowngradeInfo"/>
no-referrer-when-downgrade
</label>
</div>
</div>
<div class="col-sm-8" id="metaPolicyNoReferrerWhenDowngradeInfo">
Referrer information should contain full URLs, except when a link downgrades from a TLS secured connection (https) on this peer to an unsecured target (http).
</div>
</div>
<div class="form-group">
<div class="col-sm-4">
<div class="radio">
<label>
<input name="metaPolicy" id="metaPolicyEmpty"
type="radio" #(metaPolicyEmptyChecked)#::checked#(/metaPolicyEmptyChecked)#
value="" aria-describedby="metaPolicyEmptyInfo"/>
empty value
</label>
</div>
</div>
<div class="col-sm-8" id="metaPolicyEmptyInfo">
Default browser behavior : it should corresponds to "no-referrer-when-downgrade".
</div>
</div>
<div class="form-group">
<div class="col-sm-4">
<div class="radio">
<label>
<input name="metaPolicy" id="metaPolicyUnsafeUrl"
type="radio" #(metaPolicyUnsafeUrlChecked)#::checked#(/metaPolicyUnsafeUrlChecked)#
value="unsafe-url" aria-describedby="metaPolicyUnsafeUrlInfo"/>
unsafe-url
</label>
</div>
</div>
<div class="col-sm-8" id="metaPolicyUnsafeUrlInfo">
Unsafe setting : referrer information should always contain full URLs.
</div>
</div>
#(metaPolicyCustom)#::
<div class="form-group">
<div class="col-sm-4">
<div class="radio">
<label>
<input name="metaPolicy" id="metaPolicyCustom"
type="radio" #(checked)#::checked#(/checked)#
value="#[value]#" aria-describedby="metaPolicyCustomInfo"/>
#[value]#
</label>
</div>
</div>
<div class="col-sm-7 alert alert-warning" id="metaPolicyCustomInfo" role="alert">
Custom setting : probably manually edited, be sure this value is the desired one.
</div>
</div>
#(/metaPolicyCustom)#
</fieldset>
<fieldset>
<legend>Search results links</legend>
<div class="form-group">
<div class="col-sm-4">
<div class="checkbox">
<label>
<input name="searchResultNoReferrer" id="searchResultNoReferrer"
type="checkbox" #(searchResultNoReferrerChecked)#::checked#(/searchResultNoReferrerChecked)#
aria-describedby="searchResultNoReferrerInfo"/>
Add the "noreferrer" link type to search results links
</label>
</div>
</div>
<div class="col-sm-8" id="searchResultNoReferrerInfo">
<p>When checked, this overrides the global referrer policy and adds the standard "noreferrer"
<a href="https://www.w3.org/TR/html/links.html#allowed-keywords-and-their-meanings" title="Link types section at W3C HTML specification">link type</a> to search results links,
thus instructing the browser that it should not send any referrer information at all when visiting them.</p>
<p>Be careful with this : some websites might reject requests with no referrer.</p>
<p>It is a standard HTML5 attribute value,
supported by much more browsers than the meta tag : if you want a higher level of privacy but use an old or incompatible browser,
this can be a valuable option.</p>
</div>
</div>
</fieldset>
<div class="col-sm-6">
<input type="submit" class="btn btn-primary" name="referrerPolicySettings" value="Submit" aria-describedby="submitInfo"/>
<em id="submitInfo">Changes will take effect immediately.</em>
</div>
</form>

@ -17,6 +17,7 @@
<td valign="top">
<ul class="settingsMenu">
<li><a href="?page=ServerAccess">Server Access Settings</a></li>
<li><a href="?page=referrer">Referrer Policy Settings</a></li>
<li><a href="?page=crawler">Crawler Settings</a></li>
<li><a href="?page=seed">Seed Upload Settings</a></li>
<li><a href="?page=messageForwarding">Message Forwarding (optional)</a></li>

@ -26,6 +26,7 @@ import java.util.HashMap;
import java.util.Iterator;
import net.yacy.cora.protocol.RequestHeader;
import net.yacy.http.ReferrerPolicy;
import net.yacy.peers.Network;
import net.yacy.peers.Seed;
import net.yacy.peers.operation.yacySeedUploader;
@ -57,6 +58,8 @@ public final class Settings_p {
}
else if (page.equals("ServerAccess")) {
prop.put("settingsTables", "Settings_ServerAccess.inc");
} else if (page.equals("referrer")) {
prop.put("settingsTables", "Settings_Referrer.inc");
}
else if (page.equals("SystemBehaviour")) {
prop.put("settingsTables", "Settings_SystemBehaviour.inc");
@ -202,6 +205,29 @@ public final class Settings_p {
prop.put("solrBinaryResponseChecked", env.getConfigBool(SwitchboardConstants.REMOTE_SOLR_BINARY_RESPONSE_ENABLED,
SwitchboardConstants.REMOTE_SOLR_BINARY_RESPONSE_ENABLED_DEFAULT) ? 1 : 0);
// Referrer Policy
final String metaPolicy = env.getConfig(SwitchboardConstants.REFERRER_META_POLICY,
SwitchboardConstants.REFERRER_META_POLICY_DEFAULT);
prop.put("metaPolicyNoReferrerChecked", ReferrerPolicy.NO_REFERRER.getValue().equals(metaPolicy) ? 1 : 0);
prop.put("metaPolicySameOriginChecked", ReferrerPolicy.SAME_ORIGIN.getValue().equals(metaPolicy) ? 1 : 0);
prop.put("metaPolicyStrictOriginChecked", ReferrerPolicy.STRICT_ORIGIN.getValue().equals(metaPolicy) ? 1 : 0);
prop.put("metaPolicyOriginChecked", ReferrerPolicy.ORIGIN.getValue().equals(metaPolicy) ? 1 : 0);
prop.put("metaPolicyStrictOriginWhenCrossOriginChecked", ReferrerPolicy.STRICT_ORIGIN_WHEN_CROSS_ORIGIN.getValue().equals(metaPolicy) ? 1 : 0);
prop.put("metaPolicyOriginWhenCrossOriginChecked", ReferrerPolicy.ORIGIN_WHEN_CROSS_ORIGIN.getValue().equals(metaPolicy) ? 1 : 0);
prop.put("metaPolicyNoReferrerWhenDowngradeChecked", ReferrerPolicy.NO_REFERRER_WHEN_DOWNGRADE.getValue().equals(metaPolicy) ? 1 : 0);
prop.put("metaPolicyEmptyChecked", ReferrerPolicy.EMPTY.getValue().equals(metaPolicy) ? 1 : 0);
prop.put("metaPolicyUnsafeUrlChecked", ReferrerPolicy.UNSAFE_URL.getValue().equals(metaPolicy) ? 1 : 0);
if(ReferrerPolicy.contains(metaPolicy)) {
prop.put("metaPolicyCustom", 0);
} else {
prop.put("metaPolicyCustom", 1);
prop.put("metaPolicyCustom_checked", 1);
prop.put("metaPolicyCustom_value", metaPolicy);
}
prop.put("searchResultNoReferrerChecked", env.getConfigBool(SwitchboardConstants.SEARCH_RESULT_NOREFERRER,
SwitchboardConstants.SEARCH_RESULT_NOREFERRER_DEFAULT) ? 1 : 0);
/* For easier user understanding, the following flags controlling data sources selection
* are rendered in the UI as checkboxes corresponding to enabled value when ticked */
prop.put("searchLocalDHTChecked", !env.getConfigBool(SwitchboardConstants.DEBUG_SEARCH_LOCAL_DHT_OFF, false) ? 1 : 0);

@ -0,0 +1,79 @@
// ReferrerPolicy.java
// Copyright 2017 by luccioman; https://github.com/luccioman
//
// This is a part of YaCy, a peer-to-peer based web search engine
//
// $LastChangedDate$
// $LastChangedRevision$
// $LastChangedBy$
//
// LICENSE
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package net.yacy.http;
/**
* Referrer policies enumeration, as decribed by the related W3C recommendation
* (https://www.w3.org/TR/referrer-policy/#referrer-policies)
*/
public enum ReferrerPolicy {
EMPTY(""),
NO_REFERRER("no-referrer"),
NO_REFERRER_WHEN_DOWNGRADE("no-referrer-when-downgrade"),
SAME_ORIGIN("same-origin"),
ORIGIN("origin"),
STRICT_ORIGIN("strict-origin"),
ORIGIN_WHEN_CROSS_ORIGIN("origin-when-cross-origin"),
STRICT_ORIGIN_WHEN_CROSS_ORIGIN("strict-origin-when-cross-origin"),
UNSAFE_URL("unsafe-url");
/**
* Policy string value
*/
private final String value;
/**
* Enumeration private constructor
* @param value the policy string value
*/
private ReferrerPolicy(final String value) {
this.value = value;
}
/**
* @return the policy string value
*/
public String getValue() {
return value;
}
/**
* @param value a policy string value
* @return true when this enumeration contains an element with the specified policy value
*/
public static boolean contains(final String value) {
boolean res = false;
for(ReferrerPolicy policy : ReferrerPolicy.values()) {
if(policy.getValue().equals(value)) {
res = true;
break;
}
}
return res;
}
}

@ -1020,7 +1020,7 @@ public class YaCyDefaultServlet extends HttpServlet {
templatePatterns.putHTML(servletProperties.PEER_STAT_CLIENTID, sb.peers.myID());
templatePatterns.put(servletProperties.PEER_STAT_MYTIME, GenericFormatter.SHORT_SECOND_FORMATTER.format());
templatePatterns.put(servletProperties.RELATIVE_BASE, YaCyDefaultServlet.getRelativeBase(target));
templatePatterns.put(SwitchboardConstants.REFERRER_POLICY, sb.getConfig(SwitchboardConstants.REFERRER_POLICY, SwitchboardConstants.REFERRER_POLICY_DEFAULT));
templatePatterns.put(SwitchboardConstants.REFERRER_META_POLICY, sb.getConfig(SwitchboardConstants.REFERRER_META_POLICY, SwitchboardConstants.REFERRER_META_POLICY_DEFAULT));
Seed myPeer = sb.peers.mySeed();
templatePatterns.put("newpeer", myPeer.getAge() >= 1 ? 0 : 1);
templatePatterns.putHTML("newpeer_peerhash", myPeer.hash);

@ -275,10 +275,10 @@ public final class SwitchboardConstants {
public static final String CLUSTER_PEERS_IPPORT = "cluster.peers.ipport";
/** Key of the global HTTP Referrer policy delivered by meta tag */
public static final String REFERRER_POLICY = "referrer.meta.policy";
public static final String REFERRER_META_POLICY = "referrer.meta.policy";
/** Default value for the global HTTP Referrer policy delivered by meta tag */
public static final String REFERRER_POLICY_DEFAULT = "origin-when-cross-origin";
public static final String REFERRER_META_POLICY_DEFAULT = "origin-when-cross-origin";
public static final String DHT_ENABLED = "network.unit.dht";

Loading…
Cancel
Save