Hello, I'm trying to set up a simple authorization scheme based on roles.
Some of the accesses are limited by the path:
But some others I want to filter by method:Code:<bean id="filterInvocationInterceptor" class="net.sf.acegisecurity.intercept.web.FilterSecurityInterceptor"> <property name="authenticationManager"><ref bean="authenticationManager"/></property> <property name="accessDecisionManager"><ref local="httpRequestAccessDecisionManager"/></property> <property name="objectDefinitionSource"> <value> CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON PATTERN_TYPE_APACHE_ANT /index.jsp=ROLE_ANONYMOUS,ROLE_USER /logoff.jsp=ROLE_ANONYMOUS,ROLE_USER /login.jsp=ROLE_ANONYMOUS,ROLE_USER /decorators/**=ROLE_ANONYMOUS,ROLE_USER /images/**=ROLE_ANONYMOUS,ROLE_USER /scripts/**=ROLE_ANONYMOUS,ROLE_USER /styles/**=ROLE_ANONYMOUS,ROLE_USER </value> </property> </bean>
The problem is even though I'm logged in as a user with ROLE_USER, it still can call org.appfuse.web.UserAction.edit:Code:<bean id="securityInterceptor" class="net.sf.acegisecurity.intercept.method.aopalliance.MethodSecurityInterceptor"> <property name="authenticationManager"><ref bean="authenticationManager"/></property> <property name="accessDecisionManager"><ref bean="httpRequestAccessDecisionManager"/></property> <property name="objectDefinitionSource"> <value> org.appfuse.web.UserAction.list=ROLE_USER org.appfuse.web.UserAction.save=ROLE_ADMIN org.appfuse.web.UserAction.edit=ROLE_ADMIN org.appfuse.web.UserAction.delete=ROLE_ADMIN org.appfuse.web.UserAction.*=ROLE_USER </value> </property> </bean>
Here's a piece of the log:
As you can see in the last few lines, a pattern of /** matched my call, but I have no /** defined in my context files.Code:[DEBUG,PathBasedFilterInvocationDefinitionMap,http-8080-Processor25] Converted URL to lowercase, from: '/user.do?method=edit&id=1'; to: '/user.do?method=edit&id=1' [DEBUG,PathBasedFilterInvocationDefinitionMap,http-8080-Processor25] Converted URL to lowercase, from: '/user.do?method=edit&id=1'; to: '/user.do?method=edit&id=1' [DEBUG,PathBasedFilterInvocationDefinitionMap,http-8080-Processor25] Converted URL to lowercase, from: '/user.do?method=edit&id=1'; to: '/user.do?method=edit&id=1' [DEBUG,PathBasedFilterInvocationDefinitionMap,http-8080-Processor25] Candidate is: '/user.do?method=edit&id=1'; pattern is /index.jsp; matched=false [DEBUG,PathBasedFilterInvocationDefinitionMap,http-8080-Processor25] Candidate is: '/user.do?method=edit&id=1'; pattern is /index.jsp; matched=false [DEBUG,PathBasedFilterInvocationDefinitionMap,http-8080-Processor25] Candidate is: '/user.do?method=edit&id=1'; pattern is /index.jsp; matched=false [DEBUG,PathBasedFilterInvocationDefinitionMap,http-8080-Processor25] Candidate is: '/user.do?method=edit&id=1'; pattern is /logoff.jsp; matched=false [DEBUG,PathBasedFilterInvocationDefinitionMap,http-8080-Processor25] Candidate is: '/user.do?method=edit&id=1'; pattern is /logoff.jsp; matched=false [DEBUG,PathBasedFilterInvocationDefinitionMap,http-8080-Processor25] Candidate is: '/user.do?method=edit&id=1'; pattern is /logoff.jsp; matched=false [DEBUG,PathBasedFilterInvocationDefinitionMap,http-8080-Processor25] Candidate is: '/user.do?method=edit&id=1'; pattern is /login.jsp; matched=false [DEBUG,PathBasedFilterInvocationDefinitionMap,http-8080-Processor25] Candidate is: '/user.do?method=edit&id=1'; pattern is /login.jsp; matched=false [DEBUG,PathBasedFilterInvocationDefinitionMap,http-8080-Processor25] Candidate is: '/user.do?method=edit&id=1'; pattern is /login.jsp; matched=false [DEBUG,PathBasedFilterInvocationDefinitionMap,http-8080-Processor25] Candidate is: '/user.do?method=edit&id=1'; pattern is /decorators/**; matched=false [DEBUG,PathBasedFilterInvocationDefinitionMap,http-8080-Processor25] Candidate is: '/user.do?method=edit&id=1'; pattern is /decorators/**; matched=false [DEBUG,PathBasedFilterInvocationDefinitionMap,http-8080-Processor25] Candidate is: '/user.do?method=edit&id=1'; pattern is /decorators/**; matched=false [DEBUG,PathBasedFilterInvocationDefinitionMap,http-8080-Processor25] Candidate is: '/user.do?method=edit&id=1'; pattern is /images/**; matched=false [DEBUG,PathBasedFilterInvocationDefinitionMap,http-8080-Processor25] Candidate is: '/user.do?method=edit&id=1'; pattern is /images/**; matched=false [DEBUG,PathBasedFilterInvocationDefinitionMap,http-8080-Processor25] Candidate is: '/user.do?method=edit&id=1'; pattern is /images/**; matched=false [DEBUG,PathBasedFilterInvocationDefinitionMap,http-8080-Processor25] Candidate is: '/user.do?method=edit&id=1'; pattern is /scripts/**; matched=false [DEBUG,PathBasedFilterInvocationDefinitionMap,http-8080-Processor25] Candidate is: '/user.do?method=edit&id=1'; pattern is /scripts/**; matched=false [DEBUG,PathBasedFilterInvocationDefinitionMap,http-8080-Processor25] Candidate is: '/user.do?method=edit&id=1'; pattern is /scripts/**; matched=false [DEBUG,PathBasedFilterInvocationDefinitionMap,http-8080-Processor25] Candidate is: '/user.do?method=edit&id=1'; pattern is /styles/**; matched=false [DEBUG,PathBasedFilterInvocationDefinitionMap,http-8080-Processor25] Candidate is: '/user.do?method=edit&id=1'; pattern is /styles/**; matched=false [DEBUG,PathBasedFilterInvocationDefinitionMap,http-8080-Processor25] Candidate is: '/user.do?method=edit&id=1'; pattern is /styles/**; matched=false [DEBUG,AbstractSecurityInterceptor,http-8080-Processor25] Public object - authentication not attempted [DEBUG,AbstractSecurityInterceptor,http-8080-Processor25] Public object - authentication not attempted [DEBUG,AbstractSecurityInterceptor,http-8080-Processor25] Authentication object detected and tagged as unauthenticated [DEBUG,AbstractSecurityInterceptor,http-8080-Processor25] Authentication object detected and tagged as unauthenticated [DEBUG,FilterChainProxy,http-8080-Processor25] /user.do?method=edit&id=1 reached end of additional filter chain; proceeding with original chain [DEBUG,PathBasedFilterInvocationDefinitionMap,http-8080-Processor23] Converted URL to lowercase, from: '/user.do?method=edit&id=1'; to: '/user.do?method=edit&id=1' [DEBUG,PathBasedFilterInvocationDefinitionMap,http-8080-Processor23] Converted URL to lowercase, from: '/user.do?method=edit&id=1'; to: '/user.do?method=edit&id=1' [DEBUG,PathBasedFilterInvocationDefinitionMap,http-8080-Processor23] Converted URL to lowercase, from: '/user.do?method=edit&id=1'; to: '/user.do?method=edit&id=1' [DEBUG,PathBasedFilterInvocationDefinitionMap,http-8080-Processor23] Candidate is: '/user.do?method=edit&id=1'; pattern is /**; matched=true [DEBUG,PathBasedFilterInvocationDefinitionMap,http-8080-Processor23] Candidate is: '/user.do?method=edit&id=1'; pattern is /**; matched=true [DEBUG,PathBasedFilterInvocationDefinitionMap,http-8080-Processor23] Candidate is: '/user.do?method=edit&id=1'; pattern is /**; matched=true
Everything seems to be configured OK since this message appears on startup:
I'm sure I'm doing something wrong, so I'd appreciate any help on this.Code:[DEBUG,MethodDefinitionMap,main] Adding secure method [org.appfuse.web.UserAction.edit] with attributes [[ROLE_ADMIN]] [DEBUG,MethodDefinitionMap,main] Adding secure method [org.appfuse.web.UserAction.edit] with attributes [[ROLE_ADMIN]] [DEBUG,MethodDefinitionMap,main] Replacing attributes for secure method [public org.apache.struts.action.ActionForward org.appfuse.web.UserAction.edit(org.apache.struts.action.ActionMapping,org.apache.struts.action.ActionForm,javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) throws java.lang.Exception]: current name [org.appfuse.web.UserAction.edit] is more specific than [org.appfuse.web.UserAction.*] [DEBUG,MethodDefinitionMap,main] Replacing attributes for secure method [public org.apache.struts.action.ActionForward org.appfuse.web.UserAction.edit(org.apache.struts.action.ActionMapping,org.apache.struts.action.ActionForm,javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) throws java.lang.Exception]: current name [org.appfuse.web.UserAction.edit] is more specific than [org.appfuse.web.UserAction.*] [INFO,MethodDefinitionMap,main] Adding secure method [public org.apache.struts.action.ActionForward org.appfuse.web.UserAction.edit(org.apache.struts.action.ActionMapping,org.apache.struts.action.ActionForm,javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) throws java.lang.Exception] with attributes [[ROLE_ADMIN]] [INFO,MethodDefinitionMap,main] Adding secure method [public org.apache.struts.action.ActionForward org.appfuse.web.UserAction.edit(org.apache.struts.action.ActionMapping,org.apache.struts.action.ActionForm,javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) throws java.lang.Exception] with attributes [[ROLE_ADMIN]]
Thanks,
Alejandro Sarco



