You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Guojun Zhu <zg...@gmail.com> on 2009/05/06 21:05:53 UTC
Form-based Container Security with SSL
Hi,
We had a small web application on tomcat 5.5. We use tomcat realm
(MD5 digest) with the form-based login. I have a few questions on
this.
1. When we use http, does the form-based login page send the username
and password plainly or in the digested form?
2. We set up the ssl in 8443 port. All links in our application are
relative link without the specified scheme. So currently all the
links (including login page) go either through normal http or
encrypted https. Is there anyway to limit the ssl only for the login
page alone and make sure login page always go through ssl? Rest pages
are really fairly low-risk stuff and we do not worry about the leak on
them.
Our site (http://sulfite.lis.illinois.edu:8080/InformProjectDev,
https://sulfite.lis.illinois.edu:8443/InformProjectDev)
Thanks.
Sincerely
Zhu, Guojun
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Form-based Container Security with SSL
Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Martin,
On 5/6/2009 10:26 PM, Martin Gainty wrote:
> With redirect-prefix, instead of executing baz action's execute() method (by
> default it isn't overriden in struts.xml to be something else), [...]
What is your obsession with Struts these days? It must be 3-6 posts from
you that offer Struts-related "solutions" to problems not involving Struts.
Again, your posts are confusing at best.
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAkoERKYACgkQ9CaO5/Lv0PAENgCfY/9nQ2qwx+zefuaXa1uavDg8
Z3kAoJP35vb6FMMBoKrTOK1rl7pE0Xxc
=a9qD
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
RE: Form-based Container Security with SSL
Posted by Martin Gainty <mg...@hotmail.com>.
Redirect prefix
With redirect-prefix, instead of executing baz action's execute() method (by
default it isn't overriden in struts.xml to be something else), it will get
redirected to, in this case to www.google.com. Internally it uses
ServletRedirectResult to do the task.
<s:form action="baz">
<s:textfield label="Enter your name" name="person.name"/>
<s:submit value="Create person"/>
<s:submit name="redirect:www.google.com" value="Cancel"/>
</s:form>
struts handles all of those contingencies via actionmapper mapping an action/namespace to
handle some known URL
http://struts.apache.org/2.0.14/docs/actionmapper.html
(implementing actionmapper doesnt prevent you from giving chris money)
Martin
______________________________________________
Disclaimer and Confidentiality/Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
This message is confidential. If you should not be the intended receiver, then we ask politely to report. Each unauthorized forwarding or manufacturing of a copy is inadmissible. This message serves only for the exchange of information and has no legal binding effect. Due to the easy manipulation of emails we cannot take responsibility over the the contents.
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.
> Date: Wed, 6 May 2009 21:54:02 -0400
> From: chris@christopherschultz.net
> To: users@tomcat.apache.org
> Subject: Re: Form-based Container Security with SSL
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Guojun,
>
> On 5/6/2009 3:05 PM, Guojun Zhu wrote:
> > We had a small web application on tomcat 5.5. We use tomcat realm
> > (MD5 digest) with the form-based login. I have a few questions on
> > this.
> >
> > 1. When we use http, does the form-based login page send the username
> > and password plainly or in the digested form?
>
> Your web browser will send the credentials in cleartext. The only
> "digest" being used here is the one used to hash the password before it
> is checked against your database (all on the server side).
>
> If you want the password sent securely, you'll need to either use HTTPS
> or use DIGEST authentication, which uses HTTP Auth instead of forms. I
> prefer HTTPS + form over DIGEST, FWIW.
>
> > 2. We set up the ssl in 8443 port. All links in our application are
> > relative link without the specified scheme. So currently all the
> > links (including login page) go either through normal http or
> > encrypted https. Is there anyway to limit the ssl only for the login
> > page alone and make sure login page always go through ssl? Rest pages
> > are really fairly low-risk stuff and we do not worry about the leak on
> > them.
>
> Are you comfortable with the possibility of session hijacking? If so,
> there is a way to do this that I outlined a few weeks ago. Hmm... I
> can't seem to find it in the archives; I'll give you the short-short
> version. Try something like this:
>
> web.xml:
> <form-login-page>/login.jsp</form-login-page>
> ...
> <security-constraint>
> <web-resource-collection>
> <url-pattern>/login.jsp</url-pattern>
> </web-resource-collection>
> <user-data-constraint>
> <transport-guarantee>CONFIDENTIAL</transport-guarantee>
> </user-data-constraint>
> <security-constraint>
>
> login.jsp:
> <%
> Cookie mySessionCookie = ...;
> if(mySessionCookie.isSecure())
> {
> // We don't want a secure session cookie. Kill it,
> // redirect to non-secure page and bounce back.
>
> session.invalidate();
>
> response.sendRedirect(response.encodeRedirectURL(BOUNCE_PAGE));
> }
> %>
>
> Your bounce page should simply create a session and redirect to
> https://yourhost/login.jsp.
>
> You should probably create a filter that watches every URL except your
> login page and drives everything back to HTTP if it finds HTTPS in use.
>
> This may interfere with the container's ability to store and re-play
> requests for protected resources /after/ a successful login. YMMV. If
> you can't get it working using this suggestion, feel free to hire me to
> do it for you ;)
>
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAkoCPzoACgkQ9CaO5/Lv0PAPnwCcC9jIfZ9oc60imAgaw01sfcjJ
> MlEAoIsyPZ9f6dXGo5IInzLXOMxh7vs0
> =9YPw
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
_________________________________________________________________
Hotmail® goes with you.
http://windowslive.com/Tutorial/Hotmail/Mobile?ocid=TXT_TAGLM_WL_HM_Tutorial_Mobile1_052009
RE: Form-based Container Security with SSL
Posted by Martin Gainty <mg...@hotmail.com>.
if your goal is encryption..
i found this explanation from Stanford helpful in understanding kerberos/ssh/ssl
http://pangea.stanford.edu/computerinfo/resources/network/security/safeguards/kerberos.html
HTH
Martin
______________________________________________
Disclaimer and Confidentiality/Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
This message is confidential. If you should not be the intended receiver, then we ask politely to report. Each unauthorized forwarding or manufacturing of a copy is inadmissible. This message serves only for the exchange of information and has no legal binding effect. Due to the easy manipulation of emails we cannot take responsibility over the the contents.
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.
> Date: Mon, 11 May 2009 18:37:22 -0400
> From: chris@christopherschultz.net
> To: users@tomcat.apache.org
> Subject: Re: Form-based Container Security with SSL
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Guojun,
>
> On 5/11/2009 5:49 PM, Guojun Zhu wrote:
> > Dear Chris,
> >
> > Thank you very much. What we really want is that the login
> > username/password communicates encrypted. Everything else can be in
> > clear-text. (We also need the log-out, so I cannot use the digest
> > authentification.)
> >
> >
> >> Showing a non-secure login page isn't a problem, is it? You just need to
> >> make sure that the login form's action is HTTPS and you will get a
> >> secure login.
> >
> > But if this login page is reached by http, will the login
> > username/password be sent out in clear-texted?
>
> The scheme used to access the login page is not relevant to the safety
> of your credentials. Only the scheme used to /submit/ those credentials
> from your login form is relevant.
>
> > Or should I specified the action "j_security_check" as https?
>
> Definitely.
>
> > Then after the authentication,
> > change back to http.
>
> Correct.
>
> > (By changing the secured cookie into unsecured?
> > Where? In every pages as tomcat has redirect the link away from
> > login?)
>
> No, all my suggestions have been to create a non-secure session id
> cookie /before/ authentication occurs. Then you don't have to worry
> about it, later.
>
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAkoIqKIACgkQ9CaO5/Lv0PAifgCdGOhDbM2bEmMyoZUGCKrwSQx5
> Sg0AoJCaYuusBHIS98n8vKRUtalnjQkD
> =OlR2
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
_________________________________________________________________
Windows Live™: Keep your life in sync.
http://windowslive.com/explore?ocid=TXT_TAGLM_BR_life_in_synch_052009
Re: Form-based Container Security with SSL
Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Guojun,
On 5/11/2009 5:49 PM, Guojun Zhu wrote:
> Dear Chris,
>
> Thank you very much. What we really want is that the login
> username/password communicates encrypted. Everything else can be in
> clear-text. (We also need the log-out, so I cannot use the digest
> authentification.)
>
>
>> Showing a non-secure login page isn't a problem, is it? You just need to
>> make sure that the login form's action is HTTPS and you will get a
>> secure login.
>
> But if this login page is reached by http, will the login
> username/password be sent out in clear-texted?
The scheme used to access the login page is not relevant to the safety
of your credentials. Only the scheme used to /submit/ those credentials
from your login form is relevant.
> Or should I specified the action "j_security_check" as https?
Definitely.
> Then after the authentication,
> change back to http.
Correct.
> (By changing the secured cookie into unsecured?
> Where? In every pages as tomcat has redirect the link away from
> login?)
No, all my suggestions have been to create a non-secure session id
cookie /before/ authentication occurs. Then you don't have to worry
about it, later.
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAkoIqKIACgkQ9CaO5/Lv0PAifgCdGOhDbM2bEmMyoZUGCKrwSQx5
Sg0AoJCaYuusBHIS98n8vKRUtalnjQkD
=OlR2
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Form-based Container Security with SSL
Posted by Guojun Zhu <zg...@gmail.com>.
Dear Chris,
Thank you very much. What we really want is that the login
username/password communicates encrypted. Everything else can be in
clear-text. (We also need the log-out, so I cannot use the digest
authentification.)
> Showing a non-secure login page isn't a problem, is it? You just need to
> make sure that the login form's action is HTTPS and you will get a
> secure login.
But if this login page is reached by http, will the login
username/password be sent out in clear-texted? Or should I specified
the action "j_security_check" as https? Then after the authentication,
change back to http. (By changing the secured cookie into unsecured?
Where? In every pages as tomcat has redirect the link away from
login?)
Thank you very much?
Sincerely
Zhu, Guojun
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Form-based Container Security with SSL
Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Guojun,
On 5/8/2009 5:27 PM, Guojun Zhu wrote:
> What do you mean "You want to ensure a session is created in
> non-secure more BEFORE the user submits their credentials."?
Session id cookies are created by Tomcat in either "secure" mode (when
the session is created during a HTTPS request) or non-secure mode (when
the session is created during a HTTP request). If you get a "secure"
cookie, the browser will no longer send it to the server when you go
back to HTTP mode. So, you have to make sure you get a non-secure cookie.
Your options are (as previously stated)
1. Modify the cookie to make sure it's not set to secure=true
or
2. Modify your web application to ensure the session id cookie is
created in non-secure mode. This may require you to expire a
session id cookie that is already in secure mode, redirect to
a non-secure page that creates a new (non-secure) session cookie,
and then redirects to your login page so you can be authenticated
in a secure environment (but still with a non-secure session id
cookie).
> I am sorry, but I am not sure that I understand what you mean. All
> your solutions is to modify the login.jsp. But we have already reach
> there by http unsecurely whenever I try to access any restricted
> pages.
Showing a non-secure login page isn't a problem, is it? You just need to
make sure that the login form's action is HTTPS and you will get a
secure login.
> Furthermore, in your solution, what cookie should I get? Is there any
> special one?
You will always get a cookie with the name JSESSIONID created by Tomcat.
This is the cookie you need to make sure is /not/ in secure mode.
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAkoISRgACgkQ9CaO5/Lv0PAmIACgmgOzZlbJ0ey62HBTW7WRIKV4
MtkAnil4A/2Ra8KEMh/7D3Jy+/ETl1Xe
=4RUF
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Form-based Container Security with SSL
Posted by Guojun Zhu <zg...@gmail.com>.
Dear Chris,
I am sorry, but I am not sure that I understand what you mean. All
your solutions is to modify the login.jsp. But we have already reach
there by http unsecurely whenever I try to access any restricted
pages. I have set things like this with the form authentication as
last post. Am I doing the right thing? Or should I change it to
CONFIDENTIAL?
<security-constraint>
<display-name>normal</display-name>
<web-resource-collection>
<web-resource-name>INFORM project</web-resource-name>
<description/>
<url-pattern>*.do</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
<http-method>HEAD</http-method>
<http-method>PUT</http-method>
<http-method>OPTIONS</http-method>
<http-method>TRACE</http-method>
<http-method>DELETE</http-method>
</web-resource-collection>
<auth-constraint>
<description>user for all pages except the admin and home</description>
<role-name>inform</role-name>
</auth-constraint>
</security-constraint>
What do you mean "You want to ensure a session is created in
non-secure more BEFORE the user
submits their credentials."?
Furthermore, in your solution, what cookie should I get? Is there any
special one?
I am sorry for the naiveness from me. I am also very much willing to
learn a bit more about all these stuff. If there is too much to
explain, could you please point me to some place to start to read and
understand my problem? Thank you and have a great weekend!
Sincerely
Zhu, Guojun
On Fri, May 8, 2009 at 9:48 AM, Christopher Schultz
<ch...@christopherschultz.net> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Guojun,
>
> On 5/8/2009 12:22 AM, Guojun Zhu wrote:
>> Thank you very much. I can get the link redirect. But the tomcat's
>> container security seems to happen before it.
>
> The container's security mechanism will always execute before your code.
> Keep that in mind when designing solutions.
>
>> Here is the stuff in
>> the web.xml. When I type
>> http://localhost:8080/InformProject/pages/login.jsp, it will redirect
>> to https://localhost:8443/..... The browser will alert me because it
>> is self-certified. But when I go other pages, which should bring this
>> login page up, it just bring up the http plain version and bypass this
>> redirection.
>>
>> <web-resource-collection>
>> <web-resource-name>login page</web-resource-name>
>> <url-pattern>/pages/login.jsp</url-pattern>
>> </web-resource-collection>
>> <user-data-constraint>
>> <transport-guarantee>CONFIDENTIAL</transport-guarantee>
>> </user-data-constraint>
>> </security-constraint>
>
> You don't want your login.jsp page to be set to CONFIDENTIAL. You want
> to ensure a session is created in non-secure more BEFORE the user
> submits their credentials. There are a couple of ways to do this:
>
> 1. Have login.jsp redirect to a bounce page in HTTP mode if the session
> cookie is secure (something like:
>
> if(sessionIdCookie.isSecure()) {
> session.invalidate();
> response.sendRedirect(BOUNCE); // use HTTP, not HTTPS
> return;
> }
>
> Then your bounce page does this:
> request.getSession(true);
> response.sendRedirect("/login.jsp");
>
> 2. You could also try, in your login.jsp:
>
> if(sessionIdCookie.isSecure()) {
> sessionIdCookie.setSecure(false);
> response.addCookie(sessionIdCookie);
> }
>
> I only just found the Cookie.setSecure method... I'm not sure how
> browsers deal with a cookie changing secure-ness: you'll have to check.
>
> 3. Have login.jsp check for a (currently) secure request and redirect
> to itself in non-secure mode (after adjusting/deleting the cookie).
> Once in non-secure mode, create a new cookie/session and make sure
> your login form submits to an HTTPS URL.
>
> I would start with #2 and see if that works.
>
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAkoERlAACgkQ9CaO5/Lv0PD6lQCePk/76Ob8J/as0mFPbR0DvGtX
> AmwAnjCb3FIEDe44CAm2D5bXCiufa3Dn
> =beOd
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Form-based Container Security with SSL
Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Guojun,
On 5/8/2009 12:22 AM, Guojun Zhu wrote:
> Thank you very much. I can get the link redirect. But the tomcat's
> container security seems to happen before it.
The container's security mechanism will always execute before your code.
Keep that in mind when designing solutions.
> Here is the stuff in
> the web.xml. When I type
> http://localhost:8080/InformProject/pages/login.jsp, it will redirect
> to https://localhost:8443/..... The browser will alert me because it
> is self-certified. But when I go other pages, which should bring this
> login page up, it just bring up the http plain version and bypass this
> redirection.
>
> <web-resource-collection>
> <web-resource-name>login page</web-resource-name>
> <url-pattern>/pages/login.jsp</url-pattern>
> </web-resource-collection>
> <user-data-constraint>
> <transport-guarantee>CONFIDENTIAL</transport-guarantee>
> </user-data-constraint>
> </security-constraint>
You don't want your login.jsp page to be set to CONFIDENTIAL. You want
to ensure a session is created in non-secure more BEFORE the user
submits their credentials. There are a couple of ways to do this:
1. Have login.jsp redirect to a bounce page in HTTP mode if the session
cookie is secure (something like:
if(sessionIdCookie.isSecure()) {
session.invalidate();
response.sendRedirect(BOUNCE); // use HTTP, not HTTPS
return;
}
Then your bounce page does this:
request.getSession(true);
response.sendRedirect("/login.jsp");
2. You could also try, in your login.jsp:
if(sessionIdCookie.isSecure()) {
sessionIdCookie.setSecure(false);
response.addCookie(sessionIdCookie);
}
I only just found the Cookie.setSecure method... I'm not sure how
browsers deal with a cookie changing secure-ness: you'll have to check.
3. Have login.jsp check for a (currently) secure request and redirect
to itself in non-secure mode (after adjusting/deleting the cookie).
Once in non-secure mode, create a new cookie/session and make sure
your login form submits to an HTTPS URL.
I would start with #2 and see if that works.
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAkoERlAACgkQ9CaO5/Lv0PD6lQCePk/76Ob8J/as0mFPbR0DvGtX
AmwAnjCb3FIEDe44CAm2D5bXCiufa3Dn
=beOd
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Form-based Container Security with SSL
Posted by Guojun Zhu <zg...@gmail.com>.
Dear Chris,
Thank you very much. I can get the link redirect. But the tomcat's
container security seems to happen before it. Here is the stuff in
the web.xml. When I type
http://localhost:8080/InformProject/pages/login.jsp, it will redirect
to https://localhost:8443/..... The browser will alert me because it
is self-certified. But when I go other pages, which should bring this
login page up, it just bring up the http plain version and bypass this
redirection.
<web-resource-collection>
<web-resource-name>login page</web-resource-name>
<url-pattern>/pages/login.jsp</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
<login-config>
<auth-method>FORM</auth-method>
<form-login-config>
<form-login-page>/pages/login.jsp</form-login-page>
<form-error-page>/pages/error.jsp</form-error-page>
</form-login-config>
</login-config>
Sincerely yours
Zhu, Guojun
On Wed, May 6, 2009 at 8:54 PM, Christopher Schultz
<ch...@christopherschultz.net> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Guojun,
>
> On 5/6/2009 3:05 PM, Guojun Zhu wrote:
>> We had a small web application on tomcat 5.5. We use tomcat realm
>> (MD5 digest) with the form-based login. I have a few questions on
>> this.
>>
>> 1. When we use http, does the form-based login page send the username
>> and password plainly or in the digested form?
>
> Your web browser will send the credentials in cleartext. The only
> "digest" being used here is the one used to hash the password before it
> is checked against your database (all on the server side).
>
> If you want the password sent securely, you'll need to either use HTTPS
> or use DIGEST authentication, which uses HTTP Auth instead of forms. I
> prefer HTTPS + form over DIGEST, FWIW.
>
>> 2. We set up the ssl in 8443 port. All links in our application are
>> relative link without the specified scheme. So currently all the
>> links (including login page) go either through normal http or
>> encrypted https. Is there anyway to limit the ssl only for the login
>> page alone and make sure login page always go through ssl? Rest pages
>> are really fairly low-risk stuff and we do not worry about the leak on
>> them.
>
> Are you comfortable with the possibility of session hijacking? If so,
> there is a way to do this that I outlined a few weeks ago. Hmm... I
> can't seem to find it in the archives; I'll give you the short-short
> version. Try something like this:
>
> web.xml:
> <form-login-page>/login.jsp</form-login-page>
> ...
> <security-constraint>
> <web-resource-collection>
> <url-pattern>/login.jsp</url-pattern>
> </web-resource-collection>
> <user-data-constraint>
> <transport-guarantee>CONFIDENTIAL</transport-guarantee>
> </user-data-constraint>
> <security-constraint>
>
> login.jsp:
> <%
> Cookie mySessionCookie = ...;
> if(mySessionCookie.isSecure())
> {
> // We don't want a secure session cookie. Kill it,
> // redirect to non-secure page and bounce back.
>
> session.invalidate();
>
> response.sendRedirect(response.encodeRedirectURL(BOUNCE_PAGE));
> }
> %>
>
> Your bounce page should simply create a session and redirect to
> https://yourhost/login.jsp.
>
> You should probably create a filter that watches every URL except your
> login page and drives everything back to HTTP if it finds HTTPS in use.
>
> This may interfere with the container's ability to store and re-play
> requests for protected resources /after/ a successful login. YMMV. If
> you can't get it working using this suggestion, feel free to hire me to
> do it for you ;)
>
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAkoCPzoACgkQ9CaO5/Lv0PAPnwCcC9jIfZ9oc60imAgaw01sfcjJ
> MlEAoIsyPZ9f6dXGo5IInzLXOMxh7vs0
> =9YPw
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Form-based Container Security with SSL
Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Guojun,
On 5/6/2009 3:05 PM, Guojun Zhu wrote:
> We had a small web application on tomcat 5.5. We use tomcat realm
> (MD5 digest) with the form-based login. I have a few questions on
> this.
>
> 1. When we use http, does the form-based login page send the username
> and password plainly or in the digested form?
Your web browser will send the credentials in cleartext. The only
"digest" being used here is the one used to hash the password before it
is checked against your database (all on the server side).
If you want the password sent securely, you'll need to either use HTTPS
or use DIGEST authentication, which uses HTTP Auth instead of forms. I
prefer HTTPS + form over DIGEST, FWIW.
> 2. We set up the ssl in 8443 port. All links in our application are
> relative link without the specified scheme. So currently all the
> links (including login page) go either through normal http or
> encrypted https. Is there anyway to limit the ssl only for the login
> page alone and make sure login page always go through ssl? Rest pages
> are really fairly low-risk stuff and we do not worry about the leak on
> them.
Are you comfortable with the possibility of session hijacking? If so,
there is a way to do this that I outlined a few weeks ago. Hmm... I
can't seem to find it in the archives; I'll give you the short-short
version. Try something like this:
web.xml:
<form-login-page>/login.jsp</form-login-page>
...
<security-constraint>
<web-resource-collection>
<url-pattern>/login.jsp</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
<security-constraint>
login.jsp:
<%
Cookie mySessionCookie = ...;
if(mySessionCookie.isSecure())
{
// We don't want a secure session cookie. Kill it,
// redirect to non-secure page and bounce back.
session.invalidate();
response.sendRedirect(response.encodeRedirectURL(BOUNCE_PAGE));
}
%>
Your bounce page should simply create a session and redirect to
https://yourhost/login.jsp.
You should probably create a filter that watches every URL except your
login page and drives everything back to HTTP if it finds HTTPS in use.
This may interfere with the container's ability to store and re-play
requests for protected resources /after/ a successful login. YMMV. If
you can't get it working using this suggestion, feel free to hire me to
do it for you ;)
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAkoCPzoACgkQ9CaO5/Lv0PAPnwCcC9jIfZ9oc60imAgaw01sfcjJ
MlEAoIsyPZ9f6dXGo5IInzLXOMxh7vs0
=9YPw
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org