Skip to content

Commit acdac56

Browse files
authored
Add option to disable signature verification (#255)
1 parent d83bcf1 commit acdac56

5 files changed

Lines changed: 84 additions & 25 deletions

File tree

extension/content/index.html

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,32 @@
66
</head>
77

88
<body class=" loading">
9-
<section id="header">
10-
<section id="env-actions">
11-
<h2>Environment</h2>
12-
<select id="environment">
13-
<option value="custom"></option>
14-
<option value="prod">Prod</option>
15-
<option value="prod-preview">Prod (preview)</option>
16-
<option value="stage">Stage</option>
17-
<option value="stage-preview">Stage (preview)</option>
18-
<option value="dev">Dev</option>
19-
<option value="dev-preview">Dev (preview)</option>
20-
<option value="local">Local</option>
21-
</select>
22-
<button id="run-poll" title="Poll for changes of remote settings">Sync</button>
23-
<button id="clear-all-data" title="Clear every local data">Clear all</button>
24-
<div id="environment-error" class="error">⚠️ Environment cannot be changed. Try running Firefox with environment variable <pre>MOZ_REMOTE_SETTINGS_DEVTOOLS=1</pre></div>
25-
</section>
26-
<section id="header-status"">
9+
<section id="header" class="bordered">
10+
<div><!-- make a column -->
11+
<section id="actions">
12+
<button id="run-poll" title="Poll for changes of remote settings">Sync</button>
13+
<button id="clear-all-data" title="Clear every local data">Clear all</button>
14+
<div id="environment-error" class="error">⚠️ Environment cannot be changed. Try running Firefox with environment variable <pre>MOZ_REMOTE_SETTINGS_DEVTOOLS=1</pre></div>
15+
</section>
16+
<section id="options" class="bordered">
17+
<h2>Options</h2>
18+
<select id="environment">
19+
<option value="custom"></option>
20+
<option value="prod">Prod</option>
21+
<option value="prod-preview">Prod (preview)</option>
22+
<option value="stage">Stage</option>
23+
<option value="stage-preview">Stage (preview)</option>
24+
<option value="dev">Dev</option>
25+
<option value="dev-preview">Dev (preview)</option>
26+
<option value="local">Local</option>
27+
</select>
28+
<span>
29+
<input type="checkbox" id="enable-signatures"/>
30+
<label for="enable-signatures">Signatures enabled</label>
31+
</span>
32+
</section>
33+
</div>
34+
<section id="header-status" class="bordered">
2735
<h2>Status</h2>
2836
<div id="polling-error" class="error"></div>
2937
<dl>
@@ -41,12 +49,12 @@ <h2>Status</h2>
4149
<dd id="last-check">N/A</dd>
4250
</dl>
4351
</section>
44-
<section id="sync-history">
52+
<section id="sync-history" class="bordered">
4553
<h2>Sync History</h2>
4654
<ul></ul>
4755
</section>
4856
</section>
49-
<section id="status">
57+
<section id="status" class="bordered">
5058
<table id="status-table">
5159
<thead>
5260
<tr>

extension/content/script.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ async function refreshUI(state) {
6969
environment,
7070
history,
7171
serverSettingIgnored,
72+
signaturesEnabled,
7273
} = state;
7374

7475
showLoading(false);
@@ -111,6 +112,9 @@ async function refreshUI(state) {
111112
historyList.appendChild(entryRow);
112113
});
113114

115+
// Options
116+
document.getElementById("enable-signatures").checked = signaturesEnabled;
117+
114118
// Table of collections.
115119
const tpl = document.getElementById("collection-status-tpl");
116120
const statusTable = document.querySelector("#status table tbody");
@@ -201,6 +205,10 @@ async function main() {
201205
await remotesettings.switchEnvironment(event.target.value);
202206
};
203207

208+
document.getElementById("enable-signatures").onchange = async (event) => {
209+
await remotesettings.enableSignatureVerification(event.target.checked);
210+
};
211+
204212
// Poll for changes button.
205213
document.getElementById("run-poll").onclick = async () => {
206214
showGlobalError(null);

extension/content/style.css

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,23 +47,26 @@ dd {
4747
}
4848

4949
section {
50-
border: 1px solid var(--in-content-border-color);
5150
background-color: var(--in-content-box-background);
5251
padding: 10px;
5352
word-break: break-all;
5453
}
5554

55+
section.bordered {
56+
border: 1px solid var(--in-content-border-color);
57+
}
58+
5659
#header {
5760
display: flex;
5861
gap: 10px;
5962
margin-bottom: 10px;
6063
}
6164

62-
#env-actions {
65+
#options {
6366
min-width: 8em;
6467
}
6568

66-
#env-actions button, #env-actions select {
69+
#options button, #options select, #options span {
6770
display: block;
6871
width: 91%;
6972
margin: 4px 8px;
@@ -87,6 +90,11 @@ section {
8790
flex-grow: 1;
8891
}
8992

93+
#actions {
94+
padding: 0px;
95+
padding-bottom: 10px;
96+
}
97+
9098
#environment {
9199
text-align: center;
92100
}
@@ -184,7 +192,7 @@ button.clear-data {
184192
@media(min-width: 1255px) {
185193
/* When #header-status switches to 2 columns */
186194
#sync-history > ul {
187-
max-height: 7em;
195+
max-height: 8em;
188196
}
189197
}
190198

extension/experiments/remotesettings/api.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const MEGAPHONE_STAGE = "wss://autoconnect.stage.mozaws.net";
1616
async function getState() {
1717
const inspected = await RemoteSettings.inspect();
1818

19-
const { serverURL, previewMode } = inspected;
19+
const { collections, serverURL, previewMode } = inspected;
2020
let environment = "custom";
2121
switch (serverURL) {
2222
case SERVER_PROD:
@@ -57,10 +57,18 @@ async function getState() {
5757
}
5858
}
5959

60+
// If one collection has signature verification enabled, then consider
61+
// it's enabled for all in the UI.
62+
const signaturesEnabled = collections.some(({ collection, bucket }) => {
63+
const c = RemoteSettings(collection, { bucketName: bucket });
64+
return c.verifySignature;
65+
});
66+
6067
return {
6168
...inspected,
6269
environment,
6370
serverSettingIgnored,
71+
signaturesEnabled,
6472
};
6573
}
6674

@@ -156,6 +164,20 @@ var remotesettings = class extends ExtensionAPI {
156164
refreshUI();
157165
},
158166

167+
/**
168+
* enableSignatureVerification() enables or disables signature
169+
* verification on all known collections.
170+
* @param {bool} enabled true to enable, false to disable
171+
*/
172+
async enableSignatureVerification(enabled) {
173+
const { collections } = await RemoteSettings.inspect();
174+
for (const { collection, bucket } of collections) {
175+
RemoteSettings(collection, {
176+
bucketName: bucket,
177+
}).verifySignature = enabled;
178+
}
179+
},
180+
159181
/**
160182
* deleteLocal() deletes the local records of the specified collection.
161183
* @param {String} collection collection name

extension/experiments/remotesettings/schema.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,19 @@
3030
}
3131
]
3232
},
33+
{
34+
"name": "enableSignatureVerification",
35+
"type": "function",
36+
"description": "Enable signatures verification",
37+
"async": true,
38+
"parameters": [
39+
{
40+
"name": "enabled",
41+
"type": "boolean",
42+
"description": "true to enable, false to disable"
43+
}
44+
]
45+
},
3346
{
3447
"name": "deleteLocal",
3548
"type": "function",

0 commit comments

Comments
 (0)