Question

I am writing a Firefox add-on for Linux users to pass credentials for NTLM authenticated sites.some what similar to AutoAuth which is written using XUL framework

https://addons.mozilla.org/en-us/firefox/addon/autoauth/

my question is how to access Authentication Dialog using Firefox SDK?

Was it helpful?

Solution

With the add-on sdk you don't have XUL overlays so only thing you really can do outside of that is to use the window watcher. Since popup windows are considered windows you'll see them in the onTrack function when they popup in the browser.

This example code watches windows looking for the window location chrome://global/content/commonDialog.xul which is similar to what the autoauth add-on is doing. That dialog is used for a number of auth questions so you'll have to do the additional work of detecting NTLM auth.

var { isBrowser } = require("sdk/window/utils");
var delegate = {
  onTrack: function (window) {
    if (!isBrowser(window) && window.location === "chrome://global/content/commonDialog.xul") {
       // this could be the window we're looking for modify it using it's window.document
    }
  },
  onUntrack: function (window) {
    if (!isBrowser(window) && window.location === "chrome://global/content/commonDialog.xul") {
       // undo the modifications you did
    }
  }
};
var winUtils = require("window-utils");
var tracker = new winUtils.WindowTracker(delegate);

With this code you're pretty much at the point of the autoauth add-on's load() function. You can use window.document.getElementById() to access the DOM of that window and alter the elements within it.

NOTE That the window-utils module is deprecated so you'll need to keep up with the SDK as they move from that module to (hopefully) something else similar.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top