Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Critical
-
Resolution: Fixed
-
Affects Version/s: security-0.3.0
-
Fix Version/s: security-0.2.2, security-0.3.1
-
Component/s: security
-
Labels:None
-
Environment:NA
-
Number of attachments :
Description
If you want to protect /admin then your ini file contains something like
[urls]
/admin/** = authc, roles[administrator]
Unfortunately Tapestry will also allow /Admin, /ADmin etc. and the filter does not run for those urls. I think what needs to happen is create a TapestryPathMatchingFilterChainResolver
like this
public class TapestryPathMatchingFilterChainResolver extends PathMatchingFilterChainResolver {
@Override
protected boolean pathMatches(String pattern, String path)
}
and use it instead of PathMatchingFilterChainResolver in the SecurityRequestFilter. Unfortunately I think that only solves half the problem because the authc filter will not match correctly either so you need a TapestryFormAuthenticationFilter like
public class TapestryFormAuthenticationFilter extends FormAuthenticationFilter {
@Override
protected boolean pathsMatch(String pattern, String path)
}
and then override the authc filter with that implementation. I suspect this needs to be done for all the default filters.
I worked on the SecurtyRequestFilter and added the following:
PathMatchingFilterChainResolver chainResolver = (PathMatchingFilterChainResolver) shiroFilter.getFilterChainResolver();
{ //FilterChainManager manager = new DefaultFilterChainManager(); //Expose the constructed FilterChainManager by first wrapping it in a // FilterChainResolver implementation. The ShiroFilter implementations // do not know about FilterChainManagers - only resolvers: chainResolver = new TapestryPathMatchingFilterChainResolver(); chainResolver.setFilterChainManager(m); shiroFilter.setFilterChainResolver(chainResolver); }FilterChainManager m = chainResolver.getFilterChainManager();
chainResolver = null;
if (chainResolver == null)
It's ugly but it works. The problem is you really need to call new TapestryPathMatchingFilterChainResolver(filterConfig) but you don't have the filterConfig. You can't use the IniFilterChainResolverFactory because it's got the PathMatchingFilterChainResolver hardcoded. So you really need a TapestryIniFilterChainResolverFactory and override createDefaultInstance.