You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shiro.apache.org by Paul Merlin <es...@n0pe.org> on 2010/04/25 14:43:11 UTC
How to add a custom AuthenticationFilter to the FilterChainManager
Hi folks,
I'm exploring shiro code to see how to add a custom AuthenticationFilter but it
seems that thoses that are available in configuration (authcBasic etc...) are
defined in the enum DefaultFilterChainManager.DefaultFilterChainManager.
How could I add another one writen by me ?
1. Programmaticaly ?
2. By configuration ?
Thanks in advance
/Paul
Re: How to add a custom AuthenticationFilter to the FilterChainManager
Posted by Paul Merlin <pa...@nosphere.org>.
Hi Les,
> Does this help?
Definetely, it's working well, thanks a lot for the explanation.
> However, I just created SHIRO-153:
> https://issues.apache.org/jira/browse/SHIRO-153
>
> due to a problem with the [filters] section - it will be removed for
> 1.0, so be prepared to just move your filter definitions (not the
> urls) into the [main] section after 1.0
Seems a good idea to me, this will simplify the ini configuration.
Keep up the good work on shiro Les.
/Paul
Re: How to add a custom AuthenticationFilter to the
FilterChainManager
Posted by Les Hazlewood <lh...@apache.org>.
Hi Paul,
Thanks for asking this question - I just realized that although I
cover INI configuration in the main configuration page, the
web-specific stuff needs to be updated in the 'Web' configuration
section.
The enum is for Shiro's use only - it makes it easy for the Shiro
developers to keep track of the default filters that we have and what
name they are keyed under. You shouldn't modify this Enum - all
end-user Filter definitions/configuration can be done in the INI
config or whatever other config mechanism you're using. If you're
using INI, after your [main] section, just add a
[filters]
section and configure one or more filters the same way you'd configure
any other object in [main].
Those filter instances will be available to you in the
[urls]
section, which is where you define your filter chains. You can use
any of the pre-defined filters (named the same as in the DefaultFilter
enum), or define your own.
If you want your own filter to perform easy per-path configuration,
you should extend the Shiro PathMatchingFilter class, since that has
the built-in ability to have different configuration based on URL
pattern.
However, I just created SHIRO-153:
https://issues.apache.org/jira/browse/SHIRO-153
due to a problem with the [filters] section - it will be removed for
1.0, so be prepared to just move your filter definitions (not the
urls) into the [main] section after 1.0
Does this help?
- Les
On Sun, Apr 25, 2010 at 8:43 AM, Paul Merlin <es...@n0pe.org> wrote:
> Hi folks,
>
> I'm exploring shiro code to see how to add a custom AuthenticationFilter but it
> seems that thoses that are available in configuration (authcBasic etc...) are
> defined in the enum DefaultFilterChainManager.DefaultFilterChainManager.
>
> How could I add another one writen by me ?
> 1. Programmaticaly ?
> 2. By configuration ?
>
> Thanks in advance
>
> /Paul
>
>
>