# filters

## Purpose

The `filters` plug-in sets up Grails' support for Filters.

## Examples

An example filter:

    class SecurityFilters {
       def filters = {
           loginCheck(controller:'*', action:'*') {
               before = {
                  if(!session.user && !actionName.equals('login')) {
                      redirect(action:'login')
                      return false
                   }
               }       }
       }
    }

Filter rule attributes: `controller` - controller matching pattern, by default is replaced with . and a regex is compiled `action` - action matching pattern, by default is replaced with . and a regex is compiled `regex` (true/false) - use regex syntax (don't replace '' with '.') `find` (true/false) - rule matches with partial match (see java.util.regex.Matcher.find()) `invert` (true/false) - invert the rule (NOT rule)

## Description

Refer to the section on Filters in the Grails user guide which details how filters work.

Configured Spring Beans:

- `filterInterceptor` - An instance of `org.codehaus.groovy.grails.plugins.web.filters.CompositeInterceptor` that composes all the filters together into a single Spring `Interceptor`.

Configured Spring Beans given a filter called `SecurityFilters`:

- `SecurityFiltersClass` - The org.codehaus.groovy.grails.web.filters.GrailsFiltersClass instance which aids in analyzing the conventions within the filter.
- `SecurityFilters` - A singleton reference to the filter itself to support auto-wiring into a Filter