mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2024-12-30 10:47:08 -06:00
b4e19509c0
The extension should replace signed code (configure.jar) used for Firefox configuration. Using privileged code is not possible since Firefox 15 [1] [2]. Extension is bootstrapped which means it can be used without browser restart on Firefox 4 and later. How it works: Extension listens on each page's document element for event 'kerberos-auth-config' which should be raised on custom data element. Communication data is transferred through data element's attributes [3]. The only required attribute is 'method'. Currently there are two possible values: 'configure' and 'can_configure'. 'can_configure' method serves for detecting if the extension is installed. 'configure' method does the actual configuration. Possible optional options for 'configure' can be found in kerberosauth.js:kerberosauth.config_options. Currently they are: 'referer', 'native_gss_lib', 'trusted_uris', 'allow_proxies'. Result of a method is stored in data element's 'answer' attribute. When 'configure' method is used, the extension asks the user if he wants to configure the browser, it should prevent silent configuration by malicious pages. Possible enhancement: * add UI for manual edit * more configurations ie. for gss_lib, sspi (good with UI or with enhanced config page) * introspection of client (read ipa client install config and such) Ticket: https://fedorahosted.org/freeipa/ticket/3094 [1] https://bugzilla.mozilla.org/show_bug.cgi?id=546848 [2] https://bugzilla.mozilla.org/show_bug.cgi?id=757046 [3] https://developer.mozilla.org/en-US/docs/Code_snippets/Interaction_between_privileged_and_non-privileged_pages
88 lines
2.9 KiB
JavaScript
88 lines
2.9 KiB
JavaScript
// Heavily inspired by Dave Townsend's post:
|
|
// Playing with windows in restartless (bootstrapped) extensions
|
|
// http://www.oxymoronical.com/blog/2011/01/Playing-with-windows-in-restartless-bootstrapped-extensions
|
|
|
|
const Cc = Components.classes;
|
|
const Ci = Components.interfaces;
|
|
const Cu = Components.utils;
|
|
|
|
var WindowListener = {
|
|
|
|
setupBrowserUI: function(domWindow) {
|
|
var doc = domWindow.document;
|
|
domWindow.kerberosauth_listener = kerberosauth_listener(domWindow);
|
|
doc.addEventListener('kerberos-auth-config', domWindow.kerberosauth_listener, false, true);
|
|
},
|
|
|
|
tearDownBrowserUI: function(domWindow) {
|
|
|
|
var doc = domWindow.document;
|
|
doc.removeEventListener('kerberos-auth-config', domWindow.kerberosauth_listener);
|
|
delete domWindow.kerberosauth_listener;
|
|
},
|
|
|
|
// nsIWindowMediatorListener functions
|
|
onOpenWindow: function(xulWindow) {
|
|
// A new window has opened
|
|
var domWindow = xulWindow.QueryInterface(Ci.nsIInterfaceRequestor).
|
|
getInterface(Ci.nsIDOMWindowInternal);
|
|
|
|
// Wait for it to finish loading
|
|
domWindow.addEventListener("load", function listener() {
|
|
domWindow.removeEventListener("load", listener, false);
|
|
|
|
// If this is a browser window then setup its UI
|
|
if (domWindow.document.documentElement.getAttribute("windowtype") === "navigator:browser") {
|
|
WindowListener.setupBrowserUI(domWindow);
|
|
}
|
|
}, false);
|
|
},
|
|
|
|
onCloseWindow: function(xulWindow) {
|
|
},
|
|
|
|
onWindowTitleChange: function(xulWindow, newTitle) {
|
|
}
|
|
};
|
|
|
|
function startup(data, reason) {
|
|
var wm = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator);
|
|
|
|
Cu['import']("chrome://kerberosauth/content/kerberosauth.js");
|
|
|
|
// Get the list of browser windows already open
|
|
var windows = wm.getEnumerator("navigator:browser");
|
|
while (windows.hasMoreElements()) {
|
|
var domWindow = windows.getNext().QueryInterface(Ci.nsIDOMWindow);
|
|
|
|
WindowListener.setupBrowserUI(domWindow);
|
|
}
|
|
|
|
// Wait for any new browser windows to open
|
|
wm.addListener(WindowListener);
|
|
}
|
|
|
|
function shutdown(data, reason) {
|
|
// When the application is shutting down we normally don't have to clean
|
|
// up any UI changes made
|
|
if (reason == APP_SHUTDOWN)
|
|
return;
|
|
|
|
var wm = Cc["@mozilla.org/appshell/window-mediator;1"].
|
|
getService(Ci.nsIWindowMediator);
|
|
|
|
// Get the list of browser windows already open
|
|
var windows = wm.getEnumerator("navigator:browser");
|
|
while (windows.hasMoreElements()) {
|
|
var domWindow = windows.getNext().QueryInterface(Ci.nsIDOMWindow);
|
|
WindowListener.tearDownBrowserUI(domWindow);
|
|
}
|
|
|
|
// Stop listening for any new browser windows to open
|
|
wm.removeListener(WindowListener);
|
|
|
|
Cu.unload("chrome://kerberosauth/content/kerberosauth.js");
|
|
}
|
|
|
|
function install() {}
|
|
function uninstall() {} |