Announcement Announcement Module
Collapse
No announcement yet.
How do I log access denied (403) error ? Page Title Module
Move Remove Collapse
This topic is closed
X
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How do I log access denied (403) error ?

    Hi,

    when authenticated user tries to access area secured by FilterSecurityInterceptor without having the required role, Acegi generates the "Access denied" error (403). This is fine, I have the application server to catch the error and show the error page. But it would be nice to have the error logged as well.

    Is there any way to achieve that? I thought of some similar solution like LoggerListener for authentication failures...

    Thanks,
    Pavel

  • #2
    You can do it today by subclassing SecurityEnforcementFilter and overriding sendAccessDeniedError(ServletRequest, ServletResponse).

    If other people want this feature built into Acegi Security, please speak up and I'll be pleased to add it.

    Comment


    • #3
      +1 to include feature

      Comment


      • #4
        Regarding this topic. I need a way to be able to externally call a controller so that my error page gets decorated by Sitemesh. Currently, using <error-page> tag in web.xml to trap the 403 returns the error page undecorated. So since that seems to be a Sitemesh bug, I tried this way to subclass the SecurityEnforcementFilter's sendAccessDeniedError method with the following code in it, but I still get the error page undecorated. Is there any way around this?

        Code:
        protected void sendAccessDeniedError&#40;ServletRequest request, ServletResponse response&#41; throws IOException &#123;
        		try &#123;
        		request.getRequestDispatcher&#40;"/browse/error.htm"&#41;.forward&#40;request, response&#41;;
        		&#125; catch &#40;ServletException se&#41; &#123;&#125;
        	&#125;

        Comment


        • #5
          I guess one way to do it is to forward to a dummy page that has a meta refresh tag that calls your error page. Then the decorators will get applied since the client is making the request.

          Comment


          • #6
            I've just added to CVS a new package: net.sf.acegisecurity.intercept.event. It contains a variety of events which are published by AbstractSecurityInterceptor. There is also a LoggerListener which outputs the events to Commons Logging. Hopefully this will meet your requirements.

            Comment

            Working...
            X