Merge pull request #409 from UMD-ARLIS/feat/tabId
Feature: Adding tabId to log
diff --git a/build/UserALEWebExtension/background.js b/build/UserALEWebExtension/background.js
index 3003704..82a41c0 100644
--- a/build/UserALEWebExtension/background.js
+++ b/build/UserALEWebExtension/background.js
@@ -1128,6 +1128,7 @@
useraleConfig: {
url: 'http://localhost:8000',
userId: 'pluginUser',
+ authHeader: null,
toolName: 'useralePlugin',
version: version
}
@@ -1144,11 +1145,6 @@
}
browser.runtime.onMessage.addListener(function (message, sender, sendResponse) {
switch (message.type) {
- case CONFIG_CHANGE:
- options(message.payload);
- dispatchTabMessage(message);
- break;
-
// Handles logs rerouted from content and option scripts
case ADD_LOG:
var log$1 = message.payload;
@@ -1157,6 +1153,11 @@
}
log(log$1);
break;
+ case CONFIG_CHANGE:
+ console.log(message);
+ options(message.payload);
+ dispatchTabMessage(message);
+ break;
default:
console.log('got unknown message type ', message);
}
diff --git a/build/UserALEWebExtension/options.js b/build/UserALEWebExtension/options.js
index 322c1e9..8528ad8 100644
--- a/build/UserALEWebExtension/options.js
+++ b/build/UserALEWebExtension/options.js
@@ -1129,25 +1129,22 @@
addCallbacks({
reroute: rerouteLog
});
-function setConfig(e) {
+function setConfig() {
+ var config = {
+ url: document.getElementById("url").value,
+ userId: document.getElementById("user").value,
+ toolName: document.getElementById("tool").value,
+ version: document.getElementById("version").value
+ };
+
+ // Set a basic auth header if given credentials.
+ var password = document.getElementById("password").value;
+ if (config.userId && password) {
+ config.authHeader = "Basic " + btoa("".concat(config.userId, ":").concat(password));
+ }
browser.storage.local.set({
- useraleConfig: {
- url: document.getElementById("url").value,
- userId: document.getElementById("user").value,
- toolName: document.getElementById("tool").value,
- version: document.getElementById("version").value
- }
+ useraleConfig: config
}, function () {
- getConfig();
- });
-}
-function getConfig() {
- browser.storage.local.get("useraleConfig", function (res) {
- var config = res.useraleConfig;
- document.getElementById("url").value = config.url;
- document.getElementById("user").value = config.userId;
- document.getElementById("tool").value = config.toolName;
- document.getElementById("version").value = config.version;
options(config);
browser.runtime.sendMessage({
type: CONFIG_CHANGE,
@@ -1155,7 +1152,17 @@
});
});
}
-document.addEventListener('DOMContentLoaded', getConfig);
+function getConfig() {
+ browser.storage.local.get("useraleConfig", function (res) {
+ var config = res.useraleConfig;
+ options(config);
+ document.getElementById("url").value = config.url;
+ document.getElementById("user").value = config.userId;
+ document.getElementById("tool").value = config.toolName;
+ document.getElementById("version").value = config.version;
+ });
+}
+document.addEventListener("DOMContentLoaded", getConfig);
document.addEventListener("submit", setConfig);
/* eslint-enable */
diff --git a/build/UserALEWebExtension/optionsPage.html b/build/UserALEWebExtension/optionsPage.html
index 6a49db3..ff92cf0 100644
--- a/build/UserALEWebExtension/optionsPage.html
+++ b/build/UserALEWebExtension/optionsPage.html
@@ -25,18 +25,18 @@
<body>
<h1>Options</h1>
<form>
- <label>User ALE Server Host:</label>
+ <label>Logging Endpoint URL:</label>
<input id="url"/>
<br/>
-
- <label>User ALE Client Script:</label>
- <input id="clientScript"/>
- <br/>
<label>User:</label>
<input id="user"/>
<br/>
+ <label>Password:</label>
+ <input type="password" id="password"/>
+ <br/>
+
<label>Tool Name:</label>
<input id="tool"/>
<br/>
diff --git a/src/UserALEWebExtension/background.js b/src/UserALEWebExtension/background.js
index 02aec1a..9e70d06 100644
--- a/src/UserALEWebExtension/background.js
+++ b/src/UserALEWebExtension/background.js
@@ -27,6 +27,7 @@
const defaultConfig = {useraleConfig: {
url: 'http://localhost:8000',
userId: 'pluginUser',
+ authHeader: null,
toolName: 'useralePlugin',
version: userale.version,
}};
@@ -45,11 +46,6 @@
browser.runtime.onMessage.addListener(function (message, sender, sendResponse) {
switch (message.type) {
- case MessageTypes.CONFIG_CHANGE:
- userale.options(message.payload)
- dispatchTabMessage(message);
- break;
-
// Handles logs rerouted from content and option scripts
case MessageTypes.ADD_LOG:
let log = message.payload;
@@ -59,6 +55,12 @@
userale.log(log);
break;
+ case MessageTypes.CONFIG_CHANGE:
+ console.log(message);
+ userale.options(message.payload);
+ dispatchTabMessage(message);
+ break;
+
default:
console.log('got unknown message type ', message);
}
diff --git a/src/UserALEWebExtension/messageTypes.js b/src/UserALEWebExtension/messageTypes.js
index 8eaedbc..e8796f1 100644
--- a/src/UserALEWebExtension/messageTypes.js
+++ b/src/UserALEWebExtension/messageTypes.js
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-var prefix = 'USERALE_';
+const prefix = 'USERALE_';
-export var CONFIG_CHANGE = prefix + 'CONFIG_CHANGE';
-export var ADD_LOG = prefix + 'ADD_LOG';
+export const CONFIG_CHANGE = prefix + 'CONFIG_CHANGE';
+export const ADD_LOG = prefix + 'ADD_LOG';
diff --git a/src/UserALEWebExtension/options.js b/src/UserALEWebExtension/options.js
index dbb06ea..b2ecbdb 100644
--- a/src/UserALEWebExtension/options.js
+++ b/src/UserALEWebExtension/options.js
@@ -22,34 +22,42 @@
userale.addCallbacks({reroute: rerouteLog});
-function setConfig(e) {
- browser.storage.local.set(
- {useraleConfig: {
- url: document.getElementById("url").value,
- userId: document.getElementById("user").value,
- toolName: document.getElementById("tool").value,
- version: document.getElementById("version").value
- }},
- () => {getConfig()}
- );
+// TODO: Warn users when setting credentials with unsecured connection.
+const mitmWarning = "Setting credentials with http will expose you to a MITM attack. Are you sure you want to continue?";
+
+function setConfig() {
+ let config = {
+ url: document.getElementById("url").value,
+ userId: document.getElementById("user").value,
+ toolName: document.getElementById("tool").value,
+ version: document.getElementById("version").value
+ };
+
+ // Set a basic auth header if given credentials.
+ const password = document.getElementById("password").value;
+ if(config.userId && password) {
+ config.authHeader = "Basic " + btoa(`${config.userId}:${password}`);
+ }
+
+ browser.storage.local.set({useraleConfig: config}, () => {
+ userale.options(config);
+ browser.runtime.sendMessage({ type: MessageTypes.CONFIG_CHANGE, payload: config });
+ });
}
function getConfig() {
browser.storage.local.get("useraleConfig", (res) => {
let config = res.useraleConfig;
+ userale.options(config);
document.getElementById("url").value = config.url;
document.getElementById("user").value = config.userId;
document.getElementById("tool").value = config.toolName;
document.getElementById("version").value = config.version;
-
- userale.options(config);
- browser.runtime.sendMessage({ type: MessageTypes.CONFIG_CHANGE, payload: config });
-
});
}
-document.addEventListener('DOMContentLoaded', getConfig);
+document.addEventListener("DOMContentLoaded", getConfig);
document.addEventListener("submit", setConfig);
/* eslint-enable */
\ No newline at end of file
diff --git a/src/UserALEWebExtension/optionsPage.html b/src/UserALEWebExtension/optionsPage.html
index 6a49db3..ff92cf0 100644
--- a/src/UserALEWebExtension/optionsPage.html
+++ b/src/UserALEWebExtension/optionsPage.html
@@ -25,18 +25,18 @@
<body>
<h1>Options</h1>
<form>
- <label>User ALE Server Host:</label>
+ <label>Logging Endpoint URL:</label>
<input id="url"/>
<br/>
-
- <label>User ALE Client Script:</label>
- <input id="clientScript"/>
- <br/>
<label>User:</label>
<input id="user"/>
<br/>
+ <label>Password:</label>
+ <input type="password" id="password"/>
+ <br/>
+
<label>Tool Name:</label>
<input id="tool"/>
<br/>