Make Spring Security's filter's order configurable and default to zero

Previously, Spring Security's filter had no configured order. Due to
the use of AnnotationAwareOrderComparater this meant that its order
defaulted to LOWEST_PRECEDENCE. This meant that a user had to declare
a FilterRegistrationBean for the filter and explicitly set its order
if they want another filter to run after Spring Security's.

This commit updates the security auto-configuration to assign a
default order of zero to Spring Security's filter, allowing filters
to be easily configured to run before it or after it. This default
value can overridden using the server.filter-order property. The
default order is also exposed as a constant on SecurityProperties,
allowing it to be referenced from other filter declarations.

Closes gh-1640
This commit is contained in:
Andy Wilkinson
2014-10-30 13:29:27 +00:00
parent cf24af0bfb
commit 0cdb1d3f22
4 changed files with 63 additions and 0 deletions

View File

@@ -168,6 +168,7 @@ content into your application; rather pick only the properties that you need.
security.basic.enabled=true
security.basic.realm=Spring
security.basic.path= # /**
security.filter-order=0
security.headers.xss=false
security.headers.cache=false
security.headers.frame=false