Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "Jetty/Howto/Secure Passwords"
m |
|||
(2 intermediate revisions by 2 users not shown) | |||
Line 2: | Line 2: | ||
| introduction = | | introduction = | ||
− | There are many places in Jetty where you need to use and store a password, for example the SSL | + | There are many places in Jetty where you need to use and store a password, for example the SSL connector keystore password and user passwords in realms. You can store passwords as ''clear text, obfuscated, checksummed'' or ''encrypted,'' in order of increasing security. |
− | The choice of method | + | The choice of method to secure a password depends on where you are using the password. In some cases such as keystore passwords and digest authentication, the system must retrieve the original password, which requires the obfuscation method. The drawback of the obfuscation algorithm is that it protects passwords from casual viewing only. |
− | + | When the stored password is compared to one a user enters, the handling code can apply the same algorithm that secures the stored password to the user input and compare results, making password authentication more secure. | |
| steps = | | steps = | ||
− | Jetty provides a [http://dev.eclipse.org/viewcvs/index.cgi/jetty/trunk/jetty-http/src/main/java/org/eclipse/jetty/http/security/Password.java?root=RT_Jetty&view=log password utility] that can | + | Jetty provides a [http://dev.eclipse.org/viewcvs/index.cgi/jetty/trunk/jetty-http/src/main/java/org/eclipse/jetty/http/security/Password.java?root=RT_Jetty&view=log password utility] that you can use to generate all varieties of passwords. |
Run it without arguments to see usage instructions: | Run it without arguments to see usage instructions: | ||
+ | |||
+ | <strong>Version 8.1 and above -- although this works on 7.6.7 as well</strong> | ||
+ | > java -cp lib/jetty-util-xxx.jar org.eclipse.jetty.util.security.Password | ||
+ | Usage - java org.eclipse.jetty.util.security.Password [<user>] <password> | ||
+ | |||
+ | |||
+ | <strong>Below version 8.1</strong> | ||
> java -cp lib/jetty-http-xxx.jar:lib/jetty-util-xxx.jar org.eclipse.jetty.http.security.Password | > java -cp lib/jetty-http-xxx.jar:lib/jetty-util-xxx.jar org.eclipse.jetty.http.security.Password | ||
Usage - java org.eclipse.jetty.http.security.Password [<user>] <password> | Usage - java org.eclipse.jetty.http.security.Password [<user>] <password> | ||
− | where | + | where <tt>-xxx</tt> signifies the version of Jetty that you have installed. |
− | For example, to generate a secured version of the password | + | For example, to generate a secured version of the password ''blah'' for the user ''me'', enter: |
> java -cp lib/jetty-http-xxx.jar:lib/jetty-util-xxx.jar org.mortbay.jetty.security.Password me blah | > java -cp lib/jetty-http-xxx.jar:lib/jetty-util-xxx.jar org.mortbay.jetty.security.Password me blah | ||
blah | blah | ||
Line 33: | Line 40: | ||
me: CRYPT:me/ks90E221EY | me: CRYPT:me/ks90E221EY | ||
− | {{tip|Don't forget to also copy the ''OBF:'', ''MD5:'' or ''CRYPT:'' prefix on the generated password. | + | {{tip|Don't forget to also copy the ''OBF:'', ''MD5:'' or ''CRYPT:'' prefix on the generated password. Jetty cannot use it if you don't. }} |
| category = [[Category:Jetty Howto]] | | category = [[Category:Jetty Howto]] | ||
}} | }} |
Revision as of 08:42, 2 October 2012
Introduction
There are many places in Jetty where you need to use and store a password, for example the SSL connector keystore password and user passwords in realms. You can store passwords as clear text, obfuscated, checksummed or encrypted, in order of increasing security.
The choice of method to secure a password depends on where you are using the password. In some cases such as keystore passwords and digest authentication, the system must retrieve the original password, which requires the obfuscation method. The drawback of the obfuscation algorithm is that it protects passwords from casual viewing only.
When the stored password is compared to one a user enters, the handling code can apply the same algorithm that secures the stored password to the user input and compare results, making password authentication more secure.
Steps
Jetty provides a password utility that you can use to generate all varieties of passwords.
Run it without arguments to see usage instructions:
Version 8.1 and above -- although this works on 7.6.7 as well
> java -cp lib/jetty-util-xxx.jar org.eclipse.jetty.util.security.Password Usage - java org.eclipse.jetty.util.security.Password [<user>] <password>
Below version 8.1
> java -cp lib/jetty-http-xxx.jar:lib/jetty-util-xxx.jar org.eclipse.jetty.http.security.Password Usage - java org.eclipse.jetty.http.security.Password [<user>] <password>
where -xxx signifies the version of Jetty that you have installed.
For example, to generate a secured version of the password blah for the user me, enter:
> java -cp lib/jetty-http-xxx.jar:lib/jetty-util-xxx.jar org.mortbay.jetty.security.Password me blah blah OBF:20771x1b206z MD5:639bae9ac6b3e1a84cebb7b403297b79 CRYPT:me/ks90E221EY
Now you can cut and paste whichever secure version you choose into your configuration file or java code.
For example, the last line below shows you how you would cut and paste the encrypted password generated above into the properties file for a HashUserRealm:
admin: CRYPT:ad1ks..kc.1Ug,server-administrator,content-administrator,admin other: OBF:1xmk1w261u9r1w1c1xmq guest: guest,read-only me: CRYPT:me/ks90E221EY