Hi Ben,

The ShiroFilter uses a FilterChainResolver to resolve the FilterChain
to execute based on a given request.  This allows FilterChains to be
resolved dynamically at runtime.  By default, they are resolved based
on static definitions in INI, but they could very easily be resolved
dynamically.

The default implementation of the FilterChainResolver is a
PathMatchingFilterChainResolver.  It looks at the URL path on the
incoming request and then calls into a FilterChainManager to get a
corresponding FilterChain for the matched path.

The DefaultFilterChainManager implementation uses an internal
in-memory Map to manage the path-to-chain configuration.  When using
INI config, the map is populated based on the [urls] INI section.

I think it'd be a relatively easy exercise to implement the
FilterChainManager interface to talk to a datasource instead of an
in-memory map.  You can set your implementation as a property on the
PathMatchingFilterChainResolver instance, and you should be good to
go.

If you're using a DI/IoC framework like Spring or Guice this should be
really simple.  If you're not, you might have to subclass the
IniShiroFilter (or AbstractShiroFilter) to set up the
FilterChainResolver and its nested FilterChainManager instance
directly.  If you have to do that, the IniShiroFilter source code will
give you some good ideas:

http://svn.apache.org/repos/asf/shiro/trunk/web/src/main/java/org/apache/shiro/web/servlet/IniShiroFilter.java

HTH!

-- 
Les Hazlewood
Founder, Katasoft, Inc.
Application Security Products & Professional Apache Shiro Support and Training:
http://www.katasoft.com

Reply via email to