Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Custom Authentication prompt dialog ONLY FOR ONE REQUEST?

13 views
Skip to first unread message

Lev Serebryakov

unread,
Mar 24, 2007, 4:26:51 AM3/24/07
to dev-pl...@lists.mozilla.org
Hello dev-platform,

I'm writing extension for FF/Mozilla, which communicate with some service with XML-RPC like protocol.
Service can be setted up in different ways (it is whole class of intranet/internet services, not one specific, like gmail): with or without HTTP authorization, with different realms, and different auth mechanisms.
I'm using nsIXMLHttpRequest.
If authentication is configured, standard "Username/Password" dialog is popping out. But at this point (browser starts and extension ask for configuration from service) it is rather surprise for user: she doesn't go any URL and browser asks for Username/Password with generic dialog (and, very often, realm is nott to helpful too, because many admins forget to set meaningful realm name)!
Is it possible to replace this dialog for my request? I want to create custom dialog, which explain WHY exactly these username/password are asked at this time.

--
Best regards,
Lev mailto:l...@serebryakov.spb.ru

Lev Serebryakov

unread,
Mar 24, 2007, 7:37:19 AM3/24/07
to Lev Serebryakov, dev-pl...@lists.mozilla.org
Hello Lev,

Saturday, March 24, 2007, 11:26:51 AM, you wrote:

LS> Is it possible to replace this dialog for my request? I want to
LS> create custom dialog, which explain WHY exactly these username/password
LS> are asked at this time.
I'm found answer: I need to set channel.callbacks and answer to request for nsIAuthPrompter. It works.

Alexander N. Treyner

unread,
Mar 26, 2007, 4:37:01 AM3/26/07
to
Hi,
Could you give example of using channel.callbacks ?
I also seeking the way to silent authentication method.
I need to implement it for Windows NT Authentication.

Thanks.

Alex

Nickolay Ponomarev

unread,
Mar 26, 2007, 4:52:31 AM3/26/07
to Alexander N. Treyner, dev-pl...@lists.mozilla.org
Not an example, but Lev probably meant to set xmlhttprequest's
|notificationCallbacks| property to an object implementing
nsIInterfaceRequestor.

An example getInterface implementation creating the default authprompt is here:
http://lxr.mozilla.org/mozilla/source/toolkit/mozapps/update/src/nsUpdateService.js.in#2563

You need to return your own implementation of nsIAuthPrompt from your
getInterface instead.

Nickolay

> _______________________________________________
> dev-platform mailing list
> dev-pl...@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-platform
>

Lev A. Serebryakov

unread,
Mar 26, 2007, 5:16:45 AM3/26/07
to Nickolay Ponomarev, Alexander N. Treyner, dev-pl...@lists.mozilla.org
Nickolay Ponomarev wrote:

> Not an example, but Lev probably meant to set xmlhttprequest's
> |notificationCallbacks| property to an object implementing
> nsIInterfaceRequestor.
>
> An example getInterface implementation creating the default authprompt is here:
> http://lxr.mozilla.org/mozilla/source/toolkit/mozapps/update/src/nsUpdateService.js.in#2563
>
> You need to return your own implementation of nsIAuthPrompt from your
> getInterface instead.

Exactly.

--
// Lev Serebryakov

Alexander N. Treyner

unread,
Mar 26, 2007, 5:34:34 AM3/26/07
to
I will be a more specific.
I want to send user name and password, that I take from Password
Manager, without popping up any prompts.
Is it possible?
I'm authenticates with web site using Windows NT authentication, so
sending user name and password as parameters of xmlhttprequest does not
work, and by default fall back to default prompt.

Thanks,

Alex.

Lev A. Serebryakov

unread,
Mar 26, 2007, 5:43:34 AM3/26/07
to Alexander N. Treyner, dev-pl...@lists.mozilla.org
Alexander N. Treyner wrote:
> I will be a more specific.
> I want to send user name and password, that I take from Password
> Manager, without popping up any prompts.
> Is it possible?
Yes. Yous should implements nsIAuthPrompt interface and returns
username/password from promptUsernameAndPassword method. Way you obtain
username/password is your problem: you can show dialog, you can read it
from Password Manager, etc.

--
// Lev Serebryakov

Alexander N. Treyner

unread,
Mar 26, 2007, 5:47:30 AM3/26/07
to

Thanks,

I will try.

0 new messages