-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Gregor,

On 5/6/2009 2:56 PM, Gregor Schneider wrote:
> I've suggested a patch to issues.apache.org which might be helpful if
> Sid wants to implement his own Valve.
> 
> My patch is a new valve, which diverts the call to a pre-defined URL
> if j_security_check is called (I had to circumvent the fact that after
> j_security_check Tomcat is always forwarding to the last request being
> stored - that doesn't work when dealing i.e. with frames.

I'm confused about some of your code (please forgive any formatting
problems):

> +             if (started) {
> +
> +  [SNIPPED debug statements]
> +
> +                     if (aRequest.getRequestURI().startsWith(protectedPath)
> +                                     && 
> !aRequest.getRequestURI().startsWith(redirectAfterAuth)
> +                                     && !aRequest.getRequestURI().startsWith(
> +                                                     "/j_security_check", 
> 10)) {
> +                             if (aRequest.getAuthType() == null) {
> +                                     aRequest.getSession().invalidate();
> +                                     
> aResponse.sendRedirect(redirectAfterAuth);
> +                             } else {
> +                                     if (nextValve != null) {
> +                                             nextValve.invoke(aRequest, 
> aResponse);
> +                                     }
> +                             }
> +                     } else {
> +                             if (nextValve != null) {
> +                                     nextValve.invoke(aRequest, aResponse);
> +                             }
> +                     }
> +             } else {
> +                     log.debug("LoginValve starting");
> +                     if (nextValve != null) {
> +                             getNext().invoke(aRequest, aResponse);
> +                     }
> +             }

A few questions:
1. Why can't the "redirectAfterAuth" path be within the protected space?
2. Why do you check to see if the request URI /startsWith/ the
   redirectAfterAuth instead of being equal to it?
3. Why are you checking to see if characters 10 - 16 of the request URI
   are "y_check". Why not check for the whole "j_security_check" string?
   Why not check the /end/ of the request URI for j_security_check,
   since the URI for j_security_check is not required to be
   /j_security_check but pretty much */j_security_check?
4. Why are killing the session if the authtype is null?
5. Why does your valve pass-through any requests before the component
   has "started"? Is there a valid use case where NOT performing these
   checks and redirects is appropriate?

It appears that your valve does nothing but murder the session and
redirect the user if authtype=null and you are requesting a resource
from a particular URI space. This does not seem particularly useful.

Maybe I'm missing something subtle.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkoCQmEACgkQ9CaO5/Lv0PAuRwCdFUK6/DCK29UonliRDAY97Gu3
TLEAn0KpNqaJseJTOapk9kl7qrUVIqTS
=41Y+
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to