Bug 1357835 - Extend telemetry for http autentication dialog prompt to show the subresource cross-origin auth dialog prompt per suresource type. Also add a pre to putentially disable auth propts for the cross-origin images. r=mayhemer r=ckerschb r=francois

This commit is contained in:
Dragana Damjanovic dd.mozilla@gmail.com 2017-05-09 12:36:21 +02:00
Родитель 5e10562ae6
Коммит 62b9fc4ab8
5 изменённых файлов: 44 добавлений и 21 удалений

Просмотреть файл

@ -2028,6 +2028,13 @@ pref("network.generic-ntlm-auth.workstation", "WORKSTATION");
// 2 - allow the cross-origin authentication as well.
pref("network.auth.subresource-http-auth-allow", 2);
// Sub-resources HTTP-authentication for cross-origin images:
// true - it is allowed to present http auth. dialog for cross-origin images.
// false - it is not allowed.
// If network.auth.subresource-http-auth-allow has values 0 or 1 this pref does not
// have any effect.
pref("network.auth.subresource-img-cross-origin-http-auth-allow", true);
// This preference controls whether to allow sending default credentials (SSO) to
// NTLM/Negotiate servers allowed in the "trusted uri" list when navigating them
// in a Private Browsing window.

Просмотреть файл

@ -39,10 +39,9 @@ namespace net {
#define SUBRESOURCE_AUTH_DIALOG_DISALLOW_CROSS_ORIGIN 1
#define SUBRESOURCE_AUTH_DIALOG_ALLOW_ALL 2
#define HTTP_AUTH_DIALOG_TOP_LEVEL_DOC 0
#define HTTP_AUTH_DIALOG_SAME_ORIGIN_SUBRESOURCE 1
#define HTTP_AUTH_DIALOG_CROSS_ORIGIN_SUBRESOURCE 2
#define HTTP_AUTH_DIALOG_XHR 3
#define HTTP_AUTH_DIALOG_TOP_LEVEL_DOC 29
#define HTTP_AUTH_DIALOG_SAME_ORIGIN_SUBRESOURCE 30
#define HTTP_AUTH_DIALOG_SAME_ORIGIN_XHR 31
#define HTTP_AUTH_BASIC_INSECURE 0
#define HTTP_AUTH_BASIC_SECURE 1
@ -95,6 +94,8 @@ nsHttpChannelAuthProvider::~nsHttpChannelAuthProvider()
uint32_t nsHttpChannelAuthProvider::sAuthAllowPref =
SUBRESOURCE_AUTH_DIALOG_ALLOW_ALL;
bool nsHttpChannelAuthProvider::sImgCrossOriginAuthAllowPref = true;
void
nsHttpChannelAuthProvider::InitializePrefs()
{
@ -102,6 +103,9 @@ nsHttpChannelAuthProvider::InitializePrefs()
mozilla::Preferences::AddUintVarCache(&sAuthAllowPref,
"network.auth.subresource-http-auth-allow",
SUBRESOURCE_AUTH_DIALOG_ALLOW_ALL);
mozilla::Preferences::AddBoolVarCache(&sImgCrossOriginAuthAllowPref,
"network.auth.subresource-img-cross-origin-http-auth-allow",
true);
}
NS_IMETHODIMP
@ -912,8 +916,8 @@ nsHttpChannelAuthProvider::GetCredentialsForChallenge(const char *challenge,
// BlockPrompt will set mCrossOrigin parameter as well.
if (BlockPrompt()) {
LOG(("nsHttpChannelAuthProvider::GetCredentialsForChallenge: "
"Prompt is blocked [this=%p pref=%d]\n",
this, sAuthAllowPref));
"Prompt is blocked [this=%p pref=%d img-pref=%d]\n",
this, sAuthAllowPref, sImgCrossOriginAuthAllowPref));
return NS_ERROR_ABORT;
}
@ -1014,17 +1018,19 @@ nsHttpChannelAuthProvider::BlockPrompt()
if (gHttpHandler->IsTelemetryEnabled()) {
if (topDoc) {
Telemetry::Accumulate(Telemetry::HTTP_AUTH_DIALOG_STATS,
Telemetry::Accumulate(Telemetry::HTTP_AUTH_DIALOG_STATS_2,
HTTP_AUTH_DIALOG_TOP_LEVEL_DOC);
} else if (xhr) {
Telemetry::Accumulate(Telemetry::HTTP_AUTH_DIALOG_STATS,
HTTP_AUTH_DIALOG_XHR);
} else if (!mCrossOrigin) {
Telemetry::Accumulate(Telemetry::HTTP_AUTH_DIALOG_STATS,
HTTP_AUTH_DIALOG_SAME_ORIGIN_SUBRESOURCE);
if (xhr) {
Telemetry::Accumulate(Telemetry::HTTP_AUTH_DIALOG_STATS_2,
HTTP_AUTH_DIALOG_SAME_ORIGIN_XHR);
} else {
Telemetry::Accumulate(Telemetry::HTTP_AUTH_DIALOG_STATS_2,
HTTP_AUTH_DIALOG_SAME_ORIGIN_SUBRESOURCE);
}
} else {
Telemetry::Accumulate(Telemetry::HTTP_AUTH_DIALOG_STATS,
HTTP_AUTH_DIALOG_CROSS_ORIGIN_SUBRESOURCE);
Telemetry::Accumulate(Telemetry::HTTP_AUTH_DIALOG_STATS_2,
loadInfo->GetExternalContentPolicyType());
}
}
@ -1038,7 +1044,16 @@ nsHttpChannelAuthProvider::BlockPrompt()
// the sub-resources only if they are not cross-origin.
return !topDoc && !xhr && mCrossOrigin;
case SUBRESOURCE_AUTH_DIALOG_ALLOW_ALL:
// Allow the http-authentication dialog.
// Allow the http-authentication dialog for subresources.
// If pref network.auth.subresource-img-cross-origin-http-auth-allow
// is set, http-authentication dialog for image subresources is
// blocked.
if (!sImgCrossOriginAuthAllowPref &&
loadInfo &&
((loadInfo->GetExternalContentPolicyType() == nsIContentPolicy::TYPE_IMAGE) ||
(loadInfo->GetExternalContentPolicyType() == nsIContentPolicy::TYPE_IMAGESET))) {
return true;
}
return false;
default:
// This is an invalid value.

Просмотреть файл

@ -186,6 +186,7 @@ private:
// authentication credentials dialogs for sub-resources and cross-origin
// sub-resources.
static uint32_t sAuthAllowPref;
static bool sImgCrossOriginAuthAllowPref;
nsCOMPtr<nsICancelable> mGenerateCredentialsCancelable;
};

Просмотреть файл

@ -2112,11 +2112,13 @@
"n_values": 4,
"description": "Whether we raced network with the cache. (0=network & no racing, 1=cache & no racing, 2=network & raced, 3=cache & raced)"
},
"HTTP_AUTH_DIALOG_STATS": {
"expires_in_version": "never",
"HTTP_AUTH_DIALOG_STATS_2": {
"expires_in_version": "61",
"alert_emails": ["necko@mozilla.com"],
"bug_numbers": [1357835],
"kind": "enumerated",
"n_values": 4,
"description": "Stats about what kind of resource requested http authentication. (0=top-level doc, 1=same origin subresources, 2=cross-origin subresources, 3=xhr)"
"n_values": 32,
"description": "Stats about what kind of resource requested http authentication. (29=top-level doc, 30=same origin subresources, 31=same origin xhr, (nsIContentPolicy type)=cross-origin subresources per nsIContentPolicy type)"
},
"HTTP_AUTH_TYPE_STATS": {
"alert_emails": ["rbarnes@mozilla.com"],

Просмотреть файл

@ -286,7 +286,6 @@
"HTTPCONNMGR_TOTAL_SPECULATIVE_CONN",
"HTTPCONNMGR_UNUSED_SPECULATIVE_CONN",
"HTTPCONNMGR_USED_SPECULATIVE_CONN",
"HTTP_AUTH_DIALOG_STATS",
"HTTP_CACHE_DISPOSITION_2",
"HTTP_CACHE_DISPOSITION_2_V2",
"HTTP_CACHE_ENTRY_ALIVE_TIME",
@ -1012,7 +1011,6 @@
"HTTPCONNMGR_TOTAL_SPECULATIVE_CONN",
"HTTPCONNMGR_UNUSED_SPECULATIVE_CONN",
"HTTPCONNMGR_USED_SPECULATIVE_CONN",
"HTTP_AUTH_DIALOG_STATS",
"HTTP_CACHE_DISPOSITION_2",
"HTTP_CACHE_DISPOSITION_2_V2",
"HTTP_CACHE_ENTRY_ALIVE_TIME",