Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 268437

Summary: Prompting for username/password should show if info is already on record and allow editing
Product: [Eclipse Project] Equinox Reporter: Henrik Lindberg <henrik.lindberg>
Component: p2Assignee: Henrik Lindberg <henrik.lindberg>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: john.arthorne, matthew, pascal, susan
Version: 3.5   
Target Milestone: 3.5   
Hardware: All   
OS: All   
Whiteboard:

Description Henrik Lindberg CLA 2009-03-12 16:52:35 EDT
When communicating with repositories that requires authentication, the user is prompted via the IServiceUI.getUsernamePassword method if there is no password on record for the location.

If however, there is a password on record and the authentication still fails, then the user is not made aware of this. 

I propose that the getUserNamePassword method accepts an AuthenticationInfo parameter that can be null, or filled out. The user interface can then decide how to display this information, allow editing, etc.

The AuthenticationInfo should also include the location. 

Let's say "fred/secret" is stored for "http://somewhere.com", and a request is made for "http://somwhere.com/private". The dialog can now show that "fred/secret" in combination with "http;//somwhere.com" was not enough and UI passes back "fred/verysecret" for "http://somewhere.com/private".

If this enabler is implemented, there are various options how to handle the dialog...
Comment 1 John Arthorne CLA 2009-03-13 13:22:19 EDT
Wouldn't this mean p2 is introducing API for retrieving password for a given location? I.e., couldn't someone then hook this method to record/copy people's passwords?
Comment 2 Henrik Lindberg CLA 2009-03-14 19:17:46 EDT
(In reply to comment #1)
> Wouldn't this mean p2 is introducing API for retrieving password for a given
> location? I.e., couldn't someone then hook this method to record/copy people's
> passwords?
> 

Yes, you are right, since it does not know where the service is coming from. When I have written similar things before, the UI was integrated. When using a service, it would be a bad idea to give it non encrypted password.

I still think it is a good idea to show the user that there was something on file that was tried and did not work. It could just send a string like "original-password" and see if it got back the same string after user has edited.

Comment 3 Henrik Lindberg CLA 2009-04-13 08:59:38 EDT
(In reply to comment #1)
> Wouldn't this mean p2 is introducing API for retrieving password for a given
> location? I.e., couldn't someone then hook this method to record/copy people's
> passwords?
> 
I thought more about this, and it is not more dangerous to pass the password on file to the UI than it is to rely on a service to get the password in the first place. A malicious plugin could provide a UI that sends of the passwords as they are entered. The UI service that prompts the user must be trusted not to reveal authentication information.
Comment 4 Henrik Lindberg CLA 2009-04-23 07:39:31 EDT
*** Bug 273319 has been marked as a duplicate of this bug. ***
Comment 5 Henrik Lindberg CLA 2009-04-26 13:13:11 EDT
I think IServiceUI.getUsernamePassword, should take extra parameters to make it possible for the UI to explain why the user is asked to authenticate. I think location and both username/password should be passed, but if there are strong feelings about the password, it can be omitted. A code should also be passed that indicates one of:
- failed login without username/password (nothing was saved)
- failed login using stored username/password
- failed login using username/password just entered by the user

Comment 6 John Arthorne CLA 2009-04-27 13:26:30 EDT
How about just passing in an optional String, which would be the human-readable description of why the authentication failed (incorrectly entered password, incorrect stored password, etc). That keeps the API and UI simple while allowing us to tweak the level of detail shown in the message. 

I still think revealing the entered/stored password in this message would be bad - I don't think I've ever seen an authentication UI that showed me a password (valid or otherwise) in plain-text.
Comment 7 Henrik Lindberg CLA 2009-04-27 15:25:22 EDT
(In reply to comment #6)
> How about just passing in an optional String, which would be the human-readable
> description of why the authentication failed (incorrectly entered password,
> incorrect stored password, etc). That keeps the API and UI simple while
> allowing us to tweak the level of detail shown in the message. 
> 
Sure, that works too - just thought that you want the UI/human concern in the UI. It is more difficult to write a test for different cases for instance if having to parse a message. How about a code and a message :)

> I still think revealing the entered/stored password in this message would be
> bad - I don't think I've ever seen an authentication UI that showed me a
> password (valid or otherwise) in plain-text.
> 
Authentication UIs typically shows stars, but you get a sense that there is a password and how long it is. (The mac has a very nice keystore where it is possible to reveal the password if you know the keystore's password).

Anyway, the password is not the most important - the URI and the reason are.
I think a fake password can be passed instead of the real - it is then possible to see if the user did change the password.
Comment 8 John Arthorne CLA 2009-04-27 15:48:17 EDT
> How about a code and a message :)

Sure. A good way to make this evolvable without breaking API again is to pass in an object (AuthenticationRequest or some such). That way we can add extra fields to it in the future and never have to break the API again.
Comment 9 Susan McCourt CLA 2009-04-27 15:49:51 EDT
Henrick, as discussed on the p2 call, if you provide the new API on the IServiceUI side I can add the string to the dialog and also clean up the appearance/layout, etc.
Comment 10 Susan McCourt CLA 2009-04-27 15:53:26 EDT
One more thing...I'm assuming that for 3.5 we are just going to show whatever string was passed in.  

A code would be useful for the future if we decide to provide links to alternate tasks (go to the secure store prefs, delete this repo, or whatever...)

(And sorry for misspelling your name above, Henrik!)
Comment 11 Henrik Lindberg CLA 2009-04-27 20:37:27 EDT
Fixed - released to HEAD.

Different messages are shown depending on if the name/password was stored, if it comes from the cache, or if being the first time it is requested.

(Hint, try it with the testserver: http://localhost:8080/proxy/never, as this will prompt for ever).

I decided to actually pass the password to the service - it is not shown in clear text. My reasoning is that it is the same service that would be used for entering passwords in the first place - so all passwords will have been available to this service. If a malicious user can replace this service they can still get all passwords entered by the user by stealing them as they are (re)-entered.

I think this implementation is much more user friendly, even if you can't see the actual password you see if you made a stupid mistake (password is too long or short) - and it is clear that the system knew about some password.


Comment 12 Henrik Lindberg CLA 2009-04-28 07:38:19 EDT
See Bug 274007 for future work (3.6) i this area.