I would have expected the following to yield the same results:
andCode:<sec:http pattern="/whatever*/**"> </sec:http> <sec:http use-expressions="true"> <sec:intercept-url pattern="/**" access="isAuthenticated()" /> </sec:http>
However, they don't appear to operate in the same way. The first configuration allows users hitting /whatever right through. The second throws a CredentialsNotFoundException. The reason for this occurring is that in AbstractSecurityInterceptor.beforeInvocation(Objec t object), in the first case, there are no attributes, so the check goes intoCode:<sec:http use-expressions="true"> <sec:intercept-url pattern="/whatever*/**" access="permitAll" /> <sec:intercept-url pattern="/**" access="isAuthenticated()" /> </sec:http>and returns null. However, in the second example, there is an attribute - "permitAll" to it does not enter that if, continues on, and since there is no authentication throws a CredentialsNotFoundException. However, if I add an anonymous element, as follows, then there is an authentication and it succeeds.Code:if (attributes == null || attributes.isEmpty())
I am just wondering if this is as expected, and if you should have to specify the anonymous element in order for this to work? In code, where it checks if there are attributes, it could of course also check if the attribute is permitAll and circumvent the authentication check, but I am wondering if it works the way it does for historical purposes, or what the reasoning is behind it. I would just like to understand it better, or know if there is an issue with it.Code:<sec:http> <sec:intercept-url pattern="/whatever*/**" access="permitAll" /> <sec:intercept-url pattern="/**" access="isAuthenticated()" /> <sec:anonymous /> </sec:http>
One more thing of note - we have customized some things in our use of Spring Security, so there is a chance that we have broken things somewhere, but I am thinking that this would still be valid in a non-customized environment (although bringing it up because I could be wrong).
Thanks, Matt


Reply With Quote
).
