HI there,
I am having some issues with the access denied handler in my setup and i'm now tearing my hair out trying to resolve this.
When i try and access a resource which I do not have permission for i want it to be handled by a custom handler that will make an audit log entry and then display our custom 403 error. The problem is that all i recieve is a 404 Page Not Found error.
The error page itself is in a controller mapped by '/error/403' and this is displayed when accessed directly. I have also tried using a static jsp '/error.jsp' and this also displays fine when requested.
My logs and spring config files are as follows:
My application log:
Which is what i expected and this is what appears in my glassfish server log:Code:16:50:17.278 [http-thread-pool-8181-(1)] [DEBUG] [o.s.s.w.a.ExceptionTranslationFilter] - Access is denied (user is not anonymous); delegating to AccessDeniedHandler org.springframework.security.access.AccessDeniedException: Access is denied at org.springframework.security.access.vote.AffirmativeBased.decide(AffirmativeBased.java:71) ~[spring-security-core-3.0.5.RELEASE.jar:3.0.5.RELEASE] at org.springframework.security.access.intercept.AbstractSecurityInterceptor.beforeInvocation(AbstractSecurityInterceptor.java:203) ~[spring-security-core-3.0.5.RELEASE.jar:3.0.5.RELEASE] at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:106) ~[spring-security-web-3.0.5.RELEASE.jar:3.0.5.RELEASE] at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83) ~[spring-security-web-3.0.5.RELEASE.jar:3.0.5.RELEASE] . . . .
(ps it is worth noting that when i log in with the correct user i do indeed get to the requested page)
My spring security configuration is as follows (I have my oid details held in another file):Code:[#|2010-12-09T16:50:17.278+0000|SEVERE|glassfish3.0.1|org.apache.jasper.servlet.JspServlet|_ThreadID=25;_ThreadName=Thread-1;|PWC6117: File "C:\glassfishv3\glassfish\domains\domain1\applications\java\admin\adminSecure" not found|#]
It is also worth noting that if i comment out the access-denied-handler completely i do receive the standard 403 error through my browser.Code:<beans xmlns="http://www.springframework.org/schema/beans" xmlns:s="http://www.springframework.org/schema/security" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.4.xsd"> <s:http use-expressions="true"> <s:intercept-url pattern="/resources/**" filters="none" requires-channel="https"/> <s:intercept-url pattern="/logout" access="permitAll" requires-channel="https"/> <s:intercept-url pattern="/login**" access="permitAll" requires-channel="https"/> <s:intercept-url pattern="/admin/**" access="hasRole('APPS_ADMIN')" requires-channel="https"/> <s:intercept-url pattern="/**" access="hasAnyRole('APPS_USER','APPS_ADMIN')" requires-channel="https"/> <s:form-login login-page="/login" login-processing-url="/app_security_check" authentication-success-handler-ref="loginSuccessHandler" authentication-failure-handler-ref="loginFailureHandler"/> <s:logout invalidate-session="true" logout-url="/logout" logout-success-url="/login?signout=true"/> <s:access-denied-handler ref="accessDeniedHandler"/> <!--<s:access-denied-handler error-page="/error.jsp" />--> <!--<s:access-denied-handler error-page="/error/403" />--> <s:session-management> <s:concurrency-control max-sessions="1" error-if-maximum-exceeded="true" /> </s:session-management> </s:http> <bean id="loginSuccessHandler" class="uk.police.spsa.security.handler.LoginSuccessHandler"/> <bean id="loginFailureHandler" class="uk.police.spsa.security.handler.LoginFailureHandler"> <property name="defaultFailureUrl" value="/login?error=true"/> </bean> <bean id="accessDeniedHandler" class="uk.police.spsa.security.handler.AccessDeniedHandler"> <!-- maps to my error controller --> <property name="errorPage" value="/error/403"/> <!--static jsp --> <!--<property name="errorPage" value="/error.jsp"/>--> </bean> </beans>
I also have urlrewrite configured and everything seems to be working fine i believe although i have not ruled out the possibility of this being the problem.
urlrewite.xml:
Any help / suggestions would be greatly appreciated.Code:<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 3.0//EN" "http://tuckey.org/res/dtds/urlrewrite3.0.dtd"> <urlrewrite default-match-type="wildcard"> <rule> <from>/resources/**</from> <to>/resources/$1</to> </rule> <rule> <from>/logout</from> <to last="true">/logout</to> </rule> <rule> <from>/app_security_check**</from> <to last="true">/app_security_check$1</to> </rule> <rule> <from>/error.jsp</from> <to last="true">/error.jsp</to> </rule> <rule> <from>/**</from> <to>/app/$1</to> </rule> <outbound-rule> <from>/app/**</from> <to>/$1</to> </outbound-rule> </urlrewrite>
Cheers,
Craig
SPRING VERSION: 3.0.4.RELEASE
SPRING SECURITY VERSION: 3.0.5.RELEASE
GLASSFISH VERSION: 3.0.1


Reply With Quote
