LoginManager

<<

Stefanvd

Posts: 39

Joined: Thu Sep 30, 2010 2:00 pm

Post Sun Apr 01, 2012 10:47 am

LoginManager

Hi,

I try to convert the default option setting for "password" to the login manager, but i got a problem.
https://developer.mozilla.org/en/XPCOM_ ... a_password

what do my addon?
-> when i click on a button. It lock the page.
When i click back on the button, it show me a inputbox to enter my password.

  Code:
// get password from firefox built in
var hostname = "chrome://addonname";
var formSubmitURL = null;
var httprealm = 'Addon login';
var username = 'user';
try {
    var loginManager = Components.classes["@mozilla.org/login-manager;1"]
                           .getService(Components.interfaces.nsILoginManager);
    var logins = loginManager.findLogins({}, hostname, formSubmitURL, httprealm);
    for (var i = 0; i < logins.length; i++) {
      if (logins[i].username == username) { 
         enterpassword = logins[i].password;
         break;
      } 
    }

catch(ex) {
enterpassword = response.enterpassword; // old
}   


Problem:
It doesn't work on all websites, only on this "chrome://addonname" website it can unlock the page.
I need something that work on all website, that it doesn't check the current URL.


Kind Regards,
Stefan
<<

jorge-villalobos

AMO Administrator

Posts: 3005

Joined: Tue Sep 29, 2009 7:30 pm

Location: San José, Costa Rica

Post Tue Apr 03, 2012 3:32 pm

Re: LoginManager

I don't understand what you're trying to do here. Is it just trying to get a password you stored for your add-on? Or is it a password from a website?

And what do you mean when you say that the page is locked?
<<

Stefanvd

Posts: 39

Joined: Thu Sep 30, 2010 2:00 pm

Post Tue Apr 03, 2012 3:43 pm

Re: LoginManager

In my option page i create a password.
And when i am on a website (example google.com) and i click on my browser addon button.
It show a alert box to type the password. Then type password -> if OK it do something ( a action in my addon).
If wrong password -> ask it again.

Current problem
My addon can current only accept my password if i am on this kind of website chrome://addonname.
Other url give me always a error -> wrong password. But i type sure the password correct.

Just need a code that it not check the URL. The password must work on all website i visited.

Kind Regards,
Stefan
<<

archaeopteryx

AMO Editor

Posts: 1036

Joined: Fri Sep 25, 2009 1:38 pm

Location: Dresden, Germany

Post Sun Apr 08, 2012 6:06 am

Re: LoginManager

Does your script run in chrome scope and not in content? What would explain why it only works for the chrom:// page.
<<

Stefanvd

Posts: 39

Joined: Thu Sep 30, 2010 2:00 pm

Post Sun Apr 08, 2012 6:31 am

Re: LoginManager

archaeopteryx wrote:Does your script run in chrome scope and not in content? What would explain why it only works for the chrom:// page.


The code is in a injected script, i mean when i click on the button. It tell my main.js script to excute the script.js on the current page.

And why it only work on chrome:// because it check the hostname. If current page is the same as the hostname.
(need to work on all website i visited)

Kind Regards,
Stefan
<<

archaeopteryx

AMO Editor

Posts: 1036

Joined: Fri Sep 25, 2009 1:38 pm

Location: Dresden, Germany

Post Mon Apr 09, 2012 2:36 am

Re: LoginManager

You bind the password to chrome://addonname, so trying to use the same login credentials on a different host doesn't work.
<<

Stefanvd

Posts: 39

Joined: Thu Sep 30, 2010 2:00 pm

Post Mon Apr 09, 2012 2:56 am

Re: LoginManager

That does not work.

Need a code that it doesn't check the hostname or form action.
https://developer.mozilla.org/en/XPCOM_ ... a_password

But i type both "null" (the hostname and form action), then nothing work.

Kind Regards,
Stefan
<<

archaeopteryx

AMO Editor

Posts: 1036

Joined: Fri Sep 25, 2009 1:38 pm

Location: Dresden, Germany

Post Wed Apr 11, 2012 4:57 am

Re: LoginManager

As far as I understand you, the script which you inject into the web page doesn't always check for the password of chrome://addonanme, but uses the current page. This is the issue you have to fix. I don't know if you can use the login notification bar for this.
<<

Stefanvd

Posts: 39

Joined: Thu Sep 30, 2010 2:00 pm

Post Wed Apr 11, 2012 5:38 am

Re: LoginManager

It's for this extension:
https://addons.mozilla.org/en-US/firefo ... l-toprated

The addon reviewer has suggest me this:
"
We recommend that you use the Login Manager instead (https://developer.mozilla.org/en/XPCOM_ ... ginManager). This gives users more choice over what is stored, and some additional security to the stored data. Thank you!
"
Inside my option page, there is a option "password".
<<

archaeopteryx

AMO Editor

Posts: 1036

Joined: Fri Sep 25, 2009 1:38 pm

Location: Dresden, Germany

Post Wed Apr 11, 2012 6:35 am

Re: LoginManager

So you run light.js in a sandbox on the tab. I am not experienced with XPCNativeWrappers, but does it fail do access the login manager because this is a sandbox? Is there something in the error console with javascript.options.showInConsole set to true if you try to retrieve the password on a web page?
<<

Stefanvd

Posts: 39

Joined: Thu Sep 30, 2010 2:00 pm

Post Wed Apr 11, 2012 6:56 am

Re: LoginManager

javascript.options.showInConsole is true here on my firefox.
But receive no (javascript) error when i type the password correct. (but doesn't unlock the black)
<<

eviljeff

AMO Senior Editor

Posts: 317

Joined: Wed Sep 30, 2009 12:40 am

Location: Sheffield, UK

Post Fri Apr 13, 2012 9:45 am

Re: LoginManager

Hi,
can you point to where you save the password in the preferences at the moment?
thanks.
<<

Stefanvd

Posts: 39

Joined: Thu Sep 30, 2010 2:00 pm

Post Fri Apr 13, 2012 10:20 am

Re: LoginManager

Current the save code part is in the option.js and saved current in chrome://TurnOfftheLights. (see option.js -> line236 for read and 126 line for save)
And read password in light.js on line 856.

Test this version v2.0.0.81 TEST.
http://code.google.com/p/turnofftheligh ... akechanges
Go to my option page, and enable the option "password" type example 123
Then if you click on the lamp on that page you can unlock the dark.
And if you go to about:home i type the password correct but doesn't remove the dark.
<<

eviljeff

AMO Senior Editor

Posts: 317

Joined: Wed Sep 30, 2009 12:40 am

Location: Sheffield, UK

Post Mon Apr 16, 2012 4:06 am

Re: LoginManager

Its because you've not replaced the part of the code where you read the password preference, but instead replaced where the password value is read from the response object. Accessing the LoginManager there fails for the same reason that reading the preference would fail there - its in content rather than chrome scope. You need to be reading the password from the LoginManager and then setting the value enterpassword in your response object.
<<

Stefanvd

Posts: 39

Joined: Thu Sep 30, 2010 2:00 pm

Post Mon Apr 16, 2012 6:56 am

Re: LoginManager

example in code?
For me, i doesn't know what must be changed. The option.js?
<<

eviljeff

AMO Senior Editor

Posts: 317

Joined: Wed Sep 30, 2009 12:40 am

Location: Sheffield, UK

Post Mon Apr 16, 2012 7:19 am

Re: LoginManager

main.js, where you set the value enterpassword in your response object. I don't really know what other example code I can include.
<<

Stefanvd

Posts: 39

Joined: Thu Sep 30, 2010 2:00 pm

Post Mon Apr 16, 2012 8:21 am

Re: LoginManager

in the main.js -> enterpassword is the old way (if a firefox user doesn't got this firefox feature. It catch that old way)
Mark it as comment // , it doesn't get the password from there.
The problem still the same.

Return to Extension Development

Who is online

Users browsing this forum: No registered users

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
CA Gen2 style designed by Vjacheslav Trushkin.