Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable web browser password save

Tags:

jsf

jboss

jsf-2

I have a simple Login page made with JSF 2.0. Usually in every login page the web browser proposes to the user to save his username a password.

I saw in Oracle's web site where user must authenticate that when I enter my username and password the browser do not ask me do I want to save my username and password. Maybe there is a way to disable this from the code of the login page.

Is this possible?

like image 561
Peter Penzov Avatar asked Dec 14 '11 12:12

Peter Penzov


People also ask

How do I stop my browser from saving Passwords?

Method 1: One of the known methods is to use autocomplete attribute to prevent browser to remember the password. In the input field, if we define autocomplete=”off” then many times the input value is not remembered by the browser.

How do I turn off Save password in Chrome?

Another way is to type chrome://settings/passwords in the address bar and press Enter. In the Passwords settings, click or tap on the switch called “Offer to save passwords” to disable it and turn off the Chrome password manager. That was it!


1 Answers

You basically need to add autocomplete="off" attribute to the HTML <form> element. However, this attribute is not supported on the <h:form>. It's only supported on the individual <h:inputText> and <h:inputSecret> components.

So, this should do:

<h:form>
    <h:inputText value="#{auth.username}" required="true" autocomplete="off" />
    <h:inputSecret value="#{auth.password}" required="true" autocomplete="off" />
    <h:commandButton value="Login" action="#{auth.login}" />
    <h:messages />
</h:form>

The new autocomplete attribute on <h:form> is scheduled for JSF 2.2. See also JSF spec issue 418.

Or, if you're using container managed login with j_security_check which requires a plain vanilla HTML <form> anyway, then just add it in there:

<form action="j_security_check" method="post" autocomplete="off">
    <input type="text" name="j_username" />
    <input type="password" name="j_password" />
    <input type="submit" value="Login" />
</form>

See also:

  • <h:inputText> tag documentation (mentions autocomplete attribute)
  • <h:inputSecret> tag documentation (mentions autocomplete attribute)
like image 98
BalusC Avatar answered Oct 04 '22 17:10

BalusC