Results 1 to 7 of 7

Thread: <jsp:forward> bypasses Acegi?

  1. #1

    Default
    I have simple test app. that secures a subdirectory. If I navigate to that directory directly in the browser, I'm redirected to login form as expected. However if I forward to a page in the secure directory from an unsecured page using <jsp:forward>, it displays the secured page without forcing a login. Is this the expected behavior? Thx.


  2. #2
    Join Date
    Aug 2004
    Posts
    14

    Default

    The same happens to me:

    With <c:redirect url="/home.webx"/> in my index.jsp page, since home.webx requires authentication I'm redirected to login page.

    with <jsp:forward page="/home.webx"/> it goes directly to the home page without authenticating.

    for pearsons_11114..... try using the <c:redirect> tag

    bye

  3. #3
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    2,768

    Default

    Quoting http://java.sun.com/webservices/docs...ecurity4.html:

    Security constraints only work on the original request URI, not on calls made via a RequestDispatcher (which include <jsp:include> and <jsp:forward>). Inside the application, it is assumed that the application itself has complete access to all resources and would not forward a user request unless it had decided that the requesting user had access also.
    Quoting http://www.fawcette.com/javapro/2002...fault_pf.aspx:

    ... filters aren't executed when a RequestDispatcher is used.
    Given the RequestDispatcher is used when you call jsp:forward, but the RequestDispatcher does not cause the filters to run, Acegi Security has no way of securing the request.

  4. #4
    Join Date
    Nov 2004
    Posts
    15

    Default Acegi forwarder or jsp:forward between allowed tag?

    What do you think would be the best approach to control this forwarding issues?

    Right now i think the best solution would be a tag that performs the forwarding since the other would force to configure the forwarded url in 2 places.

  5. #5
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    2,768

    Default

    Sorry, I don't really follow your question. Acegi Security has no way of securing web requests caused by a <jsp:forward> because its filter is never executed. Of course, if the JSP calls another object secured by say MethodSecurityInterceptor it will be secured, but most people use FilterSecurityInterceptor to secure web requests.

    I think it would be preferable if people use <c:redirect> alone, or bear in mind when using <jsp:forward> Acegi Security cannot enforce security via FilterSecurityInterceptor.

  6. #6
    Join Date
    Aug 2004
    Location
    Denver
    Posts
    249

    Default

    If you're using a Servlet 2.4 container, you should be able to add the following after the url-pattern of your filter to trap forwards, as well as requests:

    Code:
            <dispatcher>REQUEST</dispatcher>
            <dispatcher>FORWARD</dispatcher>

  7. #7
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    2,768

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •