From 19519613744780b89f5820ac34c548b91ba6438d Mon Sep 17 00:00:00 2001 From: Marten Deinum Date: Fri, 21 Dec 2012 14:56:18 +0100 Subject: [PATCH 01/11] AddHeadersFilter for setting security filters added. Issues: SEC-2098, SEC-2099 --- .../security/config/Elements.java | 1 + .../config/SecurityNamespaceHandler.java | 2 +- .../http/AddHeadersBeanDefinitionParser.java | 99 + .../config/http/HttpConfigurationBuilder.java | 14 + .../security/config/http/SecurityFilters.java | 1 + .../main/resources/META-INF/spring.schemas | 3 +- .../security/config/spring-security-3.2.xsd | 1732 +++++++++++++++++ .../config/doc/XsdDocumentedTests.groovy | 6 +- .../security/util/filtertest-valid.xml | 2 +- .../manual/src/docbook/appendix-namespace.xml | 63 + .../web/headers/AddHeadersFilter.java | 67 + 11 files changed, 1984 insertions(+), 6 deletions(-) create mode 100644 config/src/main/java/org/springframework/security/config/http/AddHeadersBeanDefinitionParser.java create mode 100644 config/src/main/resources/org/springframework/security/config/spring-security-3.2.xsd create mode 100644 web/src/main/java/org/springframework/security/web/headers/AddHeadersFilter.java diff --git a/config/src/main/java/org/springframework/security/config/Elements.java b/config/src/main/java/org/springframework/security/config/Elements.java index 3efc60f7d35..67f71a7ad94 100644 --- a/config/src/main/java/org/springframework/security/config/Elements.java +++ b/config/src/main/java/org/springframework/security/config/Elements.java @@ -54,4 +54,5 @@ public abstract class Elements { public static final String LDAP_PASSWORD_COMPARE = "password-compare"; public static final String DEBUG = "debug"; public static final String HTTP_FIREWALL = "http-firewall"; + public static final String ADD_HEADERS = "add-headers"; } diff --git a/config/src/main/java/org/springframework/security/config/SecurityNamespaceHandler.java b/config/src/main/java/org/springframework/security/config/SecurityNamespaceHandler.java index 41950fa2191..6e52a7987aa 100644 --- a/config/src/main/java/org/springframework/security/config/SecurityNamespaceHandler.java +++ b/config/src/main/java/org/springframework/security/config/SecurityNamespaceHandler.java @@ -180,7 +180,7 @@ private boolean namespaceMatchesVersion(Element element) { private boolean matchesVersionInternal(Element element) { String schemaLocation = element.getAttributeNS("http://www.w3.org/2001/XMLSchema-instance", "schemaLocation"); - return schemaLocation.matches("(?m).*spring-security-3\\.1.*.xsd.*") + return schemaLocation.matches("(?m).*spring-security-3\\.[12].*.xsd.*") || schemaLocation.matches("(?m).*spring-security.xsd.*") || !schemaLocation.matches("(?m).*spring-security.*"); } diff --git a/config/src/main/java/org/springframework/security/config/http/AddHeadersBeanDefinitionParser.java b/config/src/main/java/org/springframework/security/config/http/AddHeadersBeanDefinitionParser.java new file mode 100644 index 00000000000..1d8ce168a19 --- /dev/null +++ b/config/src/main/java/org/springframework/security/config/http/AddHeadersBeanDefinitionParser.java @@ -0,0 +1,99 @@ +/* + * Copyright 2002-2012 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.security.config.http; + +import org.springframework.beans.factory.config.BeanDefinition; +import org.springframework.beans.factory.support.BeanDefinitionBuilder; +import org.springframework.beans.factory.xml.BeanDefinitionParser; +import org.springframework.beans.factory.xml.ParserContext; +import org.springframework.security.web.headers.AddHeadersFilter; +import org.springframework.util.xml.DomUtils; +import org.w3c.dom.Element; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Parser for the {@code AddHeadersFilter}. + * + * @author Marten Deinum + * @since 3.2 + */ +public class AddHeadersBeanDefinitionParser implements BeanDefinitionParser { + + private static final String ATT_ENABLED = "enabled"; + private static final String ATT_BLOCK = "block"; + + private static final String ATT_POLICY = "policy"; + private static final String ATT_ORIGIN = "policy"; + + private static final String ATT_NAME = "name"; + private static final String ATT_VALUE = "value"; + + private static final String XSS_ELEMENT = "xss-protection"; + private static final String CONTENT_TYPE_ELEMENT = "content-type-options"; + private static final String FRAME_OPTIONS_ELEMENT = "frame-options"; + private static final String GENERIC_HEADER_ELEMENT = "header"; + + private static final String XSS_PROTECTION_HEADER = "X-XSS-Protection"; + private static final String FRAME_OPTIONS_HEADER = "X-Frame-Options"; + private static final String CONENT_TYPE_OPTIONS_HEADER = "X-Content-Type-Options"; + + private static final String ALLOW_FROM = "ALLOW-FROM"; + + @Override + public BeanDefinition parse(Element element, ParserContext parserContext) { + BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(AddHeadersFilter.class); + final Map headers = new HashMap(); + + Element xssElt = DomUtils.getChildElementByTagName(element, XSS_ELEMENT); + Element contentTypeElt = DomUtils.getChildElementByTagName(element, CONTENT_TYPE_ELEMENT); + Element frameElt = DomUtils.getChildElementByTagName(element, FRAME_OPTIONS_ELEMENT); + + if (xssElt != null) { + boolean enabled = "true".equalsIgnoreCase(xssElt.getAttribute(ATT_ENABLED)); + boolean block = "true".equalsIgnoreCase(xssElt.getAttribute(ATT_BLOCK)); + + String value = enabled ? "1" : "0"; + if (enabled && block) { + value += "; mode=block"; + } + headers.put(XSS_PROTECTION_HEADER, value); + } + + if (frameElt != null) { + String header = frameElt.getAttribute(ATT_POLICY); + if (ALLOW_FROM.equals(header) ) { + String origin = frameElt.getAttribute(ATT_ORIGIN); + header += " " + origin; + } + headers.put(FRAME_OPTIONS_HEADER, header); + } + + if (contentTypeElt != null) { + headers.put(CONENT_TYPE_OPTIONS_HEADER, "nosniff"); + } + + List headerEtls = DomUtils.getChildElementsByTagName(element, GENERIC_HEADER_ELEMENT); + for (Element headerEtl : headerEtls) { + headers.put(headerEtl.getAttribute(ATT_NAME), headerEtl.getAttribute(ATT_VALUE)); + } + + builder.addPropertyValue("headers", headers); + return builder.getBeanDefinition(); + } +} diff --git a/config/src/main/java/org/springframework/security/config/http/HttpConfigurationBuilder.java b/config/src/main/java/org/springframework/security/config/http/HttpConfigurationBuilder.java index a568307d4e7..3f4f717573d 100644 --- a/config/src/main/java/org/springframework/security/config/http/HttpConfigurationBuilder.java +++ b/config/src/main/java/org/springframework/security/config/http/HttpConfigurationBuilder.java @@ -117,6 +117,7 @@ class HttpConfigurationBuilder { private final BeanReference portResolver; private BeanReference fsi; private BeanReference requestCache; + private BeanDefinition addHeadersFilter; public HttpConfigurationBuilder(Element element, ParserContext pc, BeanReference portMapper, BeanReference portResolver, BeanReference authenticationManager) { @@ -151,6 +152,7 @@ public HttpConfigurationBuilder(Element element, ParserContext pc, createJaasApiFilter(); createChannelProcessingFilter(); createFilterSecurityInterceptor(authenticationManager); + createAddHeadersFilter(); } @SuppressWarnings("rawtypes") @@ -554,6 +556,14 @@ private void createFilterSecurityInterceptor(BeanReference authManager) { this.fsi = new RuntimeBeanReference(fsiId); } + private void createAddHeadersFilter() { + Element elmt = DomUtils.getChildElementByTagName(httpElt, Elements.ADD_HEADERS); + if (elmt != null) { + this.addHeadersFilter = new AddHeadersBeanDefinitionParser().parse(elmt, pc); + } + + } + BeanReference getSessionStrategy() { return sessionStrategyRef; } @@ -601,6 +611,10 @@ List getFilters() { filters.add(new OrderDecorator(requestCacheAwareFilter, REQUEST_CACHE_FILTER)); } + if (addHeadersFilter != null) { + filters.add(new OrderDecorator(addHeadersFilter, ADD_HEADERS_FILTER)); + } + return filters; } } diff --git a/config/src/main/java/org/springframework/security/config/http/SecurityFilters.java b/config/src/main/java/org/springframework/security/config/http/SecurityFilters.java index 58a9bc491ab..3ff9834e9ae 100644 --- a/config/src/main/java/org/springframework/security/config/http/SecurityFilters.java +++ b/config/src/main/java/org/springframework/security/config/http/SecurityFilters.java @@ -29,6 +29,7 @@ enum SecurityFilters { CONCURRENT_SESSION_FILTER, /** {@link WebAsyncManagerIntegrationFilter} */ WEB_ASYNC_MANAGER_FILTER, + ADD_HEADERS_FILTER, LOGOUT_FILTER, X509_FILTER, PRE_AUTH_FILTER, diff --git a/config/src/main/resources/META-INF/spring.schemas b/config/src/main/resources/META-INF/spring.schemas index 4d623cd673d..5c543a8c642 100644 --- a/config/src/main/resources/META-INF/spring.schemas +++ b/config/src/main/resources/META-INF/spring.schemas @@ -1,4 +1,5 @@ -http\://www.springframework.org/schema/security/spring-security.xsd=org/springframework/security/config/spring-security-3.1.xsd +http\://www.springframework.org/schema/security/spring-security.xsd=org/springframework/security/config/spring-security-3.2.xsd +http\://www.springframework.org/schema/security/spring-security-3.2.xsd=org/springframework/security/config/spring-security-3.2.xsd http\://www.springframework.org/schema/security/spring-security-3.1.xsd=org/springframework/security/config/spring-security-3.1.xsd http\://www.springframework.org/schema/security/spring-security-3.0.3.xsd=org/springframework/security/config/spring-security-3.0.3.xsd http\://www.springframework.org/schema/security/spring-security-3.0.xsd=org/springframework/security/config/spring-security-3.0.xsd diff --git a/config/src/main/resources/org/springframework/security/config/spring-security-3.2.xsd b/config/src/main/resources/org/springframework/security/config/spring-security-3.2.xsd new file mode 100644 index 00000000000..e836e49f29c --- /dev/null +++ b/config/src/main/resources/org/springframework/security/config/spring-security-3.2.xsd @@ -0,0 +1,1732 @@ + + + + + + Defines the hashing algorithm used on user passwords. We recommend strongly against using MD4, as it is a very weak hashing algorithm. + + + + + + + + + + + + + + + + + + Whether a string should be base64 encoded + + + + + + + Supersedes the 'path-type' attribute. Defines the strategy use for matching incoming requests. Currently the options are 'ant' (for ant path patterns), 'regex' for regular expressions and 'ciRegex' for case-insensitive regular expressions. + + + + + + + + + + + + + + Deprecated. Use request-matcher instead. + + + + + + + + + + + + + Specifies an IP port number. Used to configure an embedded LDAP server, for example. + + + + + + + Specifies a URL. + + + + + + + A bean identifier, used for referring to the bean elsewhere in the context. + + + + + + + A bean identifier, used for referring to the bean elsewhere in the context. + + + + + + + Defines a reference to a Spring bean Id. + + + + + + + Defines a reference to a cache for use with a UserDetailsService. + + + + + + + A reference to a user-service (or UserDetailsService bean) Id + + + + + + + A reference to an AuthenticationManager bean + + + + + + + A reference to a DataSource bean + + + + + Enables Spring Security debugging infrastructure. This will provide human-readable (multi-line) debugging information to monitor requests coming into the security filters. This may include sensitive information, such as request parameters or headers, and should only be used in a development environment. + + + + + + Defines a reference to a Spring bean Id. + + + + + Defines the hashing algorithm used on user passwords. We recommend strongly against using MD4, as it is a very weak hashing algorithm. + + + + + + + + + + + + + + + + Whether a string should be base64 encoded + + + + + + + + A property of the UserDetails object which will be used as salt by a password encoder. Typically something like "username" might be used. + + + + + + + A single value that will be used as the salt for a password encoder. + + + + + + + A non-empty string prefix that will be added to role strings loaded from persistent storage (e.g. "ROLE_"). Use the value "none" for no prefix in cases where the default is non-empty. + + + + + + + Enables the use of expressions in the 'access' attributes in <intercept-url> elements rather than the traditional list of configuration attributes. Defaults to 'false'. If enabled, each attribute should contain a single boolean expression. If the expression evaluates to 'true', access will be granted. + + + + + Defines an LDAP server location or starts an embedded server. The url indicates the location of a remote server. If no url is given, an embedded server will be started, listening on the supplied port number. The port is optional and defaults to 33389. A Spring LDAP ContextSource bean will be registered for the server with the id supplied. + + + + + + + A bean identifier, used for referring to the bean elsewhere in the context. + + + + + Specifies a URL. + + + + + Specifies an IP port number. Used to configure an embedded LDAP server, for example. + + + + + Username (DN) of the "manager" user identity which will be used to authenticate to a (non-embedded) LDAP server. If omitted, anonymous access will be used. + + + + + The password for the manager DN. This is required if the manager-dn is specified. + + + + + Explicitly specifies an ldif file resource to load into an embedded LDAP server. The default is classpath*:*.ldiff + + + + + Optional root suffix for the embedded LDAP server. Default is "dc=springframework,dc=org" + + + + + + + The optional server to use. If omitted, and a default LDAP server is registered (using <ldap-server> with no Id), that server will be used. + + + + + + + Group search filter. Defaults to (uniqueMember={0}). The substituted parameter is the DN of the user. + + + + + + + Search base for group membership searches. Defaults to "" (searching from the root). + + + + + + + The LDAP filter used to search for users (optional). For example "(uid={0})". The substituted parameter is the user's login name. + + + + + + + Search base for user searches. Defaults to "". Only used with a 'user-search-filter'. + + + + + + + The LDAP attribute name which contains the role name which will be used within Spring Security. Defaults to "cn". + + + + + + + Allows the objectClass of the user entry to be specified. If set, the framework will attempt to load standard attributes for the defined class into the returned UserDetails object + + + + + + + + + + + + + Allows explicit customization of the loaded user object by specifying a UserDetailsContextMapper bean which will be called with the context information from the user's directory entry + + + + + This element configures a LdapUserDetailsService which is a combination of a FilterBasedLdapUserSearch and a DefaultLdapAuthoritiesPopulator. + + + + + + + A bean identifier, used for referring to the bean elsewhere in the context. + + + + + The optional server to use. If omitted, and a default LDAP server is registered (using <ldap-server> with no Id), that server will be used. + + + + + The LDAP filter used to search for users (optional). For example "(uid={0})". The substituted parameter is the user's login name. + + + + + Search base for user searches. Defaults to "". Only used with a 'user-search-filter'. + + + + + Group search filter. Defaults to (uniqueMember={0}). The substituted parameter is the DN of the user. + + + + + Search base for group membership searches. Defaults to "" (searching from the root). + + + + + The LDAP attribute name which contains the role name which will be used within Spring Security. Defaults to "cn". + + + + + Defines a reference to a cache for use with a UserDetailsService. + + + + + A non-empty string prefix that will be added to role strings loaded from persistent storage (e.g. "ROLE_"). Use the value "none" for no prefix in cases where the default is non-empty. + + + + + Allows the objectClass of the user entry to be specified. If set, the framework will attempt to load standard attributes for the defined class into the returned UserDetails object + + + + + + + + + + + Allows explicit customization of the loaded user object by specifying a UserDetailsContextMapper bean which will be called with the context information from the user's directory entry + + + + + + + + The optional server to use. If omitted, and a default LDAP server is registered (using <ldap-server> with no Id), that server will be used. + + + + + Search base for user searches. Defaults to "". Only used with a 'user-search-filter'. + + + + + The LDAP filter used to search for users (optional). For example "(uid={0})". The substituted parameter is the user's login name. + + + + + Search base for group membership searches. Defaults to "" (searching from the root). + + + + + Group search filter. Defaults to (uniqueMember={0}). The substituted parameter is the DN of the user. + + + + + The LDAP attribute name which contains the role name which will be used within Spring Security. Defaults to "cn". + + + + + A specific pattern used to build the user's DN, for example "uid={0},ou=people". The key "{0}" must be present and will be substituted with the username. + + + + + A non-empty string prefix that will be added to role strings loaded from persistent storage (e.g. "ROLE_"). Use the value "none" for no prefix in cases where the default is non-empty. + + + + + Allows the objectClass of the user entry to be specified. If set, the framework will attempt to load standard attributes for the defined class into the returned UserDetails object + + + + + + + + + + + Allows explicit customization of the loaded user object by specifying a UserDetailsContextMapper bean which will be called with the context information from the user's directory entry + + + + + + + + The attribute in the directory which contains the user password. Defaults to "userPassword". + + + + + Defines the hashing algorithm used on user passwords. We recommend strongly against using MD4, as it is a very weak hashing algorithm. + + + + + + + + + + + + + + + + Can be used inside a bean definition to add a security interceptor to the bean and set up access configuration attributes for the bean's methods + + + + Defines a protected method and the access control configuration attributes that apply to it. We strongly advise you NOT to mix "protect" declarations with any services provided "global-method-security". + + + + + + + + + + Optional AccessDecisionManager bean ID to be used by the created method security interceptor. + + + + + + + + A method name + + + + + Access configuration attributes list that applies to the method, e.g. "ROLE_A,ROLE_B". + + + + + Creates a MethodSecurityMetadataSource instance + + + + Defines a protected method and the access control configuration attributes that apply to it. We strongly advise you NOT to mix "protect" declarations with any services provided "global-method-security". + + + + + + + + + + A bean identifier, used for referring to the bean elsewhere in the context. + + + + + Enables the use of expressions in the 'access' attributes in <intercept-url> elements rather than the traditional list of configuration attributes. Defaults to 'false'. If enabled, each attribute should contain a single boolean expression. If the expression evaluates to 'true', access will be granted. + + + + + Provides method security for all beans registered in the Spring application context. Specifically, beans will be scanned for matches with the ordered list of "protect-pointcut" sub-elements, Spring Security annotations and/or. Where there is a match, the beans will automatically be proxied and security authorization applied to the methods accordingly. If you use and enable all four sources of method security metadata (ie "protect-pointcut" declarations, expression annotations, @Secured and also JSR250 security annotations), the metadata sources will be queried in that order. In practical terms, this enables you to use XML to override method security metadata expressed in annotations. If using annotations, the order of precedence is EL-based (@PreAuthorize etc.), @Secured and finally JSR-250. + + + + + Allows the default expression-based mechanism for handling Spring Security's pre and post invocation annotations (@PreFilter, @PreAuthorize, @PostFilter, @PostAuthorize) to be replace entirely. Only applies if these annotations are enabled. + + + + Defines the PrePostInvocationAttributeFactory instance which is used to generate pre and post invocation metadata from the annotated methods. + + + + + Customizes the PreInvocationAuthorizationAdviceVoter with the ref as the PreInvocationAuthorizationAdviceVoter for the <pre-post-annotation-handling> element. + + + + + Customizes the PostInvocationAdviceProvider with the ref as the PostInvocationAuthorizationAdvice for the <pre-post-annotation-handling> element. + + + + + + + Defines the SecurityExpressionHandler instance which will be used if expression-based access-control is enabled. A default implementation (with no ACL support) will be used if not supplied. + + + + + + Defines a protected pointcut and the access control configuration attributes that apply to it. Every bean registered in the Spring application context that provides a method that matches the pointcut will receive security authorization. + + + + + Allows addition of extra AfterInvocationProvider beans which should be called by the MethodSecurityInterceptor created by global-method-security. + + + + + + + + + + Specifies whether the use of Spring Security's pre and post invocation annotations (@PreFilter, @PreAuthorize, @PostFilter, @PostAuthorize) should be enabled for this application context. Defaults to "disabled". + + + + + + + + + + + Specifies whether the use of Spring Security's @Secured annotations should be enabled for this application context. Defaults to "disabled". + + + + + + + + + + + Specifies whether JSR-250 style attributes are to be used (for example "RolesAllowed"). This will require the javax.annotation.security classes on the classpath. Defaults to "disabled". + + + + + + + + + + + Optional AccessDecisionManager bean ID to override the default used for method security. + + + + + Optional RunAsmanager implementation which will be used by the configured MethodSecurityInterceptor + + + + + Allows the advice "order" to be set for the method security interceptor. + + + + + If true, class based proxying will be used instead of interface based proxying. + + + + + Can be used to specify that AspectJ should be used instead of the default Spring AOP. If set, secured classes must be woven with the AnnotationSecurityAspect from the spring-security-aspects module. + + + + + + + + + + An external MethodSecurityMetadataSource instance can be supplied which will take priority over other sources (such as the default annotations). + + + + + A reference to an AuthenticationManager bean + + + + + + + + + + + + + + An AspectJ expression, including the 'execution' keyword. For example, 'execution(int com.foo.TargetObject.countLength(String))' (without the quotes). + + + + + Access configuration attributes list that applies to all methods matching the pointcut, e.g. "ROLE_A,ROLE_B" + + + + + Allows a custom instance of HttpFirewall to be injected into the FilterChainProxy created by the namespace. + + + + + Container element for HTTP security configuration. Multiple elements can now be defined, each with a specific pattern to which the enclosed security configuration applies. A pattern can also be configured to bypass Spring Security's filters completely by setting the "secured" attribute to "false". + + + + Specifies the access attributes and/or filter list for a particular set of URLs. + + + + + Defines the access-denied strategy that should be used. An access denied page can be defined or a reference to an AccessDeniedHandler instance. + + + + + Sets up a form login configuration for authentication with a username and password + + + + + Sets up form login for authentication with an Open ID identity + + + + + + + + A reference to a user-service (or UserDetailsService bean) Id + + + + + Adds support for X.509 client authentication. + + + + + + Adds support for basic authentication + + + + + Incorporates a logout processing filter. Most web applications require a logout filter, although you may not require one if you write a controller to provider similar logic. + + + + + Session-management related functionality is implemented by the addition of a SessionManagementFilter to the filter stack. + + + + Enables concurrent session control, limiting the number of authenticated sessions a user may have at the same time. + + + + + + + + Sets up remember-me authentication. If used with the "key" attribute (or no attributes) the cookie-only implementation will be used. Specifying "token-repository-ref" or "remember-me-data-source-ref" will use the more secure, persisten token approach. + + + + + Adds support for automatically granting all anonymous web requests a particular principal identity and a corresponding granted authority. + + + + + Defines the list of mappings between http and https ports for use in redirects + + + + Provides a method to map http ports to https ports when forcing a redirect. + + + + + + + + + + Defines the SecurityExpressionHandler instance which will be used if expression-based access-control is enabled. A default implementation (with no ACL support) will be used if not supplied. + + + + + + + + + + The request URL pattern which will be mapped to the filter chain created by this <http> element. If omitted, the filter chain will match all requests. + + + + + When set to 'none', requests matching the pattern attribute will be ignored by Spring Security. No security filters will be applied and no SecurityContext will be available. If set, the <http> element must be empty, with no children. + + + + + + + + + + Allows a RequestMatcher instance to be used, as an alternative to pattern-matching. + + + + + Automatically registers a login form, BASIC authentication, anonymous authentication, logout services, remember-me and servlet-api-integration. If set to "true", all of these capabilities are added (although you can still customize the configuration of each by providing the respective element). If unspecified, defaults to "false". + + + + + Enables the use of expressions in the 'access' attributes in <intercept-url> elements rather than the traditional list of configuration attributes. Defaults to 'false'. If enabled, each attribute should contain a single boolean expression. If the expression evaluates to 'true', access will be granted. + + + + + Controls the eagerness with which an HTTP session is created by Spring Security classes. If not set, defaults to "ifRequired". If "stateless" is used, this implies that the application guarantees that it will not create a session. This differs from the use of "never" which mans that Spring Security will not create a session, but will make use of one if the application does. + + + + + + + + + + + + + A reference to a SecurityContextRepository bean. This can be used to customize how the SecurityContext is stored between requests. + + + + + Supersedes the 'path-type' attribute. Defines the strategy use for matching incoming requests. Currently the options are 'ant' (for ant path patterns), 'regex' for regular expressions and 'ciRegex' for case-insensitive regular expressions. + + + + + + + + + + + + Deprecated. Use request-matcher instead. + + + + + + + + + + + Provides versions of HttpServletRequest security methods such as isUserInRole() and getPrincipal() which are implemented by accessing the Spring SecurityContext. Defaults to "true". + + + + + If available, runs the request as the Subject acquired from the JaasAuthenticationToken. Defaults to "false". + + + + + Optional attribute specifying the ID of the AccessDecisionManager implementation which should be used for authorizing HTTP requests. + + + + + Optional attribute specifying the realm name that will be used for all authentication features that require a realm name (eg BASIC and Digest authentication). If unspecified, defaults to "Spring Security Application". + + + + + Allows a customized AuthenticationEntryPoint to be set on the ExceptionTranslationFilter. + + + + + Corresponds to the observeOncePerRequest property of FilterSecurityInterceptor. Defaults to "true" + + + + + Deprecated in favour of the access-denied-handler element. + + + + + Prevents the jsessionid parameter from being added to rendered URLs. + + + + + A bean identifier, used for referring to the bean elsewhere in the context. + + + + + A reference to an AuthenticationManager bean + + + + + + + + Defines a reference to a Spring bean Id. + + + + + The access denied page that an authenticated user will be redirected to if they request a page which they don't have the authority to access. + + + + + + + The access denied page that an authenticated user will be redirected to if they request a page which they don't have the authority to access. + + + + + + + + The pattern which defines the URL path. The content will depend on the type set in the containing http element, so will default to ant path syntax. + + + + + The access configuration attributes that apply for the configured path. + + + + + The HTTP Method for which the access configuration attributes should apply. If not specified, the attributes will apply to any method. + + + + + + + + + + + + + + + + The filter list for the path. Currently can be set to "none" to remove a path from having any filters applied. The full filter stack (consisting of all filters created by the namespace configuration, and any added using 'custom-filter'), will be applied to any other paths. + + + + + + + + + + Used to specify that a URL must be accessed over http or https, or that there is no preference. The value should be "http", "https" or "any", respectively. + + + + + + + + Specifies the URL that will cause a logout. Spring Security will initialize a filter that responds to this particular URL. Defaults to /j_spring_security_logout if unspecified. + + + + + Specifies the URL to display once the user has logged out. If not specified, defaults to /. + + + + + Specifies whether a logout also causes HttpSession invalidation, which is generally desirable. If unspecified, defaults to true. + + + + + A reference to a LogoutSuccessHandler implementation which will be used to determine the destination to which the user is taken after logging out. + + + + + A comma-separated list of the names of cookies which should be deleted when the user logs out + + + + + Allow the RequestCache used for saving requests during the login process to be set + + + + + + + + The URL that the login form is posted to. If unspecified, it defaults to /j_spring_security_check. + + + + + The name of the request parameter which contains the username. Defaults to 'j_username'. + + + + + The name of the request parameter which contains the password. Defaults to 'j_password'. + + + + + The URL that will be redirected to after successful authentication, if the user's previous action could not be resumed. This generally happens if the user visits a login page without having first requested a secured operation that triggers authentication. If unspecified, defaults to the root of the application. + + + + + Whether the user should always be redirected to the default-target-url after login. + + + + + The URL for the login page. If no login URL is specified, Spring Security will automatically create a login URL at /spring_security_login and a corresponding filter to render that login URL when requested. + + + + + The URL for the login failure page. If no login failure URL is specified, Spring Security will automatically create a failure login URL at /spring_security_login?login_error and a corresponding filter to render that login failure URL when requested. + + + + + Reference to an AuthenticationSuccessHandler bean which should be used to handle a successful authentication request. Should not be used in combination with default-target-url (or always-use-default-target-url) as the implementation should always deal with navigation to the subsequent destination + + + + + Reference to an AuthenticationFailureHandler bean which should be used to handle a failed authentication request. Should not be used in combination with authentication-failure-url as the implementation should always deal with navigation to the subsequent destination + + + + + Reference to an AuthenticationDetailsSource which will be used by the authentication filter + + + + + + Sets up an attribute exchange configuration to request specified attributes from the OpenID identity provider. When multiple elements are used, each must have an identifier-attribute attribute. Each configuration will be matched in turn against the supplied login identifier until a match is found. + + + + + + + + + + A regular expression which will be compared against the claimed identity, when deciding which attribute-exchange configuration to use during authentication. + + + + + Attributes used when making an OpenID AX Fetch Request + + + + + + + Specifies the name of the attribute that you wish to get back. For example, email. + + + + + Specifies the attribute type. For example, http://axschema.org/contact/email. See your OP's documentation for valid attribute types. + + + + + Specifies if this attribute is required to the OP, but does not error out if the OP does not return the attribute. Default is false. + + + + + Specifies the number of attributes that you wish to get back. For example, return 3 emails. The default value is 1. + + + + + Used to explicitly configure a FilterChainProxy instance with a FilterChainMap + + + + + + + + + + Deprecated. Use request-matcher instead. + + + + + + + + + + + Supersedes the 'path-type' attribute. Defines the strategy use for matching incoming requests. Currently the options are 'ant' (for ant path patterns), 'regex' for regular expressions and 'ciRegex' for case-insensitive regular expressions. + + + + + + + + + + + + Used within to define a specific URL pattern and the list of filters which apply to the URLs matching that pattern. When multiple filter-chain elements are assembled in a list in order to configure a FilterChainProxy, the most specific patterns must be placed at the top of the list, with most general ones at the bottom. + + + + + + + The request URL pattern which will be mapped to the FilterChain. + + + + + Allows a RequestMatcher instance to be used, as an alternative to pattern-matching. + + + + + A comma separated list of bean names that implement Filter that should be processed for this FilterChain. If the value is none, then no Filters will be used for this FilterChain. + + + + + + + The request URL pattern which will be mapped to the FilterChain. + + + + + + + Allows a RequestMatcher instance to be used, as an alternative to pattern-matching. + + + + + Used to explicitly configure a FilterSecurityMetadataSource bean for use with a FilterSecurityInterceptor. Usually only needed if you are configuring a FilterChainProxy explicitly, rather than using the <http> element. The intercept-url elements used should only contain pattern, method and access attributes. Any others will result in a configuration error. + + + + Specifies the access attributes and/or filter list for a particular set of URLs. + + + + + + + + + + Enables the use of expressions in the 'access' attributes in <intercept-url> elements rather than the traditional list of configuration attributes. Defaults to 'false'. If enabled, each attribute should contain a single boolean expression. If the expression evaluates to 'true', access will be granted. + + + + + A bean identifier, used for referring to the bean elsewhere in the context. + + + + + Compare after forcing to lowercase + + + + + Deprecated. Use request-matcher instead. + + + + + + + + + + + Supersedes the 'path-type' attribute. Defines the strategy use for matching incoming requests. Currently the options are 'ant' (for ant path patterns), 'regex' for regular expressions and 'ciRegex' for case-insensitive regular expressions. + + + + + + + + + + + + Deprecated synonym for filter-security-metadata-source + + + + Specifies the access attributes and/or filter list for a particular set of URLs. + + + + + + + + + + + Sets the AuthenticationEntryPoint which is used by the BasicAuthenticationFilter. + + + + + Reference to an AuthenticationDetailsSource which will be used by the authentication filter + + + + + + + + Indicates whether an existing session should be invalidated when a user authenticates and a new session started. If set to "none" no change will be made. "newSession" will create a new empty session. "migrateSession" will create a new session and copy the session attributes to the new session. Defaults to "migrateSession". + + + + + + + + + + + + The URL to which a user will be redirected if they submit an invalid session indentifier. Typically used to detect session timeouts. + + + + + Allows injection of the SessionAuthenticationStrategy instance used by the SessionManagementFilter + + + + + Defines the URL of the error page which should be shown when the SessionAuthenticationStrategy raises an exception. If not set, an unauthorized (402) error code will be returned to the client. Note that this attribute doesn't apply if the error occurs during a form-based login, where the URL for authentication failure will take precedence. + + + + + + + + The maximum number of sessions a single authenticated user can have open at the same time. Defaults to "1". + + + + + The URL a user will be redirected to if they attempt to use a session which has been "expired" because they have logged in again. + + + + + Specifies that an unauthorized error should be reported when a user attempts to login when they already have the maximum configured sessions open. The default behaviour is to expire the original session. If the session-authentication-error-url attribute is set on the session-management URL, the user will be redirected to this URL. + + + + + Allows you to define an alias for the SessionRegistry bean in order to access it in your own configuration. + + + + + Allows you to define an external SessionRegistry bean to be used by the concurrency control setup. + + + + + + + + The "key" used to identify cookies from a specific token-based remember-me application. You should set this to a unique value for your application. + + + + + Reference to a PersistentTokenRepository bean for use with the persistent token remember-me implementation. + + + + + A reference to a DataSource bean + + + + + + A reference to a user-service (or UserDetailsService bean) Id + + + + + Exports the internally defined RememberMeServices as a bean alias, allowing it to be used by other beans in the application context. + + + + + Determines whether the "secure" flag will be set on the remember-me cookie. If set to true, the cookie will only be submitted over HTTPS (recommended). By default, secure cookies will be used if the request is made on a secure connection. + + + + + The period (in seconds) for which the remember-me cookie should be valid. + + + + + Reference to an AuthenticationSuccessHandler bean which should be used to handle a successful remember-me authentication. + + + + + + + Reference to a PersistentTokenRepository bean for use with the persistent token remember-me implementation. + + + + + + + Allows a custom implementation of RememberMeServices to be used. Note that this implementation should return RememberMeAuthenticationToken instances with the same "key" value as specified in the remember-me element. Alternatively it should register its own AuthenticationProvider. It should also implement the LogoutHandler interface, which will be invoked when a user logs out. Typically the remember-me cookie would be removed on logout. + + + + + + + + + + + The key shared between the provider and filter. This generally does not need to be set. If unset, it will default to "doesNotMatter". + + + + + The username that should be assigned to the anonymous request. This allows the principal to be identified, which may be important for logging and auditing. if unset, defaults to "anonymousUser". + + + + + The granted authority that should be assigned to the anonymous request. Commonly this is used to assign the anonymous request particular roles, which can subsequently be used in authorization decisions. If unset, defaults to "ROLE_ANONYMOUS". + + + + + With the default namespace setup, the anonymous "authentication" facility is automatically enabled. You can disable it using this property. + + + + + + + + + The http port to use. + + + + + + + The https port to use. + + + + + + + + The regular expression used to obtain the username from the certificate's subject. Defaults to matching on the common name using the pattern "CN=(.*?),". + + + + + A reference to a user-service (or UserDetailsService bean) Id + + + + + Reference to an AuthenticationDetailsSource which will be used by the authentication filter + + + + + Adds a J2eePreAuthenticatedProcessingFilter to the filter chain to provide integration with container authentication. + + + + + + + A comma-separate list of roles to look for in the incoming HttpServletRequest. + + + + + A reference to a user-service (or UserDetailsService bean) Id + + + + + Registers the AuthenticationManager instance and allows its list of AuthenticationProviders to be defined. Also allows you to define an alias to allow you to reference the AuthenticationManager in your own beans. + + + + Indicates that the contained user-service should be used as an authentication source. + + + + + element which defines a password encoding strategy. Used by an authentication provider to convert submitted passwords to hashed versions, for example. + + + + Password salting strategy. A system-wide constant or a property from the UserDetails object can be used. + + + + A property of the UserDetails object which will be used as salt by a password encoder. Typically something like "username" might be used. + + + + + A single value that will be used as the salt for a password encoder. + + + + + Defines a reference to a Spring bean Id. + + + + + + + + + + + Sets up an ldap authentication provider + + + + Specifies that an LDAP provider should use an LDAP compare operation of the user's password to authenticate the user + + + + element which defines a password encoding strategy. Used by an authentication provider to convert submitted passwords to hashed versions, for example. + + + + Password salting strategy. A system-wide constant or a property from the UserDetails object can be used. + + + + A property of the UserDetails object which will be used as salt by a password encoder. Typically something like "username" might be used. + + + + + A single value that will be used as the salt for a password encoder. + + + + + Defines a reference to a Spring bean Id. + + + + + + + + + + + + + + + + + + + A bean identifier, used for referring to the bean elsewhere in the context. + + + + + An alias you wish to use for the AuthenticationManager bean (not required it you are using a specific id) + + + + + If set to true, the AuthenticationManger will attempt to clear any credentials data in the returned Authentication object, once the user has been authenticated. + + + + + + + + Defines a reference to a Spring bean Id. + + + + + A reference to a user-service (or UserDetailsService bean) Id + + + + + Creates an in-memory UserDetailsService from a properties file or a list of "user" child elements. Usernames are converted to lower-case internally to allow for case-insensitive lookups, so this should not be used if case-sensitivity is required. + + + + Represents a user in the application. + + + + + + + A bean identifier, used for referring to the bean elsewhere in the context. + + + + + + + + The location of a Properties file where each line is in the format of username=password,grantedAuthority[,grantedAuthority][,enabled|disabled] + + + + + + + + The username assigned to the user. + + + + + The password assigned to the user. This may be hashed if the corresponding authentication provider supports hashing (remember to set the "hash" attribute of the "user-service" element). This attribute be omitted in the case where the data will not be used for authentication, but only for accessing authorities. If omitted, the namespace will generate a random value, preventing its accidental use for authentication. Cannot be empty. + + + + + One of more authorities granted to the user. Separate authorities with a comma (but no space). For example, "ROLE_USER,ROLE_ADMINISTRATOR" + + + + + Can be set to "true" to mark an account as locked and unusable. + + + + + Can be set to "true" to mark an account as disabled and unusable. + + + + + Causes creation of a JDBC-based UserDetailsService. + + + + A bean identifier, used for referring to the bean elsewhere in the context. + + + + + + + + The bean ID of the DataSource which provides the required tables. + + + + + Defines a reference to a cache for use with a UserDetailsService. + + + + + An SQL statement to query a username, password, and enabled status given a username. Default is "select username,password,enabled from users where username = ?" + + + + + An SQL statement to query for a user's granted authorities given a username. The default is "select username, authority from authorities where username = ?" + + + + + An SQL statement to query user's group authorities given a username. The default is "select g.id, g.group_name, ga.authority from groups g, group_members gm, group_authorities ga where gm.username = ? and g.id = ga.group_id and g.id = gm.group_id" + + + + + A non-empty string prefix that will be added to role strings loaded from persistent storage (e.g. "ROLE_"). Use the value "none" for no prefix in cases where the default is non-empty. + + + + + + Used to indicate that a filter bean declaration should be incorporated into the security filter chain. + + + + + + + + The filter immediately after which the custom-filter should be placed in the chain. This feature will only be needed by advanced users who wish to mix their own filters into the security filter chain and have some knowledge of the standard Spring Security filters. The filter names map to specific Spring Security implementation filters. + + + + + The filter immediately before which the custom-filter should be placed in the chain + + + + + The explicit position at which the custom-filter should be placed in the chain. Use if you are replacing a standard filter. + + + + + + + The filter immediately after which the custom-filter should be placed in the chain. This feature will only be needed by advanced users who wish to mix their own filters into the security filter chain and have some knowledge of the standard Spring Security filters. The filter names map to specific Spring Security implementation filters. + + + + + + + The filter immediately before which the custom-filter should be placed in the chain + + + + + + + The explicit position at which the custom-filter should be placed in the chain. Use if you are replacing a standard filter. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Element for configuration of the AddHeadersFilter. Enables easy setting for the X-Frame-Options, X-XSS-Protection and X-Content-Type-Options headers. + + + + + + + + + + + + + Enable basic clickjacking support for newer browsers (IE8+), will set the X-Frame-Options header. + + + + + Specify the policy to use for the X-Frame-Options-Header. + + + + + + + + + + + + Specify the origin to use when ALLOW-FROM is chosen. + + + + + + + Enable basic XSS browser protection, supported by newer browsers (IE8+), will set the X-XSS-Protection header. + + + + + + enable or disable the X-XSS-Protection header. Default is 'true' meaning it is enabled. + + + + + Add mode=block to the header or not, default is on. + + + + + + + Add a X-Content-Type-Options header to the resopnse. Value is always 'nosniff'. + + + + + Add additional headers to the response. + + + + + The name of the header to add. + + + + + The value for the header. + + + + + diff --git a/config/src/test/groovy/org/springframework/security/config/doc/XsdDocumentedTests.groovy b/config/src/test/groovy/org/springframework/security/config/doc/XsdDocumentedTests.groovy index 4ad24b87fe7..c5c9bfca1a4 100644 --- a/config/src/test/groovy/org/springframework/security/config/doc/XsdDocumentedTests.groovy +++ b/config/src/test/groovy/org/springframework/security/config/doc/XsdDocumentedTests.groovy @@ -29,7 +29,7 @@ class XsdDocumentedTests extends Specification { @Shared def appendix = new File('../docs/manual/src/docbook/appendix-namespace.xml') @Shared def appendixRoot = new XmlSlurper().parse(appendix) - @Shared File schemaDocument = new File('src/main/resources/org/springframework/security/config/spring-security-3.1.xsd') + @Shared File schemaDocument = new File('src/main/resources/org/springframework/security/config/spring-security-3.2.xsd') @Shared Map elementNameToElement def setupSpec() { @@ -64,8 +64,8 @@ class XsdDocumentedTests extends Specification { def 'the latest schema is being validated'() { when: 'all the schemas are found' def schemas = schemaDocument.getParentFile().list().findAll { it.endsWith('.xsd') } - then: 'the count is equal to 7, if not then schemaDocument needs updated' - schemas.size() == 7 + then: 'the count is equal to 8, if not then schemaDocument needs updated' + schemas.size() == 8 } /** diff --git a/config/src/test/resources/org/springframework/security/util/filtertest-valid.xml b/config/src/test/resources/org/springframework/security/util/filtertest-valid.xml index a2cda067c62..f8e58820e34 100644 --- a/config/src/test/resources/org/springframework/security/util/filtertest-valid.xml +++ b/config/src/test/resources/org/springframework/security/util/filtertest-valid.xml @@ -24,7 +24,7 @@ xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd - http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd"> + http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd"> diff --git a/docs/manual/src/docbook/appendix-namespace.xml b/docs/manual/src/docbook/appendix-namespace.xml index 88efb40deb3..c197c2fb4cd 100644 --- a/docs/manual/src/docbook/appendix-namespace.xml +++ b/docs/manual/src/docbook/appendix-namespace.xml @@ -204,6 +204,68 @@ access-control. +
+ <literal><add-headers></literal> + This element allows for configuring additional (security) headers to be send with the response. + It enables easy configuration for several headers and also allows for setting custom headers through + the header element. + + X-Frame-Options - Can be set using the + frame-options element. The + X-Frame-Options + header can be used to prevent clickjacking attacks. + X-XSS-Protection - Can be set using the + xss-protection element. + The X-XSS-Protection + header can be used by browser to do basic control. + X-Content-Type-Options - Can be set using the + content-type-options element. The + X-Content-Type-Options header prevents Internet Explorer from + MIME-sniffing a response away from the declared content-type. This also applies to Google + Chrome, when downloading extensions. + + + +
+ <literal><frame-options></literal> +
+
+
+
+
+
+ <literal><xss-protection></literal> +
+
+
+
+
+
+ <literal><content-type-options></literal> +
+
+ <literal><header></literal> +
+
+
+
+
+
+ Parent Elements of <literal><add-headers></literal> + + http + +
+
+ Child Elements of <literal><add-headers></literal> + + frame-options + xss-protection + content-type-options + header + +
+
Child Elements of <http> @@ -222,6 +284,7 @@ request-cache session-management x509 + add-headers
diff --git a/web/src/main/java/org/springframework/security/web/headers/AddHeadersFilter.java b/web/src/main/java/org/springframework/security/web/headers/AddHeadersFilter.java new file mode 100644 index 00000000000..35ce92a739a --- /dev/null +++ b/web/src/main/java/org/springframework/security/web/headers/AddHeadersFilter.java @@ -0,0 +1,67 @@ +/* + * Copyright 2002-2012 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.security.web.headers; + +import org.springframework.web.filter.GenericFilterBean; + +import javax.servlet.FilterChain; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletResponse; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +/** + * Filter implementation to add headers to the current request. Can be useful to add certain headers which enable + * browser protection. Like X-Frame-Options, X-XSS-Protection and X-Content-Type-Options. + * + * @author Marten Deinum + * @since 3.2 + * + */ +public class AddHeadersFilter extends GenericFilterBean { + + /** Map of headers to add to a response */ + private final Map headers = new HashMap(); + + @Override + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { + chain.doFilter(request, response); + + if (response instanceof HttpServletResponse) { + for (Map.Entry header : headers.entrySet()) { + String name = header.getKey(); + String value = header.getValue(); + if (logger.isDebugEnabled()) { + logger.debug("Adding header '" + name + "' with value '"+value +"'"); + } + ((HttpServletResponse) response).setHeader(header.getKey(), header.getValue()); + } + } + } + + public void setHeaders(Map headers) { + this.headers.clear(); + this.headers.putAll(headers); + } + + public void addHeader(String name, String value) { + headers.put(name, value); + } +} From 6bb986331bb58762a56adfe9821586f46e9787d4 Mon Sep 17 00:00:00 2001 From: Marten Deinum Date: Wed, 2 Jan 2013 16:44:51 +0100 Subject: [PATCH 02/11] Fixed type and wrongly named attribute. --- .../config/http/AddHeadersBeanDefinitionParser.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config/src/main/java/org/springframework/security/config/http/AddHeadersBeanDefinitionParser.java b/config/src/main/java/org/springframework/security/config/http/AddHeadersBeanDefinitionParser.java index 1d8ce168a19..0b189880df5 100644 --- a/config/src/main/java/org/springframework/security/config/http/AddHeadersBeanDefinitionParser.java +++ b/config/src/main/java/org/springframework/security/config/http/AddHeadersBeanDefinitionParser.java @@ -39,7 +39,7 @@ public class AddHeadersBeanDefinitionParser implements BeanDefinitionParser { private static final String ATT_BLOCK = "block"; private static final String ATT_POLICY = "policy"; - private static final String ATT_ORIGIN = "policy"; + private static final String ATT_ORIGIN = "origin"; private static final String ATT_NAME = "name"; private static final String ATT_VALUE = "value"; @@ -51,7 +51,7 @@ public class AddHeadersBeanDefinitionParser implements BeanDefinitionParser { private static final String XSS_PROTECTION_HEADER = "X-XSS-Protection"; private static final String FRAME_OPTIONS_HEADER = "X-Frame-Options"; - private static final String CONENT_TYPE_OPTIONS_HEADER = "X-Content-Type-Options"; + private static final String CONTENT_TYPE_OPTIONS_HEADER = "X-Content-Type-Options"; private static final String ALLOW_FROM = "ALLOW-FROM"; @@ -85,7 +85,7 @@ public BeanDefinition parse(Element element, ParserContext parserContext) { } if (contentTypeElt != null) { - headers.put(CONENT_TYPE_OPTIONS_HEADER, "nosniff"); + headers.put(CONTENT_TYPE_OPTIONS_HEADER, "nosniff"); } List headerEtls = DomUtils.getChildElementsByTagName(element, GENERIC_HEADER_ELEMENT); From abfa4945d3518123a241df454d83eee6d6e55bfd Mon Sep 17 00:00:00 2001 From: Marten Deinum Date: Fri, 21 Dec 2012 14:56:18 +0100 Subject: [PATCH 03/11] Issues: SEC-2098, SEC-2099 AddHeadersFilter for setting security headers added including a bean definition parser for easy configuration of the headers. Enables easy configuration for the X-Frame-Options, X-XSS-Protection and X-Content-Type-Options headers. Also allows for additional headers to be added. --- config/convert_schema.sh | 4 +- .../security/config/Elements.java | 1 + .../config/SecurityNamespaceHandler.java | 2 +- .../http/AddHeadersBeanDefinitionParser.java | 98 + .../config/http/HttpConfigurationBuilder.java | 14 + .../security/config/http/SecurityFilters.java | 1 + .../main/resources/META-INF/spring.schemas | 3 +- .../security/config/spring-security-3.2.rnc | 782 ++++++++ .../security/config/spring-security-3.2.xsd | 1726 +++++++++++++++++ .../security/config/spring-security.xsl | 2 +- .../config/doc/XsdDocumentedTests.groovy | 6 +- .../security/util/filtertest-valid.xml | 2 +- .../manual/src/docbook/appendix-namespace.xml | 126 ++ .../web/headers/AddHeadersFilter.java | 66 + 14 files changed, 2824 insertions(+), 9 deletions(-) create mode 100644 config/src/main/java/org/springframework/security/config/http/AddHeadersBeanDefinitionParser.java create mode 100644 config/src/main/resources/org/springframework/security/config/spring-security-3.2.rnc create mode 100644 config/src/main/resources/org/springframework/security/config/spring-security-3.2.xsd create mode 100644 web/src/main/java/org/springframework/security/web/headers/AddHeadersFilter.java diff --git a/config/convert_schema.sh b/config/convert_schema.sh index d52f5eff8ef..f229457e730 100755 --- a/config/convert_schema.sh +++ b/config/convert_schema.sh @@ -3,9 +3,9 @@ pushd src/main/resources/org/springframework/security/config/ echo "Converting rnc file to xsd ..." -java -jar ~/bin/trang.jar spring-security-3.1.rnc spring-security-3.1.xsd +java -jar ~/bin/trang.jar spring-security-3.2.rnc spring-security-3.2.xsd echo "Applying XSL transformation to xsd ..." -xsltproc --output spring-security-3.1.xsd spring-security.xsl spring-security-3.1.xsd +xsltproc --output spring-security-3.2.xsd spring-security.xsl spring-security-3.2.xsd popd \ No newline at end of file diff --git a/config/src/main/java/org/springframework/security/config/Elements.java b/config/src/main/java/org/springframework/security/config/Elements.java index 3efc60f7d35..67f71a7ad94 100644 --- a/config/src/main/java/org/springframework/security/config/Elements.java +++ b/config/src/main/java/org/springframework/security/config/Elements.java @@ -54,4 +54,5 @@ public abstract class Elements { public static final String LDAP_PASSWORD_COMPARE = "password-compare"; public static final String DEBUG = "debug"; public static final String HTTP_FIREWALL = "http-firewall"; + public static final String ADD_HEADERS = "add-headers"; } diff --git a/config/src/main/java/org/springframework/security/config/SecurityNamespaceHandler.java b/config/src/main/java/org/springframework/security/config/SecurityNamespaceHandler.java index 41950fa2191..6e52a7987aa 100644 --- a/config/src/main/java/org/springframework/security/config/SecurityNamespaceHandler.java +++ b/config/src/main/java/org/springframework/security/config/SecurityNamespaceHandler.java @@ -180,7 +180,7 @@ private boolean namespaceMatchesVersion(Element element) { private boolean matchesVersionInternal(Element element) { String schemaLocation = element.getAttributeNS("http://www.w3.org/2001/XMLSchema-instance", "schemaLocation"); - return schemaLocation.matches("(?m).*spring-security-3\\.1.*.xsd.*") + return schemaLocation.matches("(?m).*spring-security-3\\.[12].*.xsd.*") || schemaLocation.matches("(?m).*spring-security.xsd.*") || !schemaLocation.matches("(?m).*spring-security.*"); } diff --git a/config/src/main/java/org/springframework/security/config/http/AddHeadersBeanDefinitionParser.java b/config/src/main/java/org/springframework/security/config/http/AddHeadersBeanDefinitionParser.java new file mode 100644 index 00000000000..2ba16e90d8d --- /dev/null +++ b/config/src/main/java/org/springframework/security/config/http/AddHeadersBeanDefinitionParser.java @@ -0,0 +1,98 @@ +/* + * Copyright 2002-2012 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.security.config.http; + +import org.springframework.beans.factory.config.BeanDefinition; +import org.springframework.beans.factory.support.BeanDefinitionBuilder; +import org.springframework.beans.factory.xml.BeanDefinitionParser; +import org.springframework.beans.factory.xml.ParserContext; +import org.springframework.security.web.headers.AddHeadersFilter; +import org.springframework.util.xml.DomUtils; +import org.w3c.dom.Element; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Parser for the {@code AddHeadersFilter}. + * + * @author Marten Deinum + * @since 3.2 + */ +public class AddHeadersBeanDefinitionParser implements BeanDefinitionParser { + + private static final String ATT_ENABLED = "enabled"; + private static final String ATT_BLOCK = "block"; + + private static final String ATT_POLICY = "policy"; + private static final String ATT_ORIGIN = "origin"; + + private static final String ATT_NAME = "name"; + private static final String ATT_VALUE = "value"; + + private static final String XSS_ELEMENT = "xss-protection"; + private static final String CONTENT_TYPE_ELEMENT = "content-type-options"; + private static final String FRAME_OPTIONS_ELEMENT = "frame-options"; + private static final String GENERIC_HEADER_ELEMENT = "header"; + + private static final String XSS_PROTECTION_HEADER = "X-XSS-Protection"; + private static final String FRAME_OPTIONS_HEADER = "X-Frame-Options"; + private static final String CONTENT_TYPE_OPTIONS_HEADER = "X-Content-Type-Options"; + + private static final String ALLOW_FROM = "ALLOW-FROM"; + + public BeanDefinition parse(Element element, ParserContext parserContext) { + BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(AddHeadersFilter.class); + final Map headers = new HashMap(); + + Element xssElt = DomUtils.getChildElementByTagName(element, XSS_ELEMENT); + Element contentTypeElt = DomUtils.getChildElementByTagName(element, CONTENT_TYPE_ELEMENT); + Element frameElt = DomUtils.getChildElementByTagName(element, FRAME_OPTIONS_ELEMENT); + + if (xssElt != null) { + boolean enabled = "true".equalsIgnoreCase(xssElt.getAttribute(ATT_ENABLED)); + boolean block = "true".equalsIgnoreCase(xssElt.getAttribute(ATT_BLOCK)); + + String value = enabled ? "1" : "0"; + if (enabled && block) { + value += "; mode=block"; + } + headers.put(XSS_PROTECTION_HEADER, value); + } + + if (frameElt != null) { + String header = frameElt.getAttribute(ATT_POLICY); + if (ALLOW_FROM.equals(header) ) { + String origin = frameElt.getAttribute(ATT_ORIGIN); + header += " " + origin; + } + headers.put(FRAME_OPTIONS_HEADER, header); + } + + if (contentTypeElt != null) { + headers.put(CONTENT_TYPE_OPTIONS_HEADER, "nosniff"); + } + + List headerEtls = DomUtils.getChildElementsByTagName(element, GENERIC_HEADER_ELEMENT); + for (Element headerEtl : headerEtls) { + headers.put(headerEtl.getAttribute(ATT_NAME), headerEtl.getAttribute(ATT_VALUE)); + } + + builder.addPropertyValue("headers", headers); + return builder.getBeanDefinition(); + } +} diff --git a/config/src/main/java/org/springframework/security/config/http/HttpConfigurationBuilder.java b/config/src/main/java/org/springframework/security/config/http/HttpConfigurationBuilder.java index a568307d4e7..3f4f717573d 100644 --- a/config/src/main/java/org/springframework/security/config/http/HttpConfigurationBuilder.java +++ b/config/src/main/java/org/springframework/security/config/http/HttpConfigurationBuilder.java @@ -117,6 +117,7 @@ class HttpConfigurationBuilder { private final BeanReference portResolver; private BeanReference fsi; private BeanReference requestCache; + private BeanDefinition addHeadersFilter; public HttpConfigurationBuilder(Element element, ParserContext pc, BeanReference portMapper, BeanReference portResolver, BeanReference authenticationManager) { @@ -151,6 +152,7 @@ public HttpConfigurationBuilder(Element element, ParserContext pc, createJaasApiFilter(); createChannelProcessingFilter(); createFilterSecurityInterceptor(authenticationManager); + createAddHeadersFilter(); } @SuppressWarnings("rawtypes") @@ -554,6 +556,14 @@ private void createFilterSecurityInterceptor(BeanReference authManager) { this.fsi = new RuntimeBeanReference(fsiId); } + private void createAddHeadersFilter() { + Element elmt = DomUtils.getChildElementByTagName(httpElt, Elements.ADD_HEADERS); + if (elmt != null) { + this.addHeadersFilter = new AddHeadersBeanDefinitionParser().parse(elmt, pc); + } + + } + BeanReference getSessionStrategy() { return sessionStrategyRef; } @@ -601,6 +611,10 @@ List getFilters() { filters.add(new OrderDecorator(requestCacheAwareFilter, REQUEST_CACHE_FILTER)); } + if (addHeadersFilter != null) { + filters.add(new OrderDecorator(addHeadersFilter, ADD_HEADERS_FILTER)); + } + return filters; } } diff --git a/config/src/main/java/org/springframework/security/config/http/SecurityFilters.java b/config/src/main/java/org/springframework/security/config/http/SecurityFilters.java index 58a9bc491ab..3ff9834e9ae 100644 --- a/config/src/main/java/org/springframework/security/config/http/SecurityFilters.java +++ b/config/src/main/java/org/springframework/security/config/http/SecurityFilters.java @@ -29,6 +29,7 @@ enum SecurityFilters { CONCURRENT_SESSION_FILTER, /** {@link WebAsyncManagerIntegrationFilter} */ WEB_ASYNC_MANAGER_FILTER, + ADD_HEADERS_FILTER, LOGOUT_FILTER, X509_FILTER, PRE_AUTH_FILTER, diff --git a/config/src/main/resources/META-INF/spring.schemas b/config/src/main/resources/META-INF/spring.schemas index 4d623cd673d..5c543a8c642 100644 --- a/config/src/main/resources/META-INF/spring.schemas +++ b/config/src/main/resources/META-INF/spring.schemas @@ -1,4 +1,5 @@ -http\://www.springframework.org/schema/security/spring-security.xsd=org/springframework/security/config/spring-security-3.1.xsd +http\://www.springframework.org/schema/security/spring-security.xsd=org/springframework/security/config/spring-security-3.2.xsd +http\://www.springframework.org/schema/security/spring-security-3.2.xsd=org/springframework/security/config/spring-security-3.2.xsd http\://www.springframework.org/schema/security/spring-security-3.1.xsd=org/springframework/security/config/spring-security-3.1.xsd http\://www.springframework.org/schema/security/spring-security-3.0.3.xsd=org/springframework/security/config/spring-security-3.0.3.xsd http\://www.springframework.org/schema/security/spring-security-3.0.xsd=org/springframework/security/config/spring-security-3.0.xsd diff --git a/config/src/main/resources/org/springframework/security/config/spring-security-3.2.rnc b/config/src/main/resources/org/springframework/security/config/spring-security-3.2.rnc new file mode 100644 index 00000000000..29cc8d81cfa --- /dev/null +++ b/config/src/main/resources/org/springframework/security/config/spring-security-3.2.rnc @@ -0,0 +1,782 @@ +namespace a = "http://relaxng.org/ns/compatibility/annotations/1.0" +datatypes xsd = "http://www.w3.org/2001/XMLSchema-datatypes" + +default namespace = "http://www.springframework.org/schema/security" + +start = http | ldap-server | authentication-provider | ldap-authentication-provider | any-user-service | ldap-server | ldap-authentication-provider + +hash = + ## Defines the hashing algorithm used on user passwords. We recommend strongly against using MD4, as it is a very weak hashing algorithm. + attribute hash {"plaintext" | "sha" | "sha-256" | "md5" | "md4" | "{sha}" | "{ssha}"} +base64 = + ## Whether a string should be base64 encoded + attribute base64 {xsd:boolean} +request-matcher = + ## Supersedes the 'path-type' attribute. Defines the strategy use for matching incoming requests. Currently the options are 'ant' (for ant path patterns), 'regex' for regular expressions and 'ciRegex' for case-insensitive regular expressions. + attribute request-matcher {"ant" | "regex" | "ciRegex"} +path-type = + ## Deprecated. Use request-matcher instead. + attribute path-type {"ant" | "regex"} +port = + ## Specifies an IP port number. Used to configure an embedded LDAP server, for example. + attribute port { xsd:positiveInteger } +url = + ## Specifies a URL. + attribute url { xsd:token } +id = + ## A bean identifier, used for referring to the bean elsewhere in the context. + attribute id {xsd:token} +name = + ## A bean identifier, used for referring to the bean elsewhere in the context. + attribute name {xsd:token} +ref = + ## Defines a reference to a Spring bean Id. + attribute ref {xsd:token} + +cache-ref = + ## Defines a reference to a cache for use with a UserDetailsService. + attribute cache-ref {xsd:token} + +user-service-ref = + ## A reference to a user-service (or UserDetailsService bean) Id + attribute user-service-ref {xsd:token} + +authentication-manager-ref = + ## A reference to an AuthenticationManager bean + attribute authentication-manager-ref {xsd:token} + +data-source-ref = + ## A reference to a DataSource bean + attribute data-source-ref {xsd:token} + + + +debug = + ## Enables Spring Security debugging infrastructure. This will provide human-readable (multi-line) debugging information to monitor requests coming into the security filters. This may include sensitive information, such as request parameters or headers, and should only be used in a development environment. + element debug {empty} + +password-encoder = + ## element which defines a password encoding strategy. Used by an authentication provider to convert submitted passwords to hashed versions, for example. + element password-encoder {password-encoder.attlist, salt-source?} +password-encoder.attlist &= + ref | (hash? & base64?) + +salt-source = + ## Password salting strategy. A system-wide constant or a property from the UserDetails object can be used. + element salt-source {user-property | system-wide | ref} +user-property = + ## A property of the UserDetails object which will be used as salt by a password encoder. Typically something like "username" might be used. + attribute user-property {xsd:token} +system-wide = + ## A single value that will be used as the salt for a password encoder. + attribute system-wide {xsd:token} + +role-prefix = + ## A non-empty string prefix that will be added to role strings loaded from persistent storage (e.g. "ROLE_"). Use the value "none" for no prefix in cases where the default is non-empty. + attribute role-prefix {xsd:token} + +use-expressions = + ## Enables the use of expressions in the 'access' attributes in elements rather than the traditional list of configuration attributes. Defaults to 'false'. If enabled, each attribute should contain a single boolean expression. If the expression evaluates to 'true', access will be granted. + attribute use-expressions {xsd:boolean} + +ldap-server = + ## Defines an LDAP server location or starts an embedded server. The url indicates the location of a remote server. If no url is given, an embedded server will be started, listening on the supplied port number. The port is optional and defaults to 33389. A Spring LDAP ContextSource bean will be registered for the server with the id supplied. + element ldap-server {ldap-server.attlist} +ldap-server.attlist &= id? +ldap-server.attlist &= (url | port)? +ldap-server.attlist &= + ## Username (DN) of the "manager" user identity which will be used to authenticate to a (non-embedded) LDAP server. If omitted, anonymous access will be used. + attribute manager-dn {xsd:string}? +ldap-server.attlist &= + ## The password for the manager DN. This is required if the manager-dn is specified. + attribute manager-password {xsd:string}? +ldap-server.attlist &= + ## Explicitly specifies an ldif file resource to load into an embedded LDAP server. The default is classpath*:*.ldiff + attribute ldif { xsd:string }? +ldap-server.attlist &= + ## Optional root suffix for the embedded LDAP server. Default is "dc=springframework,dc=org" + attribute root { xsd:string }? + +ldap-server-ref-attribute = + ## The optional server to use. If omitted, and a default LDAP server is registered (using with no Id), that server will be used. + attribute server-ref {xsd:token} + + +group-search-filter-attribute = + ## Group search filter. Defaults to (uniqueMember={0}). The substituted parameter is the DN of the user. + attribute group-search-filter {xsd:token} +group-search-base-attribute = + ## Search base for group membership searches. Defaults to "" (searching from the root). + attribute group-search-base {xsd:token} +user-search-filter-attribute = + ## The LDAP filter used to search for users (optional). For example "(uid={0})". The substituted parameter is the user's login name. + attribute user-search-filter {xsd:token} +user-search-base-attribute = + ## Search base for user searches. Defaults to "". Only used with a 'user-search-filter'. + attribute user-search-base {xsd:token} +group-role-attribute-attribute = + ## The LDAP attribute name which contains the role name which will be used within Spring Security. Defaults to "cn". + attribute group-role-attribute {xsd:token} +user-details-class-attribute = + ## Allows the objectClass of the user entry to be specified. If set, the framework will attempt to load standard attributes for the defined class into the returned UserDetails object + attribute user-details-class {"person" | "inetOrgPerson"} +user-context-mapper-attribute = + ## Allows explicit customization of the loaded user object by specifying a UserDetailsContextMapper bean which will be called with the context information from the user's directory entry + attribute user-context-mapper-ref {xsd:token} + + +ldap-user-service = + ## This element configures a LdapUserDetailsService which is a combination of a FilterBasedLdapUserSearch and a DefaultLdapAuthoritiesPopulator. + element ldap-user-service {ldap-us.attlist} +ldap-us.attlist &= id? +ldap-us.attlist &= + ldap-server-ref-attribute? +ldap-us.attlist &= + user-search-filter-attribute? +ldap-us.attlist &= + user-search-base-attribute? +ldap-us.attlist &= + group-search-filter-attribute? +ldap-us.attlist &= + group-search-base-attribute? +ldap-us.attlist &= + group-role-attribute-attribute? +ldap-us.attlist &= + cache-ref? +ldap-us.attlist &= + role-prefix? +ldap-us.attlist &= + (user-details-class-attribute | user-context-mapper-attribute)? + +ldap-authentication-provider = + ## Sets up an ldap authentication provider + element ldap-authentication-provider {ldap-ap.attlist, password-compare-element?} +ldap-ap.attlist &= + ldap-server-ref-attribute? +ldap-ap.attlist &= + user-search-base-attribute? +ldap-ap.attlist &= + user-search-filter-attribute? +ldap-ap.attlist &= + group-search-base-attribute? +ldap-ap.attlist &= + group-search-filter-attribute? +ldap-ap.attlist &= + group-role-attribute-attribute? +ldap-ap.attlist &= + ## A specific pattern used to build the user's DN, for example "uid={0},ou=people". The key "{0}" must be present and will be substituted with the username. + attribute user-dn-pattern {xsd:token}? +ldap-ap.attlist &= + role-prefix? +ldap-ap.attlist &= + (user-details-class-attribute | user-context-mapper-attribute)? + +password-compare-element = + ## Specifies that an LDAP provider should use an LDAP compare operation of the user's password to authenticate the user + element password-compare {password-compare.attlist, password-encoder?} + +password-compare.attlist &= + ## The attribute in the directory which contains the user password. Defaults to "userPassword". + attribute password-attribute {xsd:token}? +password-compare.attlist &= + hash? + +intercept-methods = + ## Can be used inside a bean definition to add a security interceptor to the bean and set up access configuration attributes for the bean's methods + element intercept-methods {intercept-methods.attlist, protect+} +intercept-methods.attlist &= + ## Optional AccessDecisionManager bean ID to be used by the created method security interceptor. + attribute access-decision-manager-ref {xsd:token}? + + +protect = + ## Defines a protected method and the access control configuration attributes that apply to it. We strongly advise you NOT to mix "protect" declarations with any services provided "global-method-security". + element protect {protect.attlist, empty} +protect.attlist &= + ## A method name + attribute method {xsd:token} +protect.attlist &= + ## Access configuration attributes list that applies to the method, e.g. "ROLE_A,ROLE_B". + attribute access {xsd:token} + +method-security-metadata-source = + ## Creates a MethodSecurityMetadataSource instance + element method-security-metadata-source {msmds.attlist, protect+} +msmds.attlist &= id? + +msmds.attlist &= use-expressions? + +global-method-security = + ## Provides method security for all beans registered in the Spring application context. Specifically, beans will be scanned for matches with the ordered list of "protect-pointcut" sub-elements, Spring Security annotations and/or. Where there is a match, the beans will automatically be proxied and security authorization applied to the methods accordingly. If you use and enable all four sources of method security metadata (ie "protect-pointcut" declarations, expression annotations, @Secured and also JSR250 security annotations), the metadata sources will be queried in that order. In practical terms, this enables you to use XML to override method security metadata expressed in annotations. If using annotations, the order of precedence is EL-based (@PreAuthorize etc.), @Secured and finally JSR-250. + element global-method-security {global-method-security.attlist, (pre-post-annotation-handling | expression-handler)?, protect-pointcut*, after-invocation-provider*} +global-method-security.attlist &= + ## Specifies whether the use of Spring Security's pre and post invocation annotations (@PreFilter, @PreAuthorize, @PostFilter, @PostAuthorize) should be enabled for this application context. Defaults to "disabled". + attribute pre-post-annotations {"disabled" | "enabled" }? +global-method-security.attlist &= + ## Specifies whether the use of Spring Security's @Secured annotations should be enabled for this application context. Defaults to "disabled". + attribute secured-annotations {"disabled" | "enabled" }? +global-method-security.attlist &= + ## Specifies whether JSR-250 style attributes are to be used (for example "RolesAllowed"). This will require the javax.annotation.security classes on the classpath. Defaults to "disabled". + attribute jsr250-annotations {"disabled" | "enabled" }? +global-method-security.attlist &= + ## Optional AccessDecisionManager bean ID to override the default used for method security. + attribute access-decision-manager-ref {xsd:token}? +global-method-security.attlist &= + ## Optional RunAsmanager implementation which will be used by the configured MethodSecurityInterceptor + attribute run-as-manager-ref {xsd:token}? +global-method-security.attlist &= + ## Allows the advice "order" to be set for the method security interceptor. + attribute order {xsd:token}? +global-method-security.attlist &= + ## If true, class based proxying will be used instead of interface based proxying. + attribute proxy-target-class {xsd:boolean}? +global-method-security.attlist &= + ## Can be used to specify that AspectJ should be used instead of the default Spring AOP. If set, secured classes must be woven with the AnnotationSecurityAspect from the spring-security-aspects module. + attribute mode {"aspectj"}? +global-method-security.attlist &= + ## An external MethodSecurityMetadataSource instance can be supplied which will take priority over other sources (such as the default annotations). + attribute metadata-source-ref {xsd:token}? +global-method-security.attlist &= + authentication-manager-ref? + + +after-invocation-provider = + ## Allows addition of extra AfterInvocationProvider beans which should be called by the MethodSecurityInterceptor created by global-method-security. + element after-invocation-provider {ref} + +pre-post-annotation-handling = + ## Allows the default expression-based mechanism for handling Spring Security's pre and post invocation annotations (@PreFilter, @PreAuthorize, @PostFilter, @PostAuthorize) to be replace entirely. Only applies if these annotations are enabled. + element pre-post-annotation-handling {invocation-attribute-factory, pre-invocation-advice, post-invocation-advice} + +invocation-attribute-factory = + ## Defines the PrePostInvocationAttributeFactory instance which is used to generate pre and post invocation metadata from the annotated methods. + element invocation-attribute-factory {ref} + +pre-invocation-advice = + ## Customizes the PreInvocationAuthorizationAdviceVoter with the ref as the PreInvocationAuthorizationAdviceVoter for the element. + element pre-invocation-advice {ref} + +post-invocation-advice = + ## Customizes the PostInvocationAdviceProvider with the ref as the PostInvocationAuthorizationAdvice for the element. + element post-invocation-advice {ref} + + +expression-handler = + ## Defines the SecurityExpressionHandler instance which will be used if expression-based access-control is enabled. A default implementation (with no ACL support) will be used if not supplied. + element expression-handler {ref} + +protect-pointcut = + ## Defines a protected pointcut and the access control configuration attributes that apply to it. Every bean registered in the Spring application context that provides a method that matches the pointcut will receive security authorization. + element protect-pointcut {protect-pointcut.attlist, empty} +protect-pointcut.attlist &= + ## An AspectJ expression, including the 'execution' keyword. For example, 'execution(int com.foo.TargetObject.countLength(String))' (without the quotes). + attribute expression {xsd:string} +protect-pointcut.attlist &= + ## Access configuration attributes list that applies to all methods matching the pointcut, e.g. "ROLE_A,ROLE_B" + attribute access {xsd:token} + +http-firewall = + ## Allows a custom instance of HttpFirewall to be injected into the FilterChainProxy created by the namespace. + element http-firewall {ref} + +http = + ## Container element for HTTP security configuration. Multiple elements can now be defined, each with a specific pattern to which the enclosed security configuration applies. A pattern can also be configured to bypass Spring Security's filters completely by setting the "secured" attribute to "false". + element http {http.attlist, (intercept-url* & access-denied-handler? & form-login? & openid-login? & x509? & jee? & http-basic? & logout? & session-management & remember-me? & anonymous? & port-mappings & custom-filter* & request-cache? & expression-handler? & add-headers?) } +http.attlist &= + ## The request URL pattern which will be mapped to the filter chain created by this element. If omitted, the filter chain will match all requests. + attribute pattern {xsd:token}? +http.attlist &= + ## When set to 'none', requests matching the pattern attribute will be ignored by Spring Security. No security filters will be applied and no SecurityContext will be available. If set, the element must be empty, with no children. + attribute security {"none"}? +http.attlist &= + ## Allows a RequestMatcher instance to be used, as an alternative to pattern-matching. + attribute request-matcher-ref { xsd:token }? +http.attlist &= + ## Automatically registers a login form, BASIC authentication, anonymous authentication, logout services, remember-me and servlet-api-integration. If set to "true", all of these capabilities are added (although you can still customize the configuration of each by providing the respective element). If unspecified, defaults to "false". + attribute auto-config {xsd:boolean}? +http.attlist &= + use-expressions? +http.attlist &= + ## Controls the eagerness with which an HTTP session is created by Spring Security classes. If not set, defaults to "ifRequired". If "stateless" is used, this implies that the application guarantees that it will not create a session. This differs from the use of "never" which mans that Spring Security will not create a session, but will make use of one if the application does. + attribute create-session {"ifRequired" | "always" | "never" | "stateless"}? +http.attlist &= + ## A reference to a SecurityContextRepository bean. This can be used to customize how the SecurityContext is stored between requests. + attribute security-context-repository-ref {xsd:token}? +http.attlist &= + request-matcher? +http.attlist &= + ## Deprecated. Use request-matcher instead. + path-type? +http.attlist &= + ## Provides versions of HttpServletRequest security methods such as isUserInRole() and getPrincipal() which are implemented by accessing the Spring SecurityContext. Defaults to "true". + attribute servlet-api-provision {xsd:boolean}? +http.attlist &= + ## If available, runs the request as the Subject acquired from the JaasAuthenticationToken. Defaults to "false". + attribute jaas-api-provision {xsd:boolean}? +http.attlist &= + ## Optional attribute specifying the ID of the AccessDecisionManager implementation which should be used for authorizing HTTP requests. + attribute access-decision-manager-ref {xsd:token}? +http.attlist &= + ## Optional attribute specifying the realm name that will be used for all authentication features that require a realm name (eg BASIC and Digest authentication). If unspecified, defaults to "Spring Security Application". + attribute realm {xsd:token}? +http.attlist &= + ## Allows a customized AuthenticationEntryPoint to be set on the ExceptionTranslationFilter. + attribute entry-point-ref {xsd:token}? +http.attlist &= + ## Corresponds to the observeOncePerRequest property of FilterSecurityInterceptor. Defaults to "true" + attribute once-per-request {xsd:boolean}? +http.attlist &= + ## Deprecated in favour of the access-denied-handler element. + attribute access-denied-page {xsd:token}? +http.attlist &= + ## Prevents the jsessionid parameter from being added to rendered URLs. + attribute disable-url-rewriting {xsd:boolean}? +http.attlist &= + ## Exposes the list of filters defined by this configuration under this bean name in the application context. + name? +http.attlist &= + authentication-manager-ref? + +access-denied-handler = + ## Defines the access-denied strategy that should be used. An access denied page can be defined or a reference to an AccessDeniedHandler instance. + element access-denied-handler {access-denied-handler.attlist, empty} +access-denied-handler.attlist &= (ref | access-denied-handler-page) + +access-denied-handler-page = + ## The access denied page that an authenticated user will be redirected to if they request a page which they don't have the authority to access. + attribute error-page {xsd:token} + +intercept-url = + ## Specifies the access attributes and/or filter list for a particular set of URLs. + element intercept-url {intercept-url.attlist, empty} +intercept-url.attlist &= + ## The pattern which defines the URL path. The content will depend on the type set in the containing http element, so will default to ant path syntax. + attribute pattern {xsd:token} +intercept-url.attlist &= + ## The access configuration attributes that apply for the configured path. + attribute access {xsd:token}? +intercept-url.attlist &= + ## The HTTP Method for which the access configuration attributes should apply. If not specified, the attributes will apply to any method. + attribute method {"GET" | "DELETE" | "HEAD" | "OPTIONS" | "POST" | "PUT" | "TRACE"}? + +intercept-url.attlist &= + ## The filter list for the path. Currently can be set to "none" to remove a path from having any filters applied. The full filter stack (consisting of all filters created by the namespace configuration, and any added using 'custom-filter'), will be applied to any other paths. + attribute filters {"none"}? +intercept-url.attlist &= + ## Used to specify that a URL must be accessed over http or https, or that there is no preference. The value should be "http", "https" or "any", respectively. + attribute requires-channel {xsd:token}? + +logout = + ## Incorporates a logout processing filter. Most web applications require a logout filter, although you may not require one if you write a controller to provider similar logic. + element logout {logout.attlist, empty} +logout.attlist &= + ## Specifies the URL that will cause a logout. Spring Security will initialize a filter that responds to this particular URL. Defaults to /j_spring_security_logout if unspecified. + attribute logout-url {xsd:token}? +logout.attlist &= + ## Specifies the URL to display once the user has logged out. If not specified, defaults to /. + attribute logout-success-url {xsd:token}? +logout.attlist &= + ## Specifies whether a logout also causes HttpSession invalidation, which is generally desirable. If unspecified, defaults to true. + attribute invalidate-session {xsd:boolean}? +logout.attlist &= + ## A reference to a LogoutSuccessHandler implementation which will be used to determine the destination to which the user is taken after logging out. + attribute success-handler-ref {xsd:token}? +logout.attlist &= + ## A comma-separated list of the names of cookies which should be deleted when the user logs out + attribute delete-cookies {xsd:token}? + +request-cache = + ## Allow the RequestCache used for saving requests during the login process to be set + element request-cache {ref} + +form-login = + ## Sets up a form login configuration for authentication with a username and password + element form-login {form-login.attlist, empty} +form-login.attlist &= + ## The URL that the login form is posted to. If unspecified, it defaults to /j_spring_security_check. + attribute login-processing-url {xsd:token}? +form-login.attlist &= + ## The name of the request parameter which contains the username. Defaults to 'j_username'. + attribute username-parameter {xsd:token}? +form-login.attlist &= + ## The name of the request parameter which contains the password. Defaults to 'j_password'. + attribute password-parameter {xsd:token}? +form-login.attlist &= + ## The URL that will be redirected to after successful authentication, if the user's previous action could not be resumed. This generally happens if the user visits a login page without having first requested a secured operation that triggers authentication. If unspecified, defaults to the root of the application. + attribute default-target-url {xsd:token}? +form-login.attlist &= + ## Whether the user should always be redirected to the default-target-url after login. + attribute always-use-default-target {xsd:boolean}? +form-login.attlist &= + ## The URL for the login page. If no login URL is specified, Spring Security will automatically create a login URL at /spring_security_login and a corresponding filter to render that login URL when requested. + attribute login-page {xsd:token}? +form-login.attlist &= + ## The URL for the login failure page. If no login failure URL is specified, Spring Security will automatically create a failure login URL at /spring_security_login?login_error and a corresponding filter to render that login failure URL when requested. + attribute authentication-failure-url {xsd:token}? +form-login.attlist &= + ## Reference to an AuthenticationSuccessHandler bean which should be used to handle a successful authentication request. Should not be used in combination with default-target-url (or always-use-default-target-url) as the implementation should always deal with navigation to the subsequent destination + attribute authentication-success-handler-ref {xsd:token}? +form-login.attlist &= + ## Reference to an AuthenticationFailureHandler bean which should be used to handle a failed authentication request. Should not be used in combination with authentication-failure-url as the implementation should always deal with navigation to the subsequent destination + attribute authentication-failure-handler-ref {xsd:token}? +form-login.attlist &= + ## Reference to an AuthenticationDetailsSource which will be used by the authentication filter + attribute authentication-details-source-ref {xsd:token}? + + +openid-login = + ## Sets up form login for authentication with an Open ID identity + element openid-login {form-login.attlist, user-service-ref?, attribute-exchange*} + +attribute-exchange = + ## Sets up an attribute exchange configuration to request specified attributes from the OpenID identity provider. When multiple elements are used, each must have an identifier-attribute attribute. Each configuration will be matched in turn against the supplied login identifier until a match is found. + element attribute-exchange {attribute-exchange.attlist, openid-attribute+} + +attribute-exchange.attlist &= + ## A regular expression which will be compared against the claimed identity, when deciding which attribute-exchange configuration to use during authentication. + attribute identifier-match {xsd:token}? + +openid-attribute = + ## Attributes used when making an OpenID AX Fetch Request + element openid-attribute {openid-attribute.attlist} + +openid-attribute.attlist &= + ## Specifies the name of the attribute that you wish to get back. For example, email. + attribute name {xsd:token} +openid-attribute.attlist &= + ## Specifies the attribute type. For example, http://axschema.org/contact/email. See your OP's documentation for valid attribute types. + attribute type {xsd:token} +openid-attribute.attlist &= + ## Specifies if this attribute is required to the OP, but does not error out if the OP does not return the attribute. Default is false. + attribute required {xsd:boolean}? +openid-attribute.attlist &= + ## Specifies the number of attributes that you wish to get back. For example, return 3 emails. The default value is 1. + attribute count {xsd:int}? + + +filter-chain-map = + ## Used to explicitly configure a FilterChainProxy instance with a FilterChainMap + element filter-chain-map {filter-chain-map.attlist, filter-chain+} +filter-chain-map.attlist &= + ## Deprecated. Use request-matcher instead. + path-type? +filter-chain-map.attlist &= + request-matcher? + +filter-chain = + ## Used within to define a specific URL pattern and the list of filters which apply to the URLs matching that pattern. When multiple filter-chain elements are assembled in a list in order to configure a FilterChainProxy, the most specific patterns must be placed at the top of the list, with most general ones at the bottom. + element filter-chain {filter-chain.attlist, empty} +filter-chain.attlist &= + (pattern | request-matcher-ref) +filter-chain.attlist &= + ## A comma separated list of bean names that implement Filter that should be processed for this FilterChain. If the value is none, then no Filters will be used for this FilterChain. + attribute filters {xsd:token} + +pattern = + ## The request URL pattern which will be mapped to the FilterChain. + attribute pattern {xsd:token} +request-matcher-ref = + ## Allows a RequestMatcher instance to be used, as an alternative to pattern-matching. + attribute request-matcher-ref {xsd:token} + +filter-security-metadata-source = + ## Used to explicitly configure a FilterSecurityMetadataSource bean for use with a FilterSecurityInterceptor. Usually only needed if you are configuring a FilterChainProxy explicitly, rather than using the element. The intercept-url elements used should only contain pattern, method and access attributes. Any others will result in a configuration error. + element filter-security-metadata-source {fsmds.attlist, intercept-url+} +fsmds.attlist &= + use-expressions? +fsmds.attlist &= + id? +fsmds.attlist &= + ## Compare after forcing to lowercase + attribute lowercase-comparisons {xsd:boolean}? +fsmds.attlist &= + ## Deprecate. Use request-matcher instead. + path-type? +fsmds.attlist &= + request-matcher? + +filter-invocation-definition-source = + ## Deprecated synonym for filter-security-metadata-source + element filter-invocation-definition-source {fsmds.attlist, intercept-url+} + +http-basic = + ## Adds support for basic authentication + element http-basic {http-basic.attlist, empty} + +http-basic.attlist &= + ## Sets the AuthenticationEntryPoint which is used by the BasicAuthenticationFilter. + attribute entry-point-ref {xsd:token}? +http-basic.attlist &= + ## Reference to an AuthenticationDetailsSource which will be used by the authentication filter + attribute authentication-details-source-ref {xsd:token}? + +session-management = + ## Session-management related functionality is implemented by the addition of a SessionManagementFilter to the filter stack. + element session-management {session-management.attlist, concurrency-control?} + +session-management.attlist &= + ## Indicates whether an existing session should be invalidated when a user authenticates and a new session started. If set to "none" no change will be made. "newSession" will create a new empty session. "migrateSession" will create a new session and copy the session attributes to the new session. Defaults to "migrateSession". + attribute session-fixation-protection {"none" | "newSession" | "migrateSession" }? +session-management.attlist &= + ## The URL to which a user will be redirected if they submit an invalid session indentifier. Typically used to detect session timeouts. + attribute invalid-session-url {xsd:token}? +session-management.attlist &= + ## Allows injection of the SessionAuthenticationStrategy instance used by the SessionManagementFilter + attribute session-authentication-strategy-ref {xsd:token}? +session-management.attlist &= + ## Defines the URL of the error page which should be shown when the SessionAuthenticationStrategy raises an exception. If not set, an unauthorized (402) error code will be returned to the client. Note that this attribute doesn't apply if the error occurs during a form-based login, where the URL for authentication failure will take precedence. + attribute session-authentication-error-url {xsd:token}? + + +concurrency-control = + ## Enables concurrent session control, limiting the number of authenticated sessions a user may have at the same time. + element concurrency-control {concurrency-control.attlist, empty} + +concurrency-control.attlist &= + ## The maximum number of sessions a single authenticated user can have open at the same time. Defaults to "1". + attribute max-sessions {xsd:positiveInteger}? +concurrency-control.attlist &= + ## The URL a user will be redirected to if they attempt to use a session which has been "expired" because they have logged in again. + attribute expired-url {xsd:token}? +concurrency-control.attlist &= + ## Specifies that an unauthorized error should be reported when a user attempts to login when they already have the maximum configured sessions open. The default behaviour is to expire the original session. If the session-authentication-error-url attribute is set on the session-management URL, the user will be redirected to this URL. + attribute error-if-maximum-exceeded {xsd:boolean}? +concurrency-control.attlist &= + ## Allows you to define an alias for the SessionRegistry bean in order to access it in your own configuration. + attribute session-registry-alias {xsd:token}? +concurrency-control.attlist &= + ## Allows you to define an external SessionRegistry bean to be used by the concurrency control setup. + attribute session-registry-ref {xsd:token}? + + +remember-me = + ## Sets up remember-me authentication. If used with the "key" attribute (or no attributes) the cookie-only implementation will be used. Specifying "token-repository-ref" or "remember-me-data-source-ref" will use the more secure, persisten token approach. + element remember-me {remember-me.attlist} +remember-me.attlist &= + ## The "key" used to identify cookies from a specific token-based remember-me application. You should set this to a unique value for your application. + attribute key {xsd:token}? + +remember-me.attlist &= + (token-repository-ref | remember-me-data-source-ref | remember-me-services-ref) + +remember-me.attlist &= + user-service-ref? + +remember-me.attlist &= + ## Exports the internally defined RememberMeServices as a bean alias, allowing it to be used by other beans in the application context. + attribute services-alias {xsd:token}? + +remember-me.attlist &= + ## Determines whether the "secure" flag will be set on the remember-me cookie. If set to true, the cookie will only be submitted over HTTPS (recommended). By default, secure cookies will be used if the request is made on a secure connection. + attribute use-secure-cookie {xsd:boolean}? + +remember-me.attlist &= + ## The period (in seconds) for which the remember-me cookie should be valid. + attribute token-validity-seconds {xsd:integer}? + +remember-me.attlist &= + ## Reference to an AuthenticationSuccessHandler bean which should be used to handle a successful remember-me authentication. + attribute authentication-success-handler-ref {xsd:token}? + + +token-repository-ref = + ## Reference to a PersistentTokenRepository bean for use with the persistent token remember-me implementation. + attribute token-repository-ref {xsd:token} +remember-me-services-ref = + ## Allows a custom implementation of RememberMeServices to be used. Note that this implementation should return RememberMeAuthenticationToken instances with the same "key" value as specified in the remember-me element. Alternatively it should register its own AuthenticationProvider. It should also implement the LogoutHandler interface, which will be invoked when a user logs out. Typically the remember-me cookie would be removed on logout. + attribute services-ref {xsd:token}? +remember-me-data-source-ref = + ## DataSource bean for the database that contains the token repository schema. + data-source-ref + +anonymous = + ## Adds support for automatically granting all anonymous web requests a particular principal identity and a corresponding granted authority. + element anonymous {anonymous.attlist} +anonymous.attlist &= + ## The key shared between the provider and filter. This generally does not need to be set. If unset, it will default to "doesNotMatter". + attribute key {xsd:token}? +anonymous.attlist &= + ## The username that should be assigned to the anonymous request. This allows the principal to be identified, which may be important for logging and auditing. if unset, defaults to "anonymousUser". + attribute username {xsd:token}? +anonymous.attlist &= + ## The granted authority that should be assigned to the anonymous request. Commonly this is used to assign the anonymous request particular roles, which can subsequently be used in authorization decisions. If unset, defaults to "ROLE_ANONYMOUS". + attribute granted-authority {xsd:token}? +anonymous.attlist &= + ## With the default namespace setup, the anonymous "authentication" facility is automatically enabled. You can disable it using this property. + attribute enabled {xsd:boolean}? + + +port-mappings = + ## Defines the list of mappings between http and https ports for use in redirects + element port-mappings {port-mappings.attlist, port-mapping+} + +port-mappings.attlist &= empty + +port-mapping = + ## Provides a method to map http ports to https ports when forcing a redirect. + element port-mapping {http-port, https-port} + +http-port = + ## The http port to use. + attribute http {xsd:token} + +https-port = + ## The https port to use. + attribute https {xsd:token} + + +x509 = + ## Adds support for X.509 client authentication. + element x509 {x509.attlist} +x509.attlist &= + ## The regular expression used to obtain the username from the certificate's subject. Defaults to matching on the common name using the pattern "CN=(.*?),". + attribute subject-principal-regex {xsd:token}? +x509.attlist &= + ## Explicitly specifies which user-service should be used to load user data for X.509 authenticated clients. If ommitted, the default user-service will be used. + user-service-ref? +x509.attlist &= + ## Reference to an AuthenticationDetailsSource which will be used by the authentication filter + attribute authentication-details-source-ref {xsd:token}? + +jee = + ## Adds a J2eePreAuthenticatedProcessingFilter to the filter chain to provide integration with container authentication. + element jee {jee.attlist} +jee.attlist &= + ## A comma-separate list of roles to look for in the incoming HttpServletRequest. + attribute mappable-roles {xsd:token} +jee.attlist &= + ## Explicitly specifies which user-service should be used to load user data for container authenticated clients. If ommitted, the set of mappable-roles will be used to construct the authorities for the user. + user-service-ref? + +authentication-manager = + ## Registers the AuthenticationManager instance and allows its list of AuthenticationProviders to be defined. Also allows you to define an alias to allow you to reference the AuthenticationManager in your own beans. + element authentication-manager {authman.attlist & authentication-provider* & ldap-authentication-provider*} +authman.attlist &= + id? +authman.attlist &= + ## An alias you wish to use for the AuthenticationManager bean (not required it you are using a specific id) + attribute alias {xsd:token}? +authman.attlist &= + ## If set to true, the AuthenticationManger will attempt to clear any credentials data in the returned Authentication object, once the user has been authenticated. + attribute erase-credentials {xsd:boolean}? + +authentication-provider = + ## Indicates that the contained user-service should be used as an authentication source. + element authentication-provider {ap.attlist & any-user-service & password-encoder?} +ap.attlist &= + ## Specifies a reference to a separately configured AuthenticationProvider instance which should be registered within the AuthenticationManager. + ref? +ap.attlist &= + ## Specifies a reference to a separately configured UserDetailsService from which to obtain authentication data. + user-service-ref? + +user-service = + ## Creates an in-memory UserDetailsService from a properties file or a list of "user" child elements. Usernames are converted to lower-case internally to allow for case-insensitive lookups, so this should not be used if case-sensitivity is required. + element user-service {id? & (properties-file | (user*))} +properties-file = + ## The location of a Properties file where each line is in the format of username=password,grantedAuthority[,grantedAuthority][,enabled|disabled] + attribute properties {xsd:token}? + +user = + ## Represents a user in the application. + element user {user.attlist, empty} +user.attlist &= + ## The username assigned to the user. + attribute name {xsd:token} +user.attlist &= + ## The password assigned to the user. This may be hashed if the corresponding authentication provider supports hashing (remember to set the "hash" attribute of the "user-service" element). This attribute be omitted in the case where the data will not be used for authentication, but only for accessing authorities. If omitted, the namespace will generate a random value, preventing its accidental use for authentication. Cannot be empty. + attribute password {xsd:string}? +user.attlist &= + ## One of more authorities granted to the user. Separate authorities with a comma (but no space). For example, "ROLE_USER,ROLE_ADMINISTRATOR" + attribute authorities {xsd:token} +user.attlist &= + ## Can be set to "true" to mark an account as locked and unusable. + attribute locked {xsd:boolean}? +user.attlist &= + ## Can be set to "true" to mark an account as disabled and unusable. + attribute disabled {xsd:boolean}? + +jdbc-user-service = + ## Causes creation of a JDBC-based UserDetailsService. + element jdbc-user-service {id? & jdbc-user-service.attlist} +jdbc-user-service.attlist &= + ## The bean ID of the DataSource which provides the required tables. + attribute data-source-ref {xsd:token} +jdbc-user-service.attlist &= + cache-ref? +jdbc-user-service.attlist &= + ## An SQL statement to query a username, password, and enabled status given a username. Default is "select username,password,enabled from users where username = ?" + attribute users-by-username-query {xsd:token}? +jdbc-user-service.attlist &= + ## An SQL statement to query for a user's granted authorities given a username. The default is "select username, authority from authorities where username = ?" + attribute authorities-by-username-query {xsd:token}? +jdbc-user-service.attlist &= + ## An SQL statement to query user's group authorities given a username. The default is "select g.id, g.group_name, ga.authority from groups g, group_members gm, group_authorities ga where gm.username = ? and g.id = ga.group_id and g.id = gm.group_id" + attribute group-authorities-by-username-query {xsd:token}? +jdbc-user-service.attlist &= + role-prefix? + +add-headers = + ## Element for configuration of the AddHeadersFilter. Enables easy setting for the X-Frame-Options, X-XSS-Protection and X-Content-Type-Options headers. + element add-headers {xss-protection? | frame-options? | content-type-options? | header*} + +frame-options = + ## Enable basic clickjacking support for newer browsers (IE8+), will set the X-Frame-Options header. + element frame-options {frame-options.attlist} +frame-options.attlist &= + ## Specify the policy to use for the X-Frame-Options-Header. + [ a:defaultValue = "DENY" ] + attribute policy {"DENY","SAMEORIGIN","ALLOW-FROM"}? +frame-options.attlist &= + ## Specify the origin to use when ALLOW-FROM is chosen. + attribute origin {xsd:token}? + +xss-protection = + ## Enable basic XSS browser protection, supported by newer browsers (IE8+), will set the X-XSS-Protection header. + element xss-protection {xss-protection.attlist} +xss-protection.attlist &= + ## enable or disable the X-XSS-Protection header. Default is 'true' meaning it is enabled. + [ a:defaultValue = "true" ] + attribute enabled {xsd:boolean}? +xss-protection.attlist &= + ## Add mode=block to the header or not, default is on. + [ a:defaultValue = "true" ] + attribute block {xsd:boolean}? + +content-type-options = + ## Add a X-Content-Type-Options header to the resopnse. Value is always 'nosniff'. + element content-type-options {empty} + +header= + ## Add additional headers to the response. + element header {header.attlist} +header.attlist &= + ## The name of the header to add. + attribute name {xsd:token} +header.attlist &= + ## The value for the header. + attribute value {xsd:token} + +any-user-service = user-service | jdbc-user-service | ldap-user-service + +custom-filter = + ## Used to indicate that a filter bean declaration should be incorporated into the security filter chain. + element custom-filter {custom-filter.attlist} + +custom-filter.attlist &= + ref + +custom-filter.attlist &= + (after | before | position) + +after = + ## The filter immediately after which the custom-filter should be placed in the chain. This feature will only be needed by advanced users who wish to mix their own filters into the security filter chain and have some knowledge of the standard Spring Security filters. The filter names map to specific Spring Security implementation filters. + attribute after {named-security-filter} +before = + ## The filter immediately before which the custom-filter should be placed in the chain + attribute before {named-security-filter} +position = + ## The explicit position at which the custom-filter should be placed in the chain. Use if you are replacing a standard filter. + attribute position {named-security-filter} + +named-security-filter = "FIRST" | "CHANNEL_FILTER" | "CONCURRENT_SESSION_FILTER" | "SECURITY_CONTEXT_FILTER" | "LOGOUT_FILTER" | "X509_FILTER" | "PRE_AUTH_FILTER" | "CAS_FILTER" | "FORM_LOGIN_FILTER" | "OPENID_FILTER" |"BASIC_AUTH_FILTER" | "SERVLET_API_SUPPORT_FILTER" | "REMEMBER_ME_FILTER" | "ANONYMOUS_FILTER" | "EXCEPTION_TRANSLATION_FILTER" | "SESSION_MANAGEMENT_FILTER" | "FILTER_SECURITY_INTERCEPTOR" | "SWITCH_USER_FILTER" | "LAST" diff --git a/config/src/main/resources/org/springframework/security/config/spring-security-3.2.xsd b/config/src/main/resources/org/springframework/security/config/spring-security-3.2.xsd new file mode 100644 index 00000000000..e6ec3ecdd09 --- /dev/null +++ b/config/src/main/resources/org/springframework/security/config/spring-security-3.2.xsd @@ -0,0 +1,1726 @@ + + + + + + Defines the hashing algorithm used on user passwords. We recommend strongly against using MD4, as it is a very weak hashing algorithm. + + + + + + + + + + + + + + + + + + Whether a string should be base64 encoded + + + + + + + Supersedes the 'path-type' attribute. Defines the strategy use for matching incoming requests. Currently the options are 'ant' (for ant path patterns), 'regex' for regular expressions and 'ciRegex' for case-insensitive regular expressions. + + + + + + + + + + + + + + Deprecated. Use request-matcher instead. + + + + + + + + + + + + + Specifies an IP port number. Used to configure an embedded LDAP server, for example. + + + + + + + Specifies a URL. + + + + + + + A bean identifier, used for referring to the bean elsewhere in the context. + + + + + + + A bean identifier, used for referring to the bean elsewhere in the context. + + + + + + + Defines a reference to a Spring bean Id. + + + + + + + Defines a reference to a cache for use with a UserDetailsService. + + + + + + + A reference to a user-service (or UserDetailsService bean) Id + + + + + + + A reference to an AuthenticationManager bean + + + + + + + A reference to a DataSource bean + + + + + Enables Spring Security debugging infrastructure. This will provide human-readable (multi-line) debugging information to monitor requests coming into the security filters. This may include sensitive information, such as request parameters or headers, and should only be used in a development environment. + + + + + + Defines a reference to a Spring bean Id. + + + + + Defines the hashing algorithm used on user passwords. We recommend strongly against using MD4, as it is a very weak hashing algorithm. + + + + + + + + + + + + + + + + Whether a string should be base64 encoded + + + + + + + + A property of the UserDetails object which will be used as salt by a password encoder. Typically something like "username" might be used. + + + + + + + A single value that will be used as the salt for a password encoder. + + + + + + + A non-empty string prefix that will be added to role strings loaded from persistent storage (e.g. "ROLE_"). Use the value "none" for no prefix in cases where the default is non-empty. + + + + + + + Enables the use of expressions in the 'access' attributes in <intercept-url> elements rather than the traditional list of configuration attributes. Defaults to 'false'. If enabled, each attribute should contain a single boolean expression. If the expression evaluates to 'true', access will be granted. + + + + + Defines an LDAP server location or starts an embedded server. The url indicates the location of a remote server. If no url is given, an embedded server will be started, listening on the supplied port number. The port is optional and defaults to 33389. A Spring LDAP ContextSource bean will be registered for the server with the id supplied. + + + + + + + A bean identifier, used for referring to the bean elsewhere in the context. + + + + + Specifies a URL. + + + + + Specifies an IP port number. Used to configure an embedded LDAP server, for example. + + + + + Username (DN) of the "manager" user identity which will be used to authenticate to a (non-embedded) LDAP server. If omitted, anonymous access will be used. + + + + + The password for the manager DN. This is required if the manager-dn is specified. + + + + + Explicitly specifies an ldif file resource to load into an embedded LDAP server. The default is classpath*:*.ldiff + + + + + Optional root suffix for the embedded LDAP server. Default is "dc=springframework,dc=org" + + + + + + + The optional server to use. If omitted, and a default LDAP server is registered (using <ldap-server> with no Id), that server will be used. + + + + + + + Group search filter. Defaults to (uniqueMember={0}). The substituted parameter is the DN of the user. + + + + + + + Search base for group membership searches. Defaults to "" (searching from the root). + + + + + + + The LDAP filter used to search for users (optional). For example "(uid={0})". The substituted parameter is the user's login name. + + + + + + + Search base for user searches. Defaults to "". Only used with a 'user-search-filter'. + + + + + + + The LDAP attribute name which contains the role name which will be used within Spring Security. Defaults to "cn". + + + + + + + Allows the objectClass of the user entry to be specified. If set, the framework will attempt to load standard attributes for the defined class into the returned UserDetails object + + + + + + + + + + + + + Allows explicit customization of the loaded user object by specifying a UserDetailsContextMapper bean which will be called with the context information from the user's directory entry + + + + + This element configures a LdapUserDetailsService which is a combination of a FilterBasedLdapUserSearch and a DefaultLdapAuthoritiesPopulator. + + + + + + + A bean identifier, used for referring to the bean elsewhere in the context. + + + + + The optional server to use. If omitted, and a default LDAP server is registered (using <ldap-server> with no Id), that server will be used. + + + + + The LDAP filter used to search for users (optional). For example "(uid={0})". The substituted parameter is the user's login name. + + + + + Search base for user searches. Defaults to "". Only used with a 'user-search-filter'. + + + + + Group search filter. Defaults to (uniqueMember={0}). The substituted parameter is the DN of the user. + + + + + Search base for group membership searches. Defaults to "" (searching from the root). + + + + + The LDAP attribute name which contains the role name which will be used within Spring Security. Defaults to "cn". + + + + + Defines a reference to a cache for use with a UserDetailsService. + + + + + A non-empty string prefix that will be added to role strings loaded from persistent storage (e.g. "ROLE_"). Use the value "none" for no prefix in cases where the default is non-empty. + + + + + Allows the objectClass of the user entry to be specified. If set, the framework will attempt to load standard attributes for the defined class into the returned UserDetails object + + + + + + + + + + + Allows explicit customization of the loaded user object by specifying a UserDetailsContextMapper bean which will be called with the context information from the user's directory entry + + + + + + + + The optional server to use. If omitted, and a default LDAP server is registered (using <ldap-server> with no Id), that server will be used. + + + + + Search base for user searches. Defaults to "". Only used with a 'user-search-filter'. + + + + + The LDAP filter used to search for users (optional). For example "(uid={0})". The substituted parameter is the user's login name. + + + + + Search base for group membership searches. Defaults to "" (searching from the root). + + + + + Group search filter. Defaults to (uniqueMember={0}). The substituted parameter is the DN of the user. + + + + + The LDAP attribute name which contains the role name which will be used within Spring Security. Defaults to "cn". + + + + + A specific pattern used to build the user's DN, for example "uid={0},ou=people". The key "{0}" must be present and will be substituted with the username. + + + + + A non-empty string prefix that will be added to role strings loaded from persistent storage (e.g. "ROLE_"). Use the value "none" for no prefix in cases where the default is non-empty. + + + + + Allows the objectClass of the user entry to be specified. If set, the framework will attempt to load standard attributes for the defined class into the returned UserDetails object + + + + + + + + + + + Allows explicit customization of the loaded user object by specifying a UserDetailsContextMapper bean which will be called with the context information from the user's directory entry + + + + + + + + The attribute in the directory which contains the user password. Defaults to "userPassword". + + + + + Defines the hashing algorithm used on user passwords. We recommend strongly against using MD4, as it is a very weak hashing algorithm. + + + + + + + + + + + + + + + + Can be used inside a bean definition to add a security interceptor to the bean and set up access configuration attributes for the bean's methods + + + + Defines a protected method and the access control configuration attributes that apply to it. We strongly advise you NOT to mix "protect" declarations with any services provided "global-method-security". + + + + + + + + + + Optional AccessDecisionManager bean ID to be used by the created method security interceptor. + + + + + + + + A method name + + + + + Access configuration attributes list that applies to the method, e.g. "ROLE_A,ROLE_B". + + + + + Creates a MethodSecurityMetadataSource instance + + + + Defines a protected method and the access control configuration attributes that apply to it. We strongly advise you NOT to mix "protect" declarations with any services provided "global-method-security". + + + + + + + + + + A bean identifier, used for referring to the bean elsewhere in the context. + + + + + Enables the use of expressions in the 'access' attributes in <intercept-url> elements rather than the traditional list of configuration attributes. Defaults to 'false'. If enabled, each attribute should contain a single boolean expression. If the expression evaluates to 'true', access will be granted. + + + + + Provides method security for all beans registered in the Spring application context. Specifically, beans will be scanned for matches with the ordered list of "protect-pointcut" sub-elements, Spring Security annotations and/or. Where there is a match, the beans will automatically be proxied and security authorization applied to the methods accordingly. If you use and enable all four sources of method security metadata (ie "protect-pointcut" declarations, expression annotations, @Secured and also JSR250 security annotations), the metadata sources will be queried in that order. In practical terms, this enables you to use XML to override method security metadata expressed in annotations. If using annotations, the order of precedence is EL-based (@PreAuthorize etc.), @Secured and finally JSR-250. + + + + + Allows the default expression-based mechanism for handling Spring Security's pre and post invocation annotations (@PreFilter, @PreAuthorize, @PostFilter, @PostAuthorize) to be replace entirely. Only applies if these annotations are enabled. + + + + Defines the PrePostInvocationAttributeFactory instance which is used to generate pre and post invocation metadata from the annotated methods. + + + + + Customizes the PreInvocationAuthorizationAdviceVoter with the ref as the PreInvocationAuthorizationAdviceVoter for the <pre-post-annotation-handling> element. + + + + + Customizes the PostInvocationAdviceProvider with the ref as the PostInvocationAuthorizationAdvice for the <pre-post-annotation-handling> element. + + + + + + + Defines the SecurityExpressionHandler instance which will be used if expression-based access-control is enabled. A default implementation (with no ACL support) will be used if not supplied. + + + + + + Defines a protected pointcut and the access control configuration attributes that apply to it. Every bean registered in the Spring application context that provides a method that matches the pointcut will receive security authorization. + + + + + Allows addition of extra AfterInvocationProvider beans which should be called by the MethodSecurityInterceptor created by global-method-security. + + + + + + + + + + Specifies whether the use of Spring Security's pre and post invocation annotations (@PreFilter, @PreAuthorize, @PostFilter, @PostAuthorize) should be enabled for this application context. Defaults to "disabled". + + + + + + + + + + + Specifies whether the use of Spring Security's @Secured annotations should be enabled for this application context. Defaults to "disabled". + + + + + + + + + + + Specifies whether JSR-250 style attributes are to be used (for example "RolesAllowed"). This will require the javax.annotation.security classes on the classpath. Defaults to "disabled". + + + + + + + + + + + Optional AccessDecisionManager bean ID to override the default used for method security. + + + + + Optional RunAsmanager implementation which will be used by the configured MethodSecurityInterceptor + + + + + Allows the advice "order" to be set for the method security interceptor. + + + + + If true, class based proxying will be used instead of interface based proxying. + + + + + Can be used to specify that AspectJ should be used instead of the default Spring AOP. If set, secured classes must be woven with the AnnotationSecurityAspect from the spring-security-aspects module. + + + + + + + + + + An external MethodSecurityMetadataSource instance can be supplied which will take priority over other sources (such as the default annotations). + + + + + A reference to an AuthenticationManager bean + + + + + + + + + + + + + + An AspectJ expression, including the 'execution' keyword. For example, 'execution(int com.foo.TargetObject.countLength(String))' (without the quotes). + + + + + Access configuration attributes list that applies to all methods matching the pointcut, e.g. "ROLE_A,ROLE_B" + + + + + Allows a custom instance of HttpFirewall to be injected into the FilterChainProxy created by the namespace. + + + + + Container element for HTTP security configuration. Multiple elements can now be defined, each with a specific pattern to which the enclosed security configuration applies. A pattern can also be configured to bypass Spring Security's filters completely by setting the "secured" attribute to "false". + + + + Specifies the access attributes and/or filter list for a particular set of URLs. + + + + + Defines the access-denied strategy that should be used. An access denied page can be defined or a reference to an AccessDeniedHandler instance. + + + + + Sets up a form login configuration for authentication with a username and password + + + + + Sets up form login for authentication with an Open ID identity + + + + + + + + A reference to a user-service (or UserDetailsService bean) Id + + + + + Adds support for X.509 client authentication. + + + + + + Adds support for basic authentication + + + + + Incorporates a logout processing filter. Most web applications require a logout filter, although you may not require one if you write a controller to provider similar logic. + + + + + Session-management related functionality is implemented by the addition of a SessionManagementFilter to the filter stack. + + + + Enables concurrent session control, limiting the number of authenticated sessions a user may have at the same time. + + + + + + + + Sets up remember-me authentication. If used with the "key" attribute (or no attributes) the cookie-only implementation will be used. Specifying "token-repository-ref" or "remember-me-data-source-ref" will use the more secure, persisten token approach. + + + + + Adds support for automatically granting all anonymous web requests a particular principal identity and a corresponding granted authority. + + + + + Defines the list of mappings between http and https ports for use in redirects + + + + Provides a method to map http ports to https ports when forcing a redirect. + + + + + + + + + + Defines the SecurityExpressionHandler instance which will be used if expression-based access-control is enabled. A default implementation (with no ACL support) will be used if not supplied. + + + + + Element for configuration of the AddHeadersFilter. Enables easy setting for the X-Frame-Options, X-XSS-Protection and X-Content-Type-Options headers. + + + + + + + + + + + + + + + The request URL pattern which will be mapped to the filter chain created by this <http> element. If omitted, the filter chain will match all requests. + + + + + When set to 'none', requests matching the pattern attribute will be ignored by Spring Security. No security filters will be applied and no SecurityContext will be available. If set, the <http> element must be empty, with no children. + + + + + + + + + + Allows a RequestMatcher instance to be used, as an alternative to pattern-matching. + + + + + Automatically registers a login form, BASIC authentication, anonymous authentication, logout services, remember-me and servlet-api-integration. If set to "true", all of these capabilities are added (although you can still customize the configuration of each by providing the respective element). If unspecified, defaults to "false". + + + + + Enables the use of expressions in the 'access' attributes in <intercept-url> elements rather than the traditional list of configuration attributes. Defaults to 'false'. If enabled, each attribute should contain a single boolean expression. If the expression evaluates to 'true', access will be granted. + + + + + Controls the eagerness with which an HTTP session is created by Spring Security classes. If not set, defaults to "ifRequired". If "stateless" is used, this implies that the application guarantees that it will not create a session. This differs from the use of "never" which mans that Spring Security will not create a session, but will make use of one if the application does. + + + + + + + + + + + + + A reference to a SecurityContextRepository bean. This can be used to customize how the SecurityContext is stored between requests. + + + + + Supersedes the 'path-type' attribute. Defines the strategy use for matching incoming requests. Currently the options are 'ant' (for ant path patterns), 'regex' for regular expressions and 'ciRegex' for case-insensitive regular expressions. + + + + + + + + + + + + Deprecated. Use request-matcher instead. + + + + + + + + + + + Provides versions of HttpServletRequest security methods such as isUserInRole() and getPrincipal() which are implemented by accessing the Spring SecurityContext. Defaults to "true". + + + + + If available, runs the request as the Subject acquired from the JaasAuthenticationToken. Defaults to "false". + + + + + Optional attribute specifying the ID of the AccessDecisionManager implementation which should be used for authorizing HTTP requests. + + + + + Optional attribute specifying the realm name that will be used for all authentication features that require a realm name (eg BASIC and Digest authentication). If unspecified, defaults to "Spring Security Application". + + + + + Allows a customized AuthenticationEntryPoint to be set on the ExceptionTranslationFilter. + + + + + Corresponds to the observeOncePerRequest property of FilterSecurityInterceptor. Defaults to "true" + + + + + Deprecated in favour of the access-denied-handler element. + + + + + Prevents the jsessionid parameter from being added to rendered URLs. + + + + + A bean identifier, used for referring to the bean elsewhere in the context. + + + + + A reference to an AuthenticationManager bean + + + + + + + + Defines a reference to a Spring bean Id. + + + + + The access denied page that an authenticated user will be redirected to if they request a page which they don't have the authority to access. + + + + + + + The access denied page that an authenticated user will be redirected to if they request a page which they don't have the authority to access. + + + + + + + + The pattern which defines the URL path. The content will depend on the type set in the containing http element, so will default to ant path syntax. + + + + + The access configuration attributes that apply for the configured path. + + + + + The HTTP Method for which the access configuration attributes should apply. If not specified, the attributes will apply to any method. + + + + + + + + + + + + + + + + The filter list for the path. Currently can be set to "none" to remove a path from having any filters applied. The full filter stack (consisting of all filters created by the namespace configuration, and any added using 'custom-filter'), will be applied to any other paths. + + + + + + + + + + Used to specify that a URL must be accessed over http or https, or that there is no preference. The value should be "http", "https" or "any", respectively. + + + + + + + + Specifies the URL that will cause a logout. Spring Security will initialize a filter that responds to this particular URL. Defaults to /j_spring_security_logout if unspecified. + + + + + Specifies the URL to display once the user has logged out. If not specified, defaults to /. + + + + + Specifies whether a logout also causes HttpSession invalidation, which is generally desirable. If unspecified, defaults to true. + + + + + A reference to a LogoutSuccessHandler implementation which will be used to determine the destination to which the user is taken after logging out. + + + + + A comma-separated list of the names of cookies which should be deleted when the user logs out + + + + + Allow the RequestCache used for saving requests during the login process to be set + + + + + + + + The URL that the login form is posted to. If unspecified, it defaults to /j_spring_security_check. + + + + + The name of the request parameter which contains the username. Defaults to 'j_username'. + + + + + The name of the request parameter which contains the password. Defaults to 'j_password'. + + + + + The URL that will be redirected to after successful authentication, if the user's previous action could not be resumed. This generally happens if the user visits a login page without having first requested a secured operation that triggers authentication. If unspecified, defaults to the root of the application. + + + + + Whether the user should always be redirected to the default-target-url after login. + + + + + The URL for the login page. If no login URL is specified, Spring Security will automatically create a login URL at /spring_security_login and a corresponding filter to render that login URL when requested. + + + + + The URL for the login failure page. If no login failure URL is specified, Spring Security will automatically create a failure login URL at /spring_security_login?login_error and a corresponding filter to render that login failure URL when requested. + + + + + Reference to an AuthenticationSuccessHandler bean which should be used to handle a successful authentication request. Should not be used in combination with default-target-url (or always-use-default-target-url) as the implementation should always deal with navigation to the subsequent destination + + + + + Reference to an AuthenticationFailureHandler bean which should be used to handle a failed authentication request. Should not be used in combination with authentication-failure-url as the implementation should always deal with navigation to the subsequent destination + + + + + Reference to an AuthenticationDetailsSource which will be used by the authentication filter + + + + + + Sets up an attribute exchange configuration to request specified attributes from the OpenID identity provider. When multiple elements are used, each must have an identifier-attribute attribute. Each configuration will be matched in turn against the supplied login identifier until a match is found. + + + + + + + + + + A regular expression which will be compared against the claimed identity, when deciding which attribute-exchange configuration to use during authentication. + + + + + Attributes used when making an OpenID AX Fetch Request + + + + + + + Specifies the name of the attribute that you wish to get back. For example, email. + + + + + Specifies the attribute type. For example, http://axschema.org/contact/email. See your OP's documentation for valid attribute types. + + + + + Specifies if this attribute is required to the OP, but does not error out if the OP does not return the attribute. Default is false. + + + + + Specifies the number of attributes that you wish to get back. For example, return 3 emails. The default value is 1. + + + + + Used to explicitly configure a FilterChainProxy instance with a FilterChainMap + + + + + + + + + + Deprecated. Use request-matcher instead. + + + + + + + + + + + Supersedes the 'path-type' attribute. Defines the strategy use for matching incoming requests. Currently the options are 'ant' (for ant path patterns), 'regex' for regular expressions and 'ciRegex' for case-insensitive regular expressions. + + + + + + + + + + + + Used within to define a specific URL pattern and the list of filters which apply to the URLs matching that pattern. When multiple filter-chain elements are assembled in a list in order to configure a FilterChainProxy, the most specific patterns must be placed at the top of the list, with most general ones at the bottom. + + + + + + + The request URL pattern which will be mapped to the FilterChain. + + + + + Allows a RequestMatcher instance to be used, as an alternative to pattern-matching. + + + + + A comma separated list of bean names that implement Filter that should be processed for this FilterChain. If the value is none, then no Filters will be used for this FilterChain. + + + + + + + The request URL pattern which will be mapped to the FilterChain. + + + + + + + Allows a RequestMatcher instance to be used, as an alternative to pattern-matching. + + + + + Used to explicitly configure a FilterSecurityMetadataSource bean for use with a FilterSecurityInterceptor. Usually only needed if you are configuring a FilterChainProxy explicitly, rather than using the <http> element. The intercept-url elements used should only contain pattern, method and access attributes. Any others will result in a configuration error. + + + + Specifies the access attributes and/or filter list for a particular set of URLs. + + + + + + + + + + Enables the use of expressions in the 'access' attributes in <intercept-url> elements rather than the traditional list of configuration attributes. Defaults to 'false'. If enabled, each attribute should contain a single boolean expression. If the expression evaluates to 'true', access will be granted. + + + + + A bean identifier, used for referring to the bean elsewhere in the context. + + + + + Compare after forcing to lowercase + + + + + Deprecated. Use request-matcher instead. + + + + + + + + + + + Supersedes the 'path-type' attribute. Defines the strategy use for matching incoming requests. Currently the options are 'ant' (for ant path patterns), 'regex' for regular expressions and 'ciRegex' for case-insensitive regular expressions. + + + + + + + + + + + + Deprecated synonym for filter-security-metadata-source + + + + Specifies the access attributes and/or filter list for a particular set of URLs. + + + + + + + + + + + Sets the AuthenticationEntryPoint which is used by the BasicAuthenticationFilter. + + + + + Reference to an AuthenticationDetailsSource which will be used by the authentication filter + + + + + + + + Indicates whether an existing session should be invalidated when a user authenticates and a new session started. If set to "none" no change will be made. "newSession" will create a new empty session. "migrateSession" will create a new session and copy the session attributes to the new session. Defaults to "migrateSession". + + + + + + + + + + + + The URL to which a user will be redirected if they submit an invalid session indentifier. Typically used to detect session timeouts. + + + + + Allows injection of the SessionAuthenticationStrategy instance used by the SessionManagementFilter + + + + + Defines the URL of the error page which should be shown when the SessionAuthenticationStrategy raises an exception. If not set, an unauthorized (402) error code will be returned to the client. Note that this attribute doesn't apply if the error occurs during a form-based login, where the URL for authentication failure will take precedence. + + + + + + + + The maximum number of sessions a single authenticated user can have open at the same time. Defaults to "1". + + + + + The URL a user will be redirected to if they attempt to use a session which has been "expired" because they have logged in again. + + + + + Specifies that an unauthorized error should be reported when a user attempts to login when they already have the maximum configured sessions open. The default behaviour is to expire the original session. If the session-authentication-error-url attribute is set on the session-management URL, the user will be redirected to this URL. + + + + + Allows you to define an alias for the SessionRegistry bean in order to access it in your own configuration. + + + + + Allows you to define an external SessionRegistry bean to be used by the concurrency control setup. + + + + + + + + The "key" used to identify cookies from a specific token-based remember-me application. You should set this to a unique value for your application. + + + + + Reference to a PersistentTokenRepository bean for use with the persistent token remember-me implementation. + + + + + A reference to a DataSource bean + + + + + + A reference to a user-service (or UserDetailsService bean) Id + + + + + Exports the internally defined RememberMeServices as a bean alias, allowing it to be used by other beans in the application context. + + + + + Determines whether the "secure" flag will be set on the remember-me cookie. If set to true, the cookie will only be submitted over HTTPS (recommended). By default, secure cookies will be used if the request is made on a secure connection. + + + + + The period (in seconds) for which the remember-me cookie should be valid. + + + + + Reference to an AuthenticationSuccessHandler bean which should be used to handle a successful remember-me authentication. + + + + + + + Reference to a PersistentTokenRepository bean for use with the persistent token remember-me implementation. + + + + + + + Allows a custom implementation of RememberMeServices to be used. Note that this implementation should return RememberMeAuthenticationToken instances with the same "key" value as specified in the remember-me element. Alternatively it should register its own AuthenticationProvider. It should also implement the LogoutHandler interface, which will be invoked when a user logs out. Typically the remember-me cookie would be removed on logout. + + + + + + + + + + + The key shared between the provider and filter. This generally does not need to be set. If unset, it will default to "doesNotMatter". + + + + + The username that should be assigned to the anonymous request. This allows the principal to be identified, which may be important for logging and auditing. if unset, defaults to "anonymousUser". + + + + + The granted authority that should be assigned to the anonymous request. Commonly this is used to assign the anonymous request particular roles, which can subsequently be used in authorization decisions. If unset, defaults to "ROLE_ANONYMOUS". + + + + + With the default namespace setup, the anonymous "authentication" facility is automatically enabled. You can disable it using this property. + + + + + + + + + The http port to use. + + + + + + + The https port to use. + + + + + + + + The regular expression used to obtain the username from the certificate's subject. Defaults to matching on the common name using the pattern "CN=(.*?),". + + + + + A reference to a user-service (or UserDetailsService bean) Id + + + + + Reference to an AuthenticationDetailsSource which will be used by the authentication filter + + + + + Adds a J2eePreAuthenticatedProcessingFilter to the filter chain to provide integration with container authentication. + + + + + + + A comma-separate list of roles to look for in the incoming HttpServletRequest. + + + + + A reference to a user-service (or UserDetailsService bean) Id + + + + + Registers the AuthenticationManager instance and allows its list of AuthenticationProviders to be defined. Also allows you to define an alias to allow you to reference the AuthenticationManager in your own beans. + + + + Indicates that the contained user-service should be used as an authentication source. + + + + + element which defines a password encoding strategy. Used by an authentication provider to convert submitted passwords to hashed versions, for example. + + + + Password salting strategy. A system-wide constant or a property from the UserDetails object can be used. + + + + A property of the UserDetails object which will be used as salt by a password encoder. Typically something like "username" might be used. + + + + + A single value that will be used as the salt for a password encoder. + + + + + Defines a reference to a Spring bean Id. + + + + + + + + + + + Sets up an ldap authentication provider + + + + Specifies that an LDAP provider should use an LDAP compare operation of the user's password to authenticate the user + + + + element which defines a password encoding strategy. Used by an authentication provider to convert submitted passwords to hashed versions, for example. + + + + Password salting strategy. A system-wide constant or a property from the UserDetails object can be used. + + + + A property of the UserDetails object which will be used as salt by a password encoder. Typically something like "username" might be used. + + + + + A single value that will be used as the salt for a password encoder. + + + + + Defines a reference to a Spring bean Id. + + + + + + + + + + + + + + + + + + + A bean identifier, used for referring to the bean elsewhere in the context. + + + + + An alias you wish to use for the AuthenticationManager bean (not required it you are using a specific id) + + + + + If set to true, the AuthenticationManger will attempt to clear any credentials data in the returned Authentication object, once the user has been authenticated. + + + + + + + + Defines a reference to a Spring bean Id. + + + + + A reference to a user-service (or UserDetailsService bean) Id + + + + + Creates an in-memory UserDetailsService from a properties file or a list of "user" child elements. Usernames are converted to lower-case internally to allow for case-insensitive lookups, so this should not be used if case-sensitivity is required. + + + + Represents a user in the application. + + + + + + + A bean identifier, used for referring to the bean elsewhere in the context. + + + + + + + + The location of a Properties file where each line is in the format of username=password,grantedAuthority[,grantedAuthority][,enabled|disabled] + + + + + + + + The username assigned to the user. + + + + + The password assigned to the user. This may be hashed if the corresponding authentication provider supports hashing (remember to set the "hash" attribute of the "user-service" element). This attribute be omitted in the case where the data will not be used for authentication, but only for accessing authorities. If omitted, the namespace will generate a random value, preventing its accidental use for authentication. Cannot be empty. + + + + + One of more authorities granted to the user. Separate authorities with a comma (but no space). For example, "ROLE_USER,ROLE_ADMINISTRATOR" + + + + + Can be set to "true" to mark an account as locked and unusable. + + + + + Can be set to "true" to mark an account as disabled and unusable. + + + + + Causes creation of a JDBC-based UserDetailsService. + + + + A bean identifier, used for referring to the bean elsewhere in the context. + + + + + + + + The bean ID of the DataSource which provides the required tables. + + + + + Defines a reference to a cache for use with a UserDetailsService. + + + + + An SQL statement to query a username, password, and enabled status given a username. Default is "select username,password,enabled from users where username = ?" + + + + + An SQL statement to query for a user's granted authorities given a username. The default is "select username, authority from authorities where username = ?" + + + + + An SQL statement to query user's group authorities given a username. The default is "select g.id, g.group_name, ga.authority from groups g, group_members gm, group_authorities ga where gm.username = ? and g.id = ga.group_id and g.id = gm.group_id" + + + + + A non-empty string prefix that will be added to role strings loaded from persistent storage (e.g. "ROLE_"). Use the value "none" for no prefix in cases where the default is non-empty. + + + + + + Enable basic clickjacking support for newer browsers (IE8+), will set the X-Frame-Options header. + + + + + + + Specify the policy to use for the X-Frame-Options-Header. + + + + + + + + + + + + Specify the origin to use when ALLOW-FROM is chosen. + + + + + Enable basic XSS browser protection, supported by newer browsers (IE8+), will set the X-XSS-Protection header. + + + + + + + enable or disable the X-XSS-Protection header. Default is 'true' meaning it is enabled. + + + + + Add mode=block to the header or not, default is on. + + + + + Add a X-Content-Type-Options header to the resopnse. Value is always 'nosniff'. + + + Add additional headers to the response. + + + + + + + The name of the header to add. + + + + + The value for the header. + + + + + + Used to indicate that a filter bean declaration should be incorporated into the security filter chain. + + + + + + + + The filter immediately after which the custom-filter should be placed in the chain. This feature will only be needed by advanced users who wish to mix their own filters into the security filter chain and have some knowledge of the standard Spring Security filters. The filter names map to specific Spring Security implementation filters. + + + + + The filter immediately before which the custom-filter should be placed in the chain + + + + + The explicit position at which the custom-filter should be placed in the chain. Use if you are replacing a standard filter. + + + + + + + The filter immediately after which the custom-filter should be placed in the chain. This feature will only be needed by advanced users who wish to mix their own filters into the security filter chain and have some knowledge of the standard Spring Security filters. The filter names map to specific Spring Security implementation filters. + + + + + + + The filter immediately before which the custom-filter should be placed in the chain + + + + + + + The explicit position at which the custom-filter should be placed in the chain. Use if you are replacing a standard filter. + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/config/src/main/resources/org/springframework/security/config/spring-security.xsl b/config/src/main/resources/org/springframework/security/config/spring-security.xsl index fe34d23d6e3..5f2d6581701 100644 --- a/config/src/main/resources/org/springframework/security/config/spring-security.xsl +++ b/config/src/main/resources/org/springframework/security/config/spring-security.xsl @@ -9,7 +9,7 @@ - ,access-denied-handler,anonymous,session-management,concurrency-control,after-invocation-provider,authentication-provider,ldap-authentication-provider,user,port-mapping,openid-login,expression-handler,form-login,http-basic,intercept-url,logout,password-encoder,port-mappings,port-mapper,password-compare,protect,protect-pointcut,pre-post-annotation-handling,pre-invocation-advice,post-invocation-advice,invocation-attribute-factory,remember-me,salt-source,x509, + ,access-denied-handler,anonymous,session-management,concurrency-control,after-invocation-provider,authentication-provider,ldap-authentication-provider,user,port-mapping,openid-login,expression-handler,form-login,http-basic,intercept-url,logout,password-encoder,port-mappings,port-mapper,password-compare,protect,protect-pointcut,pre-post-annotation-handling,pre-invocation-advice,post-invocation-advice,invocation-attribute-factory,remember-me,salt-source,x509,add-headers, diff --git a/config/src/test/groovy/org/springframework/security/config/doc/XsdDocumentedTests.groovy b/config/src/test/groovy/org/springframework/security/config/doc/XsdDocumentedTests.groovy index 4ad24b87fe7..c5c9bfca1a4 100644 --- a/config/src/test/groovy/org/springframework/security/config/doc/XsdDocumentedTests.groovy +++ b/config/src/test/groovy/org/springframework/security/config/doc/XsdDocumentedTests.groovy @@ -29,7 +29,7 @@ class XsdDocumentedTests extends Specification { @Shared def appendix = new File('../docs/manual/src/docbook/appendix-namespace.xml') @Shared def appendixRoot = new XmlSlurper().parse(appendix) - @Shared File schemaDocument = new File('src/main/resources/org/springframework/security/config/spring-security-3.1.xsd') + @Shared File schemaDocument = new File('src/main/resources/org/springframework/security/config/spring-security-3.2.xsd') @Shared Map elementNameToElement def setupSpec() { @@ -64,8 +64,8 @@ class XsdDocumentedTests extends Specification { def 'the latest schema is being validated'() { when: 'all the schemas are found' def schemas = schemaDocument.getParentFile().list().findAll { it.endsWith('.xsd') } - then: 'the count is equal to 7, if not then schemaDocument needs updated' - schemas.size() == 7 + then: 'the count is equal to 8, if not then schemaDocument needs updated' + schemas.size() == 8 } /** diff --git a/config/src/test/resources/org/springframework/security/util/filtertest-valid.xml b/config/src/test/resources/org/springframework/security/util/filtertest-valid.xml index a2cda067c62..f8e58820e34 100644 --- a/config/src/test/resources/org/springframework/security/util/filtertest-valid.xml +++ b/config/src/test/resources/org/springframework/security/util/filtertest-valid.xml @@ -24,7 +24,7 @@ xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd - http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd"> + http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd"> diff --git a/docs/manual/src/docbook/appendix-namespace.xml b/docs/manual/src/docbook/appendix-namespace.xml index 88efb40deb3..6308e0017a3 100644 --- a/docs/manual/src/docbook/appendix-namespace.xml +++ b/docs/manual/src/docbook/appendix-namespace.xml @@ -208,6 +208,7 @@ Child Elements of <http> access-denied-handler + add-headers anonymous custom-filter expression-handler @@ -255,6 +256,131 @@ +
+ <literal><add-headers></literal> + This element allows for configuring additional (security) headers to be send with the response. + It enables easy configuration for several headers and also allows for setting custom headers through + the header element. + + X-Frame-Options - Can be set using the + frame-options element. The + X-Frame-Options + header can be used to prevent clickjacking attacks. + X-XSS-Protection - Can be set using the + xss-protection element. + The X-XSS-Protection + header can be used by browser to do basic control. + X-Content-Type-Options - Can be set using the + content-type-options element. The + X-Content-Type-Options header prevents Internet Explorer from + MIME-sniffing a response away from the declared content-type. This also applies to Google + Chrome, when downloading extensions. + + +
+ Parent Elements of <literal><add-headers></literal> + + http + +
+
+ Child Elements of <literal><add-headers></literal> + + content-type-options + frame-options + header + xss-protection + +
+
+
+ <literal><frame-options></literal> + When enabled adds the X-Frame-Options header to the response, this allows newer browsers to do some security + checks and prevent clickjacking attacks. +
+ <literal><frame-options></literal> Attributes +
+ <literal>frame-options-policy</literal> + + + DENY The page cannot be displayed in a frame, regardless of + the site attempting to do so. + SAMEORIGIN The page can only be displayed in a frame on the + same origin as the page itself + ALLOW-FROM origin + The page can only be displayed in a frame on the specified origin. + + + In other words, if you specify DENY, not only will attempts to load the page in a frame fail + when loaded from other sites, attempts to do so will fail when loaded from the same site. On the + other hand, if you specify SAMEORIGIN, you can still use the page in a frame as long as the site + including it in a frame it is the same as the one serving the page. + +
+
+ <literal>frame-options-origin</literal> + The origin +
+
+
+ Parent Elements of <literal><frame-options></literal> + + add-headers + +
+
+
+ <literal><xss-protection></literal> + Adds the X-XSS-Protection header to the response. This is in no-way a full protection to XSS attacks! +
+
+ <literal>xss-protection-enabled</literal> + Enable or Disable xss-protection. +
+
+ <literal>xss-protection-block</literal> + When enabled adds mode=block to the header. Which indicates to the browser that loading should be blocked. +
+
+
+ Parent Elements of <literal><xss-protection></literal> + + add-headers + +
+
+
+ <literal><content-type-options></literal> + Add the X-Content-Type-Options header to the response. Indicates the browser (IE8+) to enable detection + for MIME-sniffing. +
+ Parent Elements of <literal><content-type-options></literal> + + add-headers + +
+
+
+ <literal><header></literal> + Add additional headers to the response, both the name and value need to be specified. +
+ <literal><header-attributes></literal> Attributes +
+ <literal>header-name</literal> + The name of the header. +
+
+ <literal>header-value</literal> + The value of the header to add. +
+
+
+ Parent Elements of <literal><header></literal> + + add-headers + +
+
<literal><anonymous></literal> Adds an AnonymousAuthenticationFilter to the stack and an diff --git a/web/src/main/java/org/springframework/security/web/headers/AddHeadersFilter.java b/web/src/main/java/org/springframework/security/web/headers/AddHeadersFilter.java new file mode 100644 index 00000000000..762ab20236a --- /dev/null +++ b/web/src/main/java/org/springframework/security/web/headers/AddHeadersFilter.java @@ -0,0 +1,66 @@ +/* + * Copyright 2002-2012 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.security.web.headers; + +import org.springframework.web.filter.GenericFilterBean; + +import javax.servlet.FilterChain; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletResponse; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +/** + * Filter implementation to add headers to the current request. Can be useful to add certain headers which enable + * browser protection. Like X-Frame-Options, X-XSS-Protection and X-Content-Type-Options. + * + * @author Marten Deinum + * @since 3.2 + * + */ +public class AddHeadersFilter extends GenericFilterBean { + + /** Map of headers to add to a response */ + private final Map headers = new HashMap(); + + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { + chain.doFilter(request, response); + + if (response instanceof HttpServletResponse) { + for (Map.Entry header : headers.entrySet()) { + String name = header.getKey(); + String value = header.getValue(); + if (logger.isDebugEnabled()) { + logger.debug("Adding header '" + name + "' with value '"+value +"'"); + } + ((HttpServletResponse) response).setHeader(header.getKey(), header.getValue()); + } + } + } + + public void setHeaders(Map headers) { + this.headers.clear(); + this.headers.putAll(headers); + } + + public void addHeader(String name, String value) { + headers.put(name, value); + } +} From 3057ace2118a4bd4700c608883a1cd4da3a95249 Mon Sep 17 00:00:00 2001 From: Marten Deinum Date: Fri, 21 Dec 2012 14:56:18 +0100 Subject: [PATCH 04/11] Issues: SEC-2098, SEC-2099 AddHeadersFilter for setting security headers added including a bean definition parser for easy configuration of the headers. Enables easy configuration for the X-Frame-Options, X-XSS-Protection and X-Content-Type-Options headers. Also allows for additional headers to be added. Issues: SEC-2098, SEC-2099 AddHeadersFilter for setting security headers added including a bean definition parser for easy configuration of the headers. Enables easy configuration for the X-Frame-Options, X-XSS-Protection and X-Content-Type-Options headers. Also allows for additional headers to be added. Processing comments. --- .../config/SecurityNamespaceHandler.java | 7 +- ....java => HeadersBeanDefinitionParser.java} | 74 +++++++++++++------ .../config/http/HttpConfigurationBuilder.java | 2 +- .../security/config/http/SecurityFilters.java | 2 +- .../security/config/spring-security-3.2.rnc | 50 ++++++------- .../manual/src/docbook/appendix-namespace.xml | 18 ++--- docs/manual/src/docbook/namespace-config.xml | 22 ++++++ .../resources/applicationContext-security.xml | 8 +- ...dHeadersFilter.java => HeadersFilter.java} | 28 +++---- 9 files changed, 130 insertions(+), 81 deletions(-) rename config/src/main/java/org/springframework/security/config/http/{AddHeadersBeanDefinitionParser.java => HeadersBeanDefinitionParser.java} (68%) rename web/src/main/java/org/springframework/security/web/headers/{AddHeadersFilter.java => HeadersFilter.java} (64%) diff --git a/config/src/main/java/org/springframework/security/config/SecurityNamespaceHandler.java b/config/src/main/java/org/springframework/security/config/SecurityNamespaceHandler.java index 6e52a7987aa..6f18f410f3f 100644 --- a/config/src/main/java/org/springframework/security/config/SecurityNamespaceHandler.java +++ b/config/src/main/java/org/springframework/security/config/SecurityNamespaceHandler.java @@ -65,8 +65,9 @@ public SecurityNamespaceHandler() { public BeanDefinition parse(Element element, ParserContext pc) { if (!namespaceMatchesVersion(element)) { - pc.getReaderContext().fatal("You cannot use a spring-security-2.0.xsd or spring-security-3.0.xsd schema " + - "with Spring Security 3.1. Please update your schema declarations to the 3.1 schema.", element); + pc.getReaderContext().fatal("You cannot use a spring-security-2.0.xsd, spring-security-3.0.xsd schema " + + "or spring-security-3.1.xsd with Spring Security 3.2. Please update your schema declarations to the " + + " 3.2 schema.", element); } String name = pc.getDelegate().getLocalName(element); BeanDefinitionParser parser = parsers.get(name); @@ -180,7 +181,7 @@ private boolean namespaceMatchesVersion(Element element) { private boolean matchesVersionInternal(Element element) { String schemaLocation = element.getAttributeNS("http://www.w3.org/2001/XMLSchema-instance", "schemaLocation"); - return schemaLocation.matches("(?m).*spring-security-3\\.[12].*.xsd.*") + return schemaLocation.matches("(?m).*spring-security-3\\.2.*.xsd.*") || schemaLocation.matches("(?m).*spring-security.xsd.*") || !schemaLocation.matches("(?m).*spring-security.*"); } diff --git a/config/src/main/java/org/springframework/security/config/http/AddHeadersBeanDefinitionParser.java b/config/src/main/java/org/springframework/security/config/http/HeadersBeanDefinitionParser.java similarity index 68% rename from config/src/main/java/org/springframework/security/config/http/AddHeadersBeanDefinitionParser.java rename to config/src/main/java/org/springframework/security/config/http/HeadersBeanDefinitionParser.java index 2ba16e90d8d..ce7d228f1c9 100644 --- a/config/src/main/java/org/springframework/security/config/http/AddHeadersBeanDefinitionParser.java +++ b/config/src/main/java/org/springframework/security/config/http/HeadersBeanDefinitionParser.java @@ -19,7 +19,8 @@ import org.springframework.beans.factory.support.BeanDefinitionBuilder; import org.springframework.beans.factory.xml.BeanDefinitionParser; import org.springframework.beans.factory.xml.ParserContext; -import org.springframework.security.web.headers.AddHeadersFilter; +import org.springframework.security.web.headers.HeadersFilter; +import org.springframework.util.StringUtils; import org.springframework.util.xml.DomUtils; import org.w3c.dom.Element; @@ -28,12 +29,12 @@ import java.util.Map; /** - * Parser for the {@code AddHeadersFilter}. + * Parser for the {@code HeadersFilter}. * * @author Marten Deinum * @since 3.2 */ -public class AddHeadersBeanDefinitionParser implements BeanDefinitionParser { +public class HeadersBeanDefinitionParser implements BeanDefinitionParser { private static final String ATT_ENABLED = "enabled"; private static final String ATT_BLOCK = "block"; @@ -56,43 +57,68 @@ public class AddHeadersBeanDefinitionParser implements BeanDefinitionParser { private static final String ALLOW_FROM = "ALLOW-FROM"; public BeanDefinition parse(Element element, ParserContext parserContext) { - BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(AddHeadersFilter.class); + BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(HeadersFilter.class); final Map headers = new HashMap(); - Element xssElt = DomUtils.getChildElementByTagName(element, XSS_ELEMENT); - Element contentTypeElt = DomUtils.getChildElementByTagName(element, CONTENT_TYPE_ELEMENT); - Element frameElt = DomUtils.getChildElementByTagName(element, FRAME_OPTIONS_ELEMENT); + parseXssElement(element, headers); + parseFrameOptionsElement(element, parserContext, headers); + parseContentTypeOptionsElement(element, headers); - if (xssElt != null) { - boolean enabled = "true".equalsIgnoreCase(xssElt.getAttribute(ATT_ENABLED)); - boolean block = "true".equalsIgnoreCase(xssElt.getAttribute(ATT_BLOCK)); + parseHeaderElements(element, headers); - String value = enabled ? "1" : "0"; - if (enabled && block) { - value += "; mode=block"; - } - headers.put(XSS_PROTECTION_HEADER, value); + builder.addPropertyValue("headers", headers); + return builder.getBeanDefinition(); + } + + private void parseHeaderElements(Element element, Map headers) { + List headerEtls = DomUtils.getChildElementsByTagName(element, GENERIC_HEADER_ELEMENT); + for (Element headerEtl : headerEtls) { + headers.put(headerEtl.getAttribute(ATT_NAME), headerEtl.getAttribute(ATT_VALUE)); + } + } + + private void parseContentTypeOptionsElement(Element element, Map headers) { + Element contentTypeElt = DomUtils.getChildElementByTagName(element, CONTENT_TYPE_ELEMENT); + if (contentTypeElt != null) { + headers.put(CONTENT_TYPE_OPTIONS_HEADER, "nosniff"); } + } + private void parseFrameOptionsElement(Element element, ParserContext parserContext, Map headers) { + Element frameElt = DomUtils.getChildElementByTagName(element, FRAME_OPTIONS_ELEMENT); if (frameElt != null) { - String header = frameElt.getAttribute(ATT_POLICY); + String header = getAttribute(frameElt, ATT_POLICY, "DENY"); if (ALLOW_FROM.equals(header) ) { String origin = frameElt.getAttribute(ATT_ORIGIN); + if (!StringUtils.hasText(origin) ) { + parserContext.getReaderContext().error("Frame options header value ALLOW-FROM required an origin to be specified.", frameElt); + } header += " " + origin; } headers.put(FRAME_OPTIONS_HEADER, header); } + } - if (contentTypeElt != null) { - headers.put(CONTENT_TYPE_OPTIONS_HEADER, "nosniff"); - } + private void parseXssElement(Element element, Map headers) { + Element xssElt = DomUtils.getChildElementByTagName(element, XSS_ELEMENT); + if (xssElt != null) { + boolean enabled = Boolean.valueOf(getAttribute(xssElt, ATT_ENABLED, "true")); + boolean block = Boolean.valueOf(getAttribute(xssElt, ATT_BLOCK, "true")); - List headerEtls = DomUtils.getChildElementsByTagName(element, GENERIC_HEADER_ELEMENT); - for (Element headerEtl : headerEtls) { - headers.put(headerEtl.getAttribute(ATT_NAME), headerEtl.getAttribute(ATT_VALUE)); + String value = enabled ? "1" : "0"; + if (enabled && block) { + value += "; mode=block"; + } + headers.put(XSS_PROTECTION_HEADER, value); } + } - builder.addPropertyValue("headers", headers); - return builder.getBeanDefinition(); + private String getAttribute(Element element, String name, String defaultValue) { + String value = element.getAttribute(name); + if (StringUtils.hasText(value)) { + return value; + } else { + return defaultValue; + } } } diff --git a/config/src/main/java/org/springframework/security/config/http/HttpConfigurationBuilder.java b/config/src/main/java/org/springframework/security/config/http/HttpConfigurationBuilder.java index 3f4f717573d..d3a8220baa0 100644 --- a/config/src/main/java/org/springframework/security/config/http/HttpConfigurationBuilder.java +++ b/config/src/main/java/org/springframework/security/config/http/HttpConfigurationBuilder.java @@ -559,7 +559,7 @@ private void createFilterSecurityInterceptor(BeanReference authManager) { private void createAddHeadersFilter() { Element elmt = DomUtils.getChildElementByTagName(httpElt, Elements.ADD_HEADERS); if (elmt != null) { - this.addHeadersFilter = new AddHeadersBeanDefinitionParser().parse(elmt, pc); + this.addHeadersFilter = new HeadersBeanDefinitionParser().parse(elmt, pc); } } diff --git a/config/src/main/java/org/springframework/security/config/http/SecurityFilters.java b/config/src/main/java/org/springframework/security/config/http/SecurityFilters.java index 3ff9834e9ae..20194ecedbf 100644 --- a/config/src/main/java/org/springframework/security/config/http/SecurityFilters.java +++ b/config/src/main/java/org/springframework/security/config/http/SecurityFilters.java @@ -29,7 +29,7 @@ enum SecurityFilters { CONCURRENT_SESSION_FILTER, /** {@link WebAsyncManagerIntegrationFilter} */ WEB_ASYNC_MANAGER_FILTER, - ADD_HEADERS_FILTER, + HEADERS_FILTER, LOGOUT_FILTER, X509_FILTER, PRE_AUTH_FILTER, diff --git a/config/src/main/resources/org/springframework/security/config/spring-security-3.2.rnc b/config/src/main/resources/org/springframework/security/config/spring-security-3.2.rnc index 29cc8d81cfa..b2d810c9476 100644 --- a/config/src/main/resources/org/springframework/security/config/spring-security-3.2.rnc +++ b/config/src/main/resources/org/springframework/security/config/spring-security-3.2.rnc @@ -716,46 +716,44 @@ jdbc-user-service.attlist &= jdbc-user-service.attlist &= role-prefix? -add-headers = - ## Element for configuration of the AddHeadersFilter. Enables easy setting for the X-Frame-Options, X-XSS-Protection and X-Content-Type-Options headers. - element add-headers {xss-protection? | frame-options? | content-type-options? | header*} +headers = + ## Element for configuration of the HeadersFilter. Enables easy setting for the X-Frame-Options, X-XSS-Protection and X-Content-Type-Options headers. + element headers {xss-protection? & frame-options? & content-type-options? & header*} frame-options = - ## Enable basic clickjacking support for newer browsers (IE8+), will set the X-Frame-Options header. - element frame-options {frame-options.attlist} + ## Enable basic clickjacking support for newer browsers (IE8+), will set the X-Frame-Options header. + element frame-options {frame-options.attlist, empty} frame-options.attlist &= - ## Specify the policy to use for the X-Frame-Options-Header. - [ a:defaultValue = "DENY" ] - attribute policy {"DENY","SAMEORIGIN","ALLOW-FROM"}? + ## Specify the policy to use for the X-Frame-Options-Header. + attribute policy {"DENY","SAMEORIGIN","ALLOW-FROM"}? frame-options.attlist &= - ## Specify the origin to use when ALLOW-FROM is chosen. - attribute origin {xsd:token}? + ## Specify the origin to use when ALLOW-FROM is chosen. + attribute origin {xsd:token}? xss-protection = - ## Enable basic XSS browser protection, supported by newer browsers (IE8+), will set the X-XSS-Protection header. - element xss-protection {xss-protection.attlist} + ## Enable basic XSS browser protection, supported by newer browsers (IE8+), will set the X-XSS-Protection header. + element xss-protection {xss-protection.attlist, empty} xss-protection.attlist &= - ## enable or disable the X-XSS-Protection header. Default is 'true' meaning it is enabled. - [ a:defaultValue = "true" ] - attribute enabled {xsd:boolean}? + ## enable or disable the X-XSS-Protection header. Default is 'true' meaning it is enabled. + attribute enabled {xsd:boolean}? xss-protection.attlist &= - ## Add mode=block to the header or not, default is on. - [ a:defaultValue = "true" ] - attribute block {xsd:boolean}? + ## Add mode=block to the header or not, default is on. + [ a:defaultValue = "true" ] + attribute block {xsd:boolean}? content-type-options = - ## Add a X-Content-Type-Options header to the resopnse. Value is always 'nosniff'. - element content-type-options {empty} + ## Add a X-Content-Type-Options header to the resopnse. Value is always 'nosniff'. + element content-type-options {empty} header= - ## Add additional headers to the response. - element header {header.attlist} + ## Add additional headers to the response. + element header {header.attlist, empty} header.attlist &= - ## The name of the header to add. - attribute name {xsd:token} + ## The name of the header to add. + attribute name {xsd:token} header.attlist &= - ## The value for the header. - attribute value {xsd:token} + ## The value for the header. + attribute value {xsd:token} any-user-service = user-service | jdbc-user-service | ldap-user-service diff --git a/docs/manual/src/docbook/appendix-namespace.xml b/docs/manual/src/docbook/appendix-namespace.xml index 2404e01950d..8d92d2ee12b 100644 --- a/docs/manual/src/docbook/appendix-namespace.xml +++ b/docs/manual/src/docbook/appendix-namespace.xml @@ -204,11 +204,11 @@ access-control.
-
- <literal><add-headers></literal> +
+ <literal><headers></literal> This element allows for configuring additional (security) headers to be send with the response. - It enables easy configuration for several headers and also allows for setting custom headers through - the header element. + It enables easy configuration for several headers and also allows for setting additional custom + headers through the header element. X-Frame-Options - Can be set using the frame-options element. The @@ -250,14 +250,14 @@
-
- Parent Elements of <literal><add-headers></literal> +
+ Parent Elements of <literal><headers></literal> http
-
- Child Elements of <literal><add-headers></literal> +
+ Child Elements of <literal><headers></literal> frame-options xss-protection @@ -270,7 +270,7 @@ Child Elements of <http> access-denied-handler - add-headers + headers anonymous custom-filter expression-handler diff --git a/docs/manual/src/docbook/namespace-config.xml b/docs/manual/src/docbook/namespace-config.xml index 0759c12b8d2..fcf9f8a880a 100644 --- a/docs/manual/src/docbook/namespace-config.xml +++ b/docs/manual/src/docbook/namespace-config.xml @@ -639,6 +639,23 @@ List<OpenIDAttribute> attributes = token.getAttributes();The MyOpenID providers.
+
+ Response Headers + A lot of different attacks to hijack content, sessions or connections are available and lately + browsers (optionally) can help to prevent those attacks. To enable these features we need to send some + additional headers to the client. Spring Security allows for easy configuration for several headers. + + + + + +
+ + ]]> + + +
Adding in Your Own Filters If you've used Spring Security before, you'll know that the framework maintains a @@ -693,6 +710,11 @@ List<OpenIDAttribute> attributes = token.getAttributes();The ConcurrentSessionFilter session-management/concurrency-control + + HEADERS_FILTER + HeadersFilter + http/headers + LOGOUT_FILTER LogoutFilter diff --git a/samples/contacts/src/main/resources/applicationContext-security.xml b/samples/contacts/src/main/resources/applicationContext-security.xml index 5a952f205d7..143b098fdc2 100644 --- a/samples/contacts/src/main/resources/applicationContext-security.xml +++ b/samples/contacts/src/main/resources/applicationContext-security.xml @@ -11,7 +11,7 @@ xmlns:b="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd - http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd"> + http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd"> @@ -30,6 +30,12 @@ + + + + +
+ diff --git a/web/src/main/java/org/springframework/security/web/headers/AddHeadersFilter.java b/web/src/main/java/org/springframework/security/web/headers/HeadersFilter.java similarity index 64% rename from web/src/main/java/org/springframework/security/web/headers/AddHeadersFilter.java rename to web/src/main/java/org/springframework/security/web/headers/HeadersFilter.java index 762ab20236a..4863d850466 100644 --- a/web/src/main/java/org/springframework/security/web/headers/AddHeadersFilter.java +++ b/web/src/main/java/org/springframework/security/web/headers/HeadersFilter.java @@ -15,14 +15,12 @@ */ package org.springframework.security.web.headers; -import org.springframework.web.filter.GenericFilterBean; +import org.springframework.web.filter.OncePerRequestFilter; import javax.servlet.FilterChain; import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; - import java.io.IOException; import java.util.HashMap; import java.util.Map; @@ -35,24 +33,22 @@ * @since 3.2 * */ -public class AddHeadersFilter extends GenericFilterBean { +public class HeadersFilter extends OncePerRequestFilter { /** Map of headers to add to a response */ private final Map headers = new HashMap(); - public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { - chain.doFilter(request, response); - - if (response instanceof HttpServletResponse) { - for (Map.Entry header : headers.entrySet()) { - String name = header.getKey(); - String value = header.getValue(); - if (logger.isDebugEnabled()) { - logger.debug("Adding header '" + name + "' with value '"+value +"'"); - } - ((HttpServletResponse) response).setHeader(header.getKey(), header.getValue()); + @Override + protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { + for (Map.Entry header : headers.entrySet()) { + String name = header.getKey(); + String value = header.getValue(); + if (logger.isTraceEnabled()) { + logger.trace("Adding header '" + name + "' with value '"+value +"'"); } + response.setHeader(header.getKey(), header.getValue()); } + filterChain.doFilter(request, response); } public void setHeaders(Map headers) { From 9b5cb4eff9e2f4f2e188d342983c7b55f4a4f672 Mon Sep 17 00:00:00 2001 From: Rob Winch Date: Thu, 3 Jan 2013 18:27:15 -0600 Subject: [PATCH 05/11] Make rnc transform part of Gradle build --- buildSrc/build.gradle | 6 + .../src/main/groovy/trang/TrangPlugin.groovy | 59 + .../META-INF/gradle-plugins/trang.properties | 1 + config/config.gradle | 9 + config/convert_schema.sh | 3 - .../security/config/spring-security-3.1.xsd | 3622 ++++++++++------- .../security/config/spring-security.xsl | 10 +- 7 files changed, 2224 insertions(+), 1486 deletions(-) create mode 100644 buildSrc/src/main/groovy/trang/TrangPlugin.groovy create mode 100644 buildSrc/src/main/resources/META-INF/gradle-plugins/trang.properties diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index 97d8b139a8f..c6dedcda8a1 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -49,6 +49,12 @@ dependencies { 'com.springsource.bundlor:com.springsource.bundlor.blint:1.0.0.RELEASE' } +// Trang +dependencies { + compile 'com.thaiopensource:trang:20091111', + 'net.sourceforge.saxon:saxon:9.1.0.8' +} + task ide(type: Copy) { from configurations.runtime into 'ide' diff --git a/buildSrc/src/main/groovy/trang/TrangPlugin.groovy b/buildSrc/src/main/groovy/trang/TrangPlugin.groovy new file mode 100644 index 00000000000..83bdb11fc7d --- /dev/null +++ b/buildSrc/src/main/groovy/trang/TrangPlugin.groovy @@ -0,0 +1,59 @@ +package trang; + +import com.thaiopensource.relaxng.translate.Driver + +import javax.xml.transform.Transformer +import javax.xml.transform.TransformerFactory +import javax.xml.transform.stream.StreamSource +import javax.xml.transform.stream.StreamResult + +import org.gradle.api.*; +import org.gradle.api.tasks.* +import org.gradle.api.file.FileCollection + +/** + * Used for converting .rnc files to .xsd files. + * @author Rob Winch + */ +class TrangPlugin implements Plugin { + public void apply(Project project) { + Task rncToXsd = project.tasks.add('rncToXsd', RncToXsd.class) + rncToXsd.description = 'Converts .rnc to .xsd' + rncToXsd.group = 'Build' + } +} + +/** + * Converts .rnc files to .xsd files using trang and then applies an xsl file to cleanup the results. + */ +public class RncToXsd extends DefaultTask { + @InputDirectory + File rncDir + + @InputFile + File xslFile + + @OutputDirectory + File xsdDir + + @TaskAction + public final void transform() { + String xslPath = xslFile.absolutePath + rncDir.listFiles( { dir, file -> file.endsWith('.rnc')} as FilenameFilter).each { rncFile -> + File xsdFile = new File(xsdDir, rncFile.name.replace('.rnc', '.xsd')) + String xsdOutputPath = xsdFile.absolutePath + new Driver().run([rncFile.absolutePath, xsdOutputPath] as String[]); + + TransformerFactory tFactory = new net.sf.saxon.TransformerFactoryImpl() + Transformer transformer = + tFactory.newTransformer(new StreamSource(xslPath)) + File temp = File.createTempFile("gradle-trang-" + xsdFile.name, ".xsd") + xsdFile.withInputStream { is -> + temp << is + } + StreamSource xmlSource = new StreamSource(temp) + transformer.transform(xmlSource, new StreamResult(xsdFile)) + temp.delete() + } + } +} \ No newline at end of file diff --git a/buildSrc/src/main/resources/META-INF/gradle-plugins/trang.properties b/buildSrc/src/main/resources/META-INF/gradle-plugins/trang.properties new file mode 100644 index 00000000000..4ef5e2b39e4 --- /dev/null +++ b/buildSrc/src/main/resources/META-INF/gradle-plugins/trang.properties @@ -0,0 +1 @@ +implementation-class=trang.TrangPlugin \ No newline at end of file diff --git a/config/config.gradle b/config/config.gradle index 6d16f62edbb..aeed6ce299b 100644 --- a/config/config.gradle +++ b/config/config.gradle @@ -1,6 +1,7 @@ // Config Module build file apply plugin: 'groovy' +apply plugin: 'trang' compileTestJava.dependsOn(':spring-security-core:compileTestJava') @@ -52,3 +53,11 @@ test { integrationTest { systemProperties['apacheDSWorkDir'] = "${buildDir}/apacheDSWork" } + +rncToXsd { + rncDir = file('src/main/resources/org/springframework/security/config/') + xsdDir = rncDir + xslFile = new File(rncDir, 'spring-security.xsl') +} + +build.dependsOn rncToXsd \ No newline at end of file diff --git a/config/convert_schema.sh b/config/convert_schema.sh index f229457e730..6f182f77e9e 100755 --- a/config/convert_schema.sh +++ b/config/convert_schema.sh @@ -1,6 +1,3 @@ -#! /bin/sh - -pushd src/main/resources/org/springframework/security/config/ echo "Converting rnc file to xsd ..." java -jar ~/bin/trang.jar spring-security-3.2.rnc spring-security-3.2.xsd diff --git a/config/src/main/resources/org/springframework/security/config/spring-security-3.1.xsd b/config/src/main/resources/org/springframework/security/config/spring-security-3.1.xsd index da0a9eb5b0f..2485e4eeb75 100644 --- a/config/src/main/resources/org/springframework/security/config/spring-security-3.1.xsd +++ b/config/src/main/resources/org/springframework/security/config/spring-security-3.1.xsd @@ -1,611 +1,834 @@ - - + + - - - Defines the hashing algorithm used on user passwords. We recommend strongly against using MD4, as it is a very weak hashing algorithm. - - - - - - - - - - - - - + + + Defines the hashing algorithm used on user passwords. We recommend strongly against using + MD4, as it is a very weak hashing algorithm. + + + + + + + + + + + + + + - - - Whether a string should be base64 encoded - - + + + Whether a string should be base64 encoded + + + - - - Supersedes the 'path-type' attribute. Defines the strategy use for matching incoming requests. Currently the options are 'ant' (for ant path patterns), 'regex' for regular expressions and 'ciRegex' for case-insensitive regular expressions. - - - - - - - - - + + + Supersedes the 'path-type' attribute. Defines the strategy use for matching incoming + requests. Currently the options are 'ant' (for ant path patterns), 'regex' for regular + expressions and 'ciRegex' for case-insensitive regular expressions. + + + + + + + + + + - - - Deprecated. Use request-matcher instead. - - - - - - - - + + + Deprecated. Use request-matcher instead. + + + + + + + + + - - - Specifies an IP port number. Used to configure an embedded LDAP server, for example. - - + + + Specifies an IP port number. Used to configure an embedded LDAP server, for example. + + + - - - Specifies a URL. - - + + + Specifies a URL. + + + - - - A bean identifier, used for referring to the bean elsewhere in the context. - - + + + A bean identifier, used for referring to the bean elsewhere in the context. + + + - - - A bean identifier, used for referring to the bean elsewhere in the context. - - + + + A bean identifier, used for referring to the bean elsewhere in the context. + + + - - - Defines a reference to a Spring bean Id. - - + + + Defines a reference to a Spring bean Id. + + + - - - Defines a reference to a cache for use with a UserDetailsService. - - + + + Defines a reference to a cache for use with a UserDetailsService. + + + - - - A reference to a user-service (or UserDetailsService bean) Id - - + + + A reference to a user-service (or UserDetailsService bean) Id + + + - - - A reference to an AuthenticationManager bean - - + + + A reference to an AuthenticationManager bean + + + - + + + A reference to a DataSource bean + + + + + - A reference to a DataSource bean + Enables Spring Security debugging infrastructure. This will provide human-readable + (multi-line) debugging information to monitor requests coming into the security filters. + This may include sensitive information, such as request parameters or headers, and should + only be used in a development environment. + - - - - Enables Spring Security debugging infrastructure. This will provide human-readable (multi-line) debugging information to monitor requests coming into the security filters. This may include sensitive information, such as request parameters or headers, and should only be used in a development environment. - + + - - - Defines a reference to a Spring bean Id. - - - - - Defines the hashing algorithm used on user passwords. We recommend strongly against using MD4, as it is a very weak hashing algorithm. - - - - - - - - - - - - - - - - Whether a string should be base64 encoded - - + + + Defines a reference to a Spring bean Id. + + + + + + Defines the hashing algorithm used on user passwords. We recommend strongly against using + MD4, as it is a very weak hashing algorithm. + + + + + + + + + + + + + + + + + Whether a string should be base64 encoded + + + - - - A property of the UserDetails object which will be used as salt by a password encoder. Typically something like "username" might be used. - - + + + A property of the UserDetails object which will be used as salt by a password encoder. + Typically something like "username" might be used. + + + - - - A single value that will be used as the salt for a password encoder. - - + + + A single value that will be used as the salt for a password encoder. + + + - - - A non-empty string prefix that will be added to role strings loaded from persistent storage (e.g. "ROLE_"). Use the value "none" for no prefix in cases where the default is non-empty. - - + + + A non-empty string prefix that will be added to role strings loaded from persistent + storage (e.g. "ROLE_"). Use the value "none" for no prefix in cases where the default is + non-empty. + + + - - - Enables the use of expressions in the 'access' attributes in <intercept-url> elements rather than the traditional list of configuration attributes. Defaults to 'false'. If enabled, each attribute should contain a single boolean expression. If the expression evaluates to 'true', access will be granted. - - + + + Enables the use of expressions in the 'access' attributes in <intercept-url> elements + rather than the traditional list of configuration attributes. Defaults to 'false'. If + enabled, each attribute should contain a single boolean expression. If the expression + evaluates to 'true', access will be granted. + + + - - Defines an LDAP server location or starts an embedded server. The url indicates the location of a remote server. If no url is given, an embedded server will be started, listening on the supplied port number. The port is optional and defaults to 33389. A Spring LDAP ContextSource bean will be registered for the server with the id supplied. - - - - - - - A bean identifier, used for referring to the bean elsewhere in the context. - - - + - Specifies a URL. + Defines an LDAP server location or starts an embedded server. The url indicates the + location of a remote server. If no url is given, an embedded server will be started, + listening on the supplied port number. The port is optional and defaults to 33389. A + Spring LDAP ContextSource bean will be registered for the server with the id supplied. + - - - - Specifies an IP port number. Used to configure an embedded LDAP server, for example. - - - - - Username (DN) of the "manager" user identity which will be used to authenticate to a (non-embedded) LDAP server. If omitted, anonymous access will be used. - - - - - The password for the manager DN. This is required if the manager-dn is specified. - - - - - Explicitly specifies an ldif file resource to load into an embedded LDAP server. The default is classpath*:*.ldiff - - - - - Optional root suffix for the embedded LDAP server. Default is "dc=springframework,dc=org" - - + + + + + + + + A bean identifier, used for referring to the bean elsewhere in the context. + + + + + + Specifies a URL. + + + + + + Specifies an IP port number. Used to configure an embedded LDAP server, for example. + + + + + + Username (DN) of the "manager" user identity which will be used to authenticate to a + (non-embedded) LDAP server. If omitted, anonymous access will be used. + + + + + + The password for the manager DN. This is required if the manager-dn is specified. + + + + + + Explicitly specifies an ldif file resource to load into an embedded LDAP server. The + default is classpath*:*.ldiff + + + + + + Optional root suffix for the embedded LDAP server. Default is "dc=springframework,dc=org" + + + - - - The optional server to use. If omitted, and a default LDAP server is registered (using <ldap-server> with no Id), that server will be used. - - + + + The optional server to use. If omitted, and a default LDAP server is registered (using + <ldap-server> with no Id), that server will be used. + + + - - - Group search filter. Defaults to (uniqueMember={0}). The substituted parameter is the DN of the user. - - + + + Group search filter. Defaults to (uniqueMember={0}). The substituted parameter is the DN + of the user. + + + - - - Search base for group membership searches. Defaults to "" (searching from the root). - - + + + Search base for group membership searches. Defaults to "" (searching from the root). + + + - - - The LDAP filter used to search for users (optional). For example "(uid={0})". The substituted parameter is the user's login name. - - + + + The LDAP filter used to search for users (optional). For example "(uid={0})". The + substituted parameter is the user's login name. + + + - - - Search base for user searches. Defaults to "". Only used with a 'user-search-filter'. - - + + + Search base for user searches. Defaults to "". Only used with a 'user-search-filter'. + + + - - - The LDAP attribute name which contains the role name which will be used within Spring Security. Defaults to "cn". - - + + + The LDAP attribute name which contains the role name which will be used within Spring + Security. Defaults to "cn". + + + - - - Allows the objectClass of the user entry to be specified. If set, the framework will attempt to load standard attributes for the defined class into the returned UserDetails object - - - - - - - - + + + Allows the objectClass of the user entry to be specified. If set, the framework will + attempt to load standard attributes for the defined class into the returned UserDetails + object + + + + + + + + + - - - Allows explicit customization of the loaded user object by specifying a UserDetailsContextMapper bean which will be called with the context information from the user's directory entry - - + + + Allows explicit customization of the loaded user object by specifying a + UserDetailsContextMapper bean which will be called with the context information from the + user's directory entry + + + - - This element configures a LdapUserDetailsService which is a combination of a FilterBasedLdapUserSearch and a DefaultLdapAuthoritiesPopulator. - - - - - - - A bean identifier, used for referring to the bean elsewhere in the context. - - - - - The optional server to use. If omitted, and a default LDAP server is registered (using <ldap-server> with no Id), that server will be used. - - - - - The LDAP filter used to search for users (optional). For example "(uid={0})". The substituted parameter is the user's login name. - - - - - Search base for user searches. Defaults to "". Only used with a 'user-search-filter'. - - - - - Group search filter. Defaults to (uniqueMember={0}). The substituted parameter is the DN of the user. - - - - - Search base for group membership searches. Defaults to "" (searching from the root). - - - - - The LDAP attribute name which contains the role name which will be used within Spring Security. Defaults to "cn". - - - - - Defines a reference to a cache for use with a UserDetailsService. - - - - - A non-empty string prefix that will be added to role strings loaded from persistent storage (e.g. "ROLE_"). Use the value "none" for no prefix in cases where the default is non-empty. - - - - - Allows the objectClass of the user entry to be specified. If set, the framework will attempt to load standard attributes for the defined class into the returned UserDetails object - - - - - - - - - + - Allows explicit customization of the loaded user object by specifying a UserDetailsContextMapper bean which will be called with the context information from the user's directory entry + This element configures a LdapUserDetailsService which is a combination of a + FilterBasedLdapUserSearch and a DefaultLdapAuthoritiesPopulator. + - + + + + + + + + A bean identifier, used for referring to the bean elsewhere in the context. + + + + + + The optional server to use. If omitted, and a default LDAP server is registered (using + <ldap-server> with no Id), that server will be used. + + + + + + The LDAP filter used to search for users (optional). For example "(uid={0})". The + substituted parameter is the user's login name. + + + + + + Search base for user searches. Defaults to "". Only used with a 'user-search-filter'. + + + + + + Group search filter. Defaults to (uniqueMember={0}). The substituted parameter is the DN + of the user. + + + + + + Search base for group membership searches. Defaults to "" (searching from the root). + + + + + + The LDAP attribute name which contains the role name which will be used within Spring + Security. Defaults to "cn". + + + + + + Defines a reference to a cache for use with a UserDetailsService. + + + + + + A non-empty string prefix that will be added to role strings loaded from persistent + storage (e.g. "ROLE_"). Use the value "none" for no prefix in cases where the default is + non-empty. + + + + + + Allows the objectClass of the user entry to be specified. If set, the framework will + attempt to load standard attributes for the defined class into the returned UserDetails + object + + + + + + + + + + + + Allows explicit customization of the loaded user object by specifying a + UserDetailsContextMapper bean which will be called with the context information from the + user's directory entry + + + - - - The optional server to use. If omitted, and a default LDAP server is registered (using <ldap-server> with no Id), that server will be used. - - - - - Search base for user searches. Defaults to "". Only used with a 'user-search-filter'. - - - - - The LDAP filter used to search for users (optional). For example "(uid={0})". The substituted parameter is the user's login name. - - - - - Search base for group membership searches. Defaults to "" (searching from the root). - - - - - Group search filter. Defaults to (uniqueMember={0}). The substituted parameter is the DN of the user. - - - - - The LDAP attribute name which contains the role name which will be used within Spring Security. Defaults to "cn". - - - - - A specific pattern used to build the user's DN, for example "uid={0},ou=people". The key "{0}" must be present and will be substituted with the username. - - - - - A non-empty string prefix that will be added to role strings loaded from persistent storage (e.g. "ROLE_"). Use the value "none" for no prefix in cases where the default is non-empty. - - - - - Allows the objectClass of the user entry to be specified. If set, the framework will attempt to load standard attributes for the defined class into the returned UserDetails object - - - - - - - - - - - Allows explicit customization of the loaded user object by specifying a UserDetailsContextMapper bean which will be called with the context information from the user's directory entry - - + + + The optional server to use. If omitted, and a default LDAP server is registered (using + <ldap-server> with no Id), that server will be used. + + + + + + Search base for user searches. Defaults to "". Only used with a 'user-search-filter'. + + + + + + The LDAP filter used to search for users (optional). For example "(uid={0})". The + substituted parameter is the user's login name. + + + + + + Search base for group membership searches. Defaults to "" (searching from the root). + + + + + + Group search filter. Defaults to (uniqueMember={0}). The substituted parameter is the DN + of the user. + + + + + + The LDAP attribute name which contains the role name which will be used within Spring + Security. Defaults to "cn". + + + + + + A specific pattern used to build the user's DN, for example "uid={0},ou=people". The key + "{0}" must be present and will be substituted with the username. + + + + + + A non-empty string prefix that will be added to role strings loaded from persistent + storage (e.g. "ROLE_"). Use the value "none" for no prefix in cases where the default is + non-empty. + + + + + + Allows the objectClass of the user entry to be specified. If set, the framework will + attempt to load standard attributes for the defined class into the returned UserDetails + object + + + + + + + + + + + + Allows explicit customization of the loaded user object by specifying a + UserDetailsContextMapper bean which will be called with the context information from the + user's directory entry + + + - - - The attribute in the directory which contains the user password. Defaults to "userPassword". - - - - - Defines the hashing algorithm used on user passwords. We recommend strongly against using MD4, as it is a very weak hashing algorithm. - - - - - - - - - - - - - - - - Can be used inside a bean definition to add a security interceptor to the bean and set up access configuration attributes for the bean's methods - - - - Defines a protected method and the access control configuration attributes that apply to it. We strongly advise you NOT to mix "protect" declarations with any services provided "global-method-security". - - - - - - + + + The attribute in the directory which contains the user password. Defaults to + "userPassword". + + + + + + Defines the hashing algorithm used on user passwords. We recommend strongly against using + MD4, as it is a very weak hashing algorithm. + + + + + + + + + + + + + + + + + + Can be used inside a bean definition to add a security interceptor to the bean and set up + access configuration attributes for the bean's methods + + + + + + + Defines a protected method and the access control configuration attributes that apply to + it. We strongly advise you NOT to mix "protect" declarations with any services provided + "global-method-security". + + + + + + + + + + - - - Optional AccessDecisionManager bean ID to be used by the created method security interceptor. - - + + + Optional AccessDecisionManager bean ID to be used by the created method security + interceptor. + + + - - - A method name - - - - - Access configuration attributes list that applies to the method, e.g. "ROLE_A,ROLE_B". - - - - - Creates a MethodSecurityMetadataSource instance - - - - Defines a protected method and the access control configuration attributes that apply to it. We strongly advise you NOT to mix "protect" declarations with any services provided "global-method-security". - - - - - - + + + A method name + + + + + + Access configuration attributes list that applies to the method, e.g. "ROLE_A,ROLE_B". + + + + + + + Creates a MethodSecurityMetadataSource instance + + + + + + + Defines a protected method and the access control configuration attributes that apply to + it. We strongly advise you NOT to mix "protect" declarations with any services provided + "global-method-security". + + + + + + + + + + - - - A bean identifier, used for referring to the bean elsewhere in the context. - - - - - Enables the use of expressions in the 'access' attributes in <intercept-url> elements rather than the traditional list of configuration attributes. Defaults to 'false'. If enabled, each attribute should contain a single boolean expression. If the expression evaluates to 'true', access will be granted. - - - - - Provides method security for all beans registered in the Spring application context. Specifically, beans will be scanned for matches with the ordered list of "protect-pointcut" sub-elements, Spring Security annotations and/or. Where there is a match, the beans will automatically be proxied and security authorization applied to the methods accordingly. If you use and enable all four sources of method security metadata (ie "protect-pointcut" declarations, expression annotations, @Secured and also JSR250 security annotations), the metadata sources will be queried in that order. In practical terms, this enables you to use XML to override method security metadata expressed in annotations. If using annotations, the order of precedence is EL-based (@PreAuthorize etc.), @Secured and finally JSR-250. - - - - - Allows the default expression-based mechanism for handling Spring Security's pre and post invocation annotations (@PreFilter, @PreAuthorize, @PostFilter, @PostAuthorize) to be replace entirely. Only applies if these annotations are enabled. - - - - Defines the PrePostInvocationAttributeFactory instance which is used to generate pre and post invocation metadata from the annotated methods. - - - - - Customizes the PreInvocationAuthorizationAdviceVoter with the ref as the PreInvocationAuthorizationAdviceVoter for the <pre-post-annotation-handling> element. - - - - - Customizes the PostInvocationAdviceProvider with the ref as the PostInvocationAuthorizationAdvice for the <pre-post-annotation-handling> element. - - - - - - - Defines the SecurityExpressionHandler instance which will be used if expression-based access-control is enabled. A default implementation (with no ACL support) will be used if not supplied. - - - - - - Defines a protected pointcut and the access control configuration attributes that apply to it. Every bean registered in the Spring application context that provides a method that matches the pointcut will receive security authorization. - - - - - Allows addition of extra AfterInvocationProvider beans which should be called by the MethodSecurityInterceptor created by global-method-security. - - - - - - + + + A bean identifier, used for referring to the bean elsewhere in the context. + + + + + + Enables the use of expressions in the 'access' attributes in <intercept-url> elements + rather than the traditional list of configuration attributes. Defaults to 'false'. If + enabled, each attribute should contain a single boolean expression. If the expression + evaluates to 'true', access will be granted. + + + + + + + Provides method security for all beans registered in the Spring application context. + Specifically, beans will be scanned for matches with the ordered list of + "protect-pointcut" sub-elements, Spring Security annotations and/or. Where there is a + match, the beans will automatically be proxied and security authorization applied to the + methods accordingly. If you use and enable all four sources of method security metadata + (ie "protect-pointcut" declarations, expression annotations, @Secured and also JSR250 + security annotations), the metadata sources will be queried in that order. In practical + terms, this enables you to use XML to override method security metadata expressed in + annotations. If using annotations, the order of precedence is EL-based (@PreAuthorize + etc.), @Secured and finally JSR-250. + + + + + + + + Allows the default expression-based mechanism for handling Spring Security's pre and post + invocation annotations (@PreFilter, @PreAuthorize, @PostFilter, @PostAuthorize) to be + replace entirely. Only applies if these annotations are enabled. + + + + + + + Defines the PrePostInvocationAttributeFactory instance which is used to generate pre and + post invocation metadata from the annotated methods. + + + + + + + + + Customizes the PreInvocationAuthorizationAdviceVoter with the ref as the + PreInvocationAuthorizationAdviceVoter for the <pre-post-annotation-handling> element. + + + + + + + + + Customizes the PostInvocationAdviceProvider with the ref as the + PostInvocationAuthorizationAdvice for the <pre-post-annotation-handling> element. + + + + + + + + + + + + Defines the SecurityExpressionHandler instance which will be used if expression-based + access-control is enabled. A default implementation (with no ACL support) will be used if + not supplied. + + + + + + + + + + Defines a protected pointcut and the access control configuration attributes that apply to + it. Every bean registered in the Spring application context that provides a method that + matches the pointcut will receive security authorization. + + + + + + + + + Allows addition of extra AfterInvocationProvider beans which should be called by the + MethodSecurityInterceptor created by global-method-security. + + + + + + + + + + - - - Specifies whether the use of Spring Security's pre and post invocation annotations (@PreFilter, @PreAuthorize, @PostFilter, @PostAuthorize) should be enabled for this application context. Defaults to "disabled". - - - - - - - - - - - Specifies whether the use of Spring Security's @Secured annotations should be enabled for this application context. Defaults to "disabled". - - - - - - - - - - - Specifies whether JSR-250 style attributes are to be used (for example "RolesAllowed"). This will require the javax.annotation.security classes on the classpath. Defaults to "disabled". - - - - - - - - - - - Optional AccessDecisionManager bean ID to override the default used for method security. - - - - - Optional RunAsmanager implementation which will be used by the configured MethodSecurityInterceptor - - - - - Allows the advice "order" to be set for the method security interceptor. - - - - - If true, class based proxying will be used instead of interface based proxying. - - - - - Can be used to specify that AspectJ should be used instead of the default Spring AOP. If set, secured classes must be woven with the AnnotationSecurityAspect from the spring-security-aspects module. - - - - - - - - - - An external MethodSecurityMetadataSource instance can be supplied which will take priority over other sources (such as the default annotations). - - - - - A reference to an AuthenticationManager bean - - + + + Specifies whether the use of Spring Security's pre and post invocation annotations + (@PreFilter, @PreAuthorize, @PostFilter, @PostAuthorize) should be enabled for this + application context. Defaults to "disabled". + + + + + + + + + + + + Specifies whether the use of Spring Security's @Secured annotations should be enabled for + this application context. Defaults to "disabled". + + + + + + + + + + + + Specifies whether JSR-250 style attributes are to be used (for example "RolesAllowed"). + This will require the javax.annotation.security classes on the classpath. Defaults to + "disabled". + + + + + + + + + + + + Optional AccessDecisionManager bean ID to override the default used for method security. + + + + + + Optional RunAsmanager implementation which will be used by the configured + MethodSecurityInterceptor + + + + + + Allows the advice "order" to be set for the method security interceptor. + + + + + + If true, class based proxying will be used instead of interface based proxying. + + + + + + Can be used to specify that AspectJ should be used instead of the default Spring AOP. If + set, secured classes must be woven with the AnnotationSecurityAspect from the + spring-security-aspects module. + + + + + + + + + + + An external MethodSecurityMetadataSource instance can be supplied which will take priority + over other sources (such as the default annotations). + + + + + + A reference to an AuthenticationManager bean + + + @@ -615,1040 +838,1477 @@ - - - An AspectJ expression, including the 'execution' keyword. For example, 'execution(int com.foo.TargetObject.countLength(String))' (without the quotes). - - - - - Access configuration attributes list that applies to all methods matching the pointcut, e.g. "ROLE_A,ROLE_B" - - + + + An AspectJ expression, including the 'execution' keyword. For example, 'execution(int + com.foo.TargetObject.countLength(String))' (without the quotes). + + + + + + Access configuration attributes list that applies to all methods matching the pointcut, + e.g. "ROLE_A,ROLE_B" + + + - - Allows a custom instance of HttpFirewall to be injected into the FilterChainProxy created by the namespace. - - - - - Container element for HTTP security configuration. Multiple elements can now be defined, each with a specific pattern to which the enclosed security configuration applies. A pattern can also be configured to bypass Spring Security's filters completely by setting the "secured" attribute to "false". - - - - Specifies the access attributes and/or filter list for a particular set of URLs. - - - - - Defines the access-denied strategy that should be used. An access denied page can be defined or a reference to an AccessDeniedHandler instance. - - - - - Sets up a form login configuration for authentication with a username and password - - - - - Sets up form login for authentication with an Open ID identity - - - - - - - - A reference to a user-service (or UserDetailsService bean) Id - - - - - Adds support for X.509 client authentication. - - - - - - Adds support for basic authentication - - - - - Incorporates a logout processing filter. Most web applications require a logout filter, although you may not require one if you write a controller to provider similar logic. - - - - - Session-management related functionality is implemented by the addition of a SessionManagementFilter to the filter stack. - - - - Enables concurrent session control, limiting the number of authenticated sessions a user may have at the same time. - - - - - - - - Sets up remember-me authentication. If used with the "key" attribute (or no attributes) the cookie-only implementation will be used. Specifying "token-repository-ref" or "remember-me-data-source-ref" will use the more secure, persisten token approach. - - - - - Adds support for automatically granting all anonymous web requests a particular principal identity and a corresponding granted authority. - - - - - Defines the list of mappings between http and https ports for use in redirects - - - - Provides a method to map http ports to https ports when forcing a redirect. - - - - - - - - - - Defines the SecurityExpressionHandler instance which will be used if expression-based access-control is enabled. A default implementation (with no ACL support) will be used if not supplied. - - - - - - + + + Allows a custom instance of HttpFirewall to be injected into the FilterChainProxy created + by the namespace. + + + + + + + + + Container element for HTTP security configuration. Multiple elements can now be defined, + each with a specific pattern to which the enclosed security configuration applies. A + pattern can also be configured to bypass Spring Security's filters completely by setting + the "secured" attribute to "false". + + + + + + + Specifies the access attributes and/or filter list for a particular set of URLs. + + + + + + + + + Defines the access-denied strategy that should be used. An access denied page can be + defined or a reference to an AccessDeniedHandler instance. + + + + + + + + + Sets up a form login configuration for authentication with a username and password + + + + + + + + + Sets up form login for authentication with an Open ID identity + + + + + + + + + + A reference to a user-service (or UserDetailsService bean) Id + + + + + + + + Adds support for X.509 client authentication. + + + + + + + + + + Adds support for basic authentication + + + + + + + + + Incorporates a logout processing filter. Most web applications require a logout filter, + although you may not require one if you write a controller to provider similar logic. + + + + + + + + + Session-management related functionality is implemented by the addition of a + SessionManagementFilter to the filter stack. + + + + + + + Enables concurrent session control, limiting the number of authenticated sessions a user + may have at the same time. + + + + + + + + + + + + + Sets up remember-me authentication. If used with the "key" attribute (or no attributes) + the cookie-only implementation will be used. Specifying "token-repository-ref" or + "remember-me-data-source-ref" will use the more secure, persisten token approach. + + + + + + + + + Adds support for automatically granting all anonymous web requests a particular principal + identity and a corresponding granted authority. + + + + + + + + + Defines the list of mappings between http and https ports for use in redirects + + + + + + + Provides a method to map http ports to https ports when forcing a redirect. + + + + + + + + + + + + + + + Defines the SecurityExpressionHandler instance which will be used if expression-based + access-control is enabled. A default implementation (with no ACL support) will be used if + not supplied. + + + + + + + + + + - - - The request URL pattern which will be mapped to the filter chain created by this <http> element. If omitted, the filter chain will match all requests. - - - - - When set to 'none', requests matching the pattern attribute will be ignored by Spring Security. No security filters will be applied and no SecurityContext will be available. If set, the <http> element must be empty, with no children. - - - - - - - - - - Allows a RequestMatcher instance to be used, as an alternative to pattern-matching. - - - - - Automatically registers a login form, BASIC authentication, anonymous authentication, logout services, remember-me and servlet-api-integration. If set to "true", all of these capabilities are added (although you can still customize the configuration of each by providing the respective element). If unspecified, defaults to "false". - - - - - Enables the use of expressions in the 'access' attributes in <intercept-url> elements rather than the traditional list of configuration attributes. Defaults to 'false'. If enabled, each attribute should contain a single boolean expression. If the expression evaluates to 'true', access will be granted. - - - - - Controls the eagerness with which an HTTP session is created by Spring Security classes. If not set, defaults to "ifRequired". If "stateless" is used, this implies that the application guarantees that it will not create a session. This differs from the use of "never" which mans that Spring Security will not create a session, but will make use of one if the application does. - - - - - - - - - - - - - A reference to a SecurityContextRepository bean. This can be used to customize how the SecurityContext is stored between requests. - - - - - Supersedes the 'path-type' attribute. Defines the strategy use for matching incoming requests. Currently the options are 'ant' (for ant path patterns), 'regex' for regular expressions and 'ciRegex' for case-insensitive regular expressions. - - - - - - - - - - - - Deprecated. Use request-matcher instead. - - - - - - - - - - - Provides versions of HttpServletRequest security methods such as isUserInRole() and getPrincipal() which are implemented by accessing the Spring SecurityContext. Defaults to "true". - - - - - If available, runs the request as the Subject acquired from the JaasAuthenticationToken. Defaults to "false". - - - - - Optional attribute specifying the ID of the AccessDecisionManager implementation which should be used for authorizing HTTP requests. - - - - - Optional attribute specifying the realm name that will be used for all authentication features that require a realm name (eg BASIC and Digest authentication). If unspecified, defaults to "Spring Security Application". - - - - - Allows a customized AuthenticationEntryPoint to be set on the ExceptionTranslationFilter. - - - - - Corresponds to the observeOncePerRequest property of FilterSecurityInterceptor. Defaults to "true" - - - - - Deprecated in favour of the access-denied-handler element. - - - - - Prevents the jsessionid parameter from being added to rendered URLs. - - - - - A bean identifier, used for referring to the bean elsewhere in the context. - - - - - A reference to an AuthenticationManager bean - - + + + The request URL pattern which will be mapped to the filter chain created by this <http> + element. If omitted, the filter chain will match all requests. + + + + + + When set to 'none', requests matching the pattern attribute will be ignored by Spring + Security. No security filters will be applied and no SecurityContext will be available. If + set, the <http> element must be empty, with no children. + + + + + + + + + + + Allows a RequestMatcher instance to be used, as an alternative to pattern-matching. + + + + + + Automatically registers a login form, BASIC authentication, anonymous authentication, + logout services, remember-me and servlet-api-integration. If set to "true", all of these + capabilities are added (although you can still customize the configuration of each by + providing the respective element). If unspecified, defaults to "false". + + + + + + Enables the use of expressions in the 'access' attributes in <intercept-url> elements + rather than the traditional list of configuration attributes. Defaults to 'false'. If + enabled, each attribute should contain a single boolean expression. If the expression + evaluates to 'true', access will be granted. + + + + + + Controls the eagerness with which an HTTP session is created by Spring Security classes. + If not set, defaults to "ifRequired". If "stateless" is used, this implies that the + application guarantees that it will not create a session. This differs from the use of + "never" which mans that Spring Security will not create a session, but will make use of + one if the application does. + + + + + + + + + + + + + + A reference to a SecurityContextRepository bean. This can be used to customize how the + SecurityContext is stored between requests. + + + + + + Supersedes the 'path-type' attribute. Defines the strategy use for matching incoming + requests. Currently the options are 'ant' (for ant path patterns), 'regex' for regular + expressions and 'ciRegex' for case-insensitive regular expressions. + + + + + + + + + + + + + Deprecated. Use request-matcher instead. + + + + + + + + + + + + Provides versions of HttpServletRequest security methods such as isUserInRole() and + getPrincipal() which are implemented by accessing the Spring SecurityContext. Defaults to + "true". + + + + + + If available, runs the request as the Subject acquired from the JaasAuthenticationToken. + Defaults to "false". + + + + + + Optional attribute specifying the ID of the AccessDecisionManager implementation which + should be used for authorizing HTTP requests. + + + + + + Optional attribute specifying the realm name that will be used for all authentication + features that require a realm name (eg BASIC and Digest authentication). If unspecified, + defaults to "Spring Security Application". + + + + + + Allows a customized AuthenticationEntryPoint to be set on the ExceptionTranslationFilter. + + + + + + Corresponds to the observeOncePerRequest property of FilterSecurityInterceptor. Defaults + to "true" + + + + + + Deprecated in favour of the access-denied-handler element. + + + + + + Prevents the jsessionid parameter from being added to rendered URLs. + + + + + + A bean identifier, used for referring to the bean elsewhere in the context. + + + + + + A reference to an AuthenticationManager bean + + + - - - Defines a reference to a Spring bean Id. - - - - - The access denied page that an authenticated user will be redirected to if they request a page which they don't have the authority to access. - - + + + Defines a reference to a Spring bean Id. + + + + + + The access denied page that an authenticated user will be redirected to if they request a + page which they don't have the authority to access. + + + - - - The access denied page that an authenticated user will be redirected to if they request a page which they don't have the authority to access. - - + + + The access denied page that an authenticated user will be redirected to if they request a + page which they don't have the authority to access. + + + - - - The pattern which defines the URL path. The content will depend on the type set in the containing http element, so will default to ant path syntax. - - - - - The access configuration attributes that apply for the configured path. - - - - - The HTTP Method for which the access configuration attributes should apply. If not specified, the attributes will apply to any method. - - - - - - - - - - - - - - - - The filter list for the path. Currently can be set to "none" to remove a path from having any filters applied. The full filter stack (consisting of all filters created by the namespace configuration, and any added using 'custom-filter'), will be applied to any other paths. - - - - - - - - - - Used to specify that a URL must be accessed over http or https, or that there is no preference. The value should be "http", "https" or "any", respectively. - - + + + The pattern which defines the URL path. The content will depend on the type set in the + containing http element, so will default to ant path syntax. + + + + + + The access configuration attributes that apply for the configured path. + + + + + + The HTTP Method for which the access configuration attributes should apply. If not + specified, the attributes will apply to any method. + + + + + + + + + + + + + + + + + The filter list for the path. Currently can be set to "none" to remove a path from having + any filters applied. The full filter stack (consisting of all filters created by the + namespace configuration, and any added using 'custom-filter'), will be applied to any + other paths. + + + + + + + + + + + Used to specify that a URL must be accessed over http or https, or that there is no + preference. The value should be "http", "https" or "any", respectively. + + + - - - Specifies the URL that will cause a logout. Spring Security will initialize a filter that responds to this particular URL. Defaults to /j_spring_security_logout if unspecified. - - - - - Specifies the URL to display once the user has logged out. If not specified, defaults to /. - - - - - Specifies whether a logout also causes HttpSession invalidation, which is generally desirable. If unspecified, defaults to true. - - - - - A reference to a LogoutSuccessHandler implementation which will be used to determine the destination to which the user is taken after logging out. - - - + + + Specifies the URL that will cause a logout. Spring Security will initialize a filter that + responds to this particular URL. Defaults to /j_spring_security_logout if unspecified. + + + + + + Specifies the URL to display once the user has logged out. If not specified, defaults to + /. + + + + + + Specifies whether a logout also causes HttpSession invalidation, which is generally + desirable. If unspecified, defaults to true. + + + + + + A reference to a LogoutSuccessHandler implementation which will be used to determine the + destination to which the user is taken after logging out. + + + + + + A comma-separated list of the names of cookies which should be deleted when the user logs + out + + + + + - A comma-separated list of the names of cookies which should be deleted when the user logs out + Allow the RequestCache used for saving requests during the login process to be set + - - - - Allow the RequestCache used for saving requests during the login process to be set - - - + + + + - - - The URL that the login form is posted to. If unspecified, it defaults to /j_spring_security_check. - - - - - The name of the request parameter which contains the username. Defaults to 'j_username'. - - - - - The name of the request parameter which contains the password. Defaults to 'j_password'. - - - - - The URL that will be redirected to after successful authentication, if the user's previous action could not be resumed. This generally happens if the user visits a login page without having first requested a secured operation that triggers authentication. If unspecified, defaults to the root of the application. - - - - - Whether the user should always be redirected to the default-target-url after login. - - - - - The URL for the login page. If no login URL is specified, Spring Security will automatically create a login URL at /spring_security_login and a corresponding filter to render that login URL when requested. - - - - - The URL for the login failure page. If no login failure URL is specified, Spring Security will automatically create a failure login URL at /spring_security_login?login_error and a corresponding filter to render that login failure URL when requested. - - - - - Reference to an AuthenticationSuccessHandler bean which should be used to handle a successful authentication request. Should not be used in combination with default-target-url (or always-use-default-target-url) as the implementation should always deal with navigation to the subsequent destination - - - - - Reference to an AuthenticationFailureHandler bean which should be used to handle a failed authentication request. Should not be used in combination with authentication-failure-url as the implementation should always deal with navigation to the subsequent destination - - - - - Reference to an AuthenticationDetailsSource which will be used by the authentication filter - - + + + The URL that the login form is posted to. If unspecified, it defaults to + /j_spring_security_check. + + + + + + The name of the request parameter which contains the username. Defaults to 'j_username'. + + + + + + The name of the request parameter which contains the password. Defaults to 'j_password'. + + + + + + The URL that will be redirected to after successful authentication, if the user's previous + action could not be resumed. This generally happens if the user visits a login page + without having first requested a secured operation that triggers authentication. If + unspecified, defaults to the root of the application. + + + + + + Whether the user should always be redirected to the default-target-url after login. + + + + + + The URL for the login page. If no login URL is specified, Spring Security will + automatically create a login URL at /spring_security_login and a corresponding filter to + render that login URL when requested. + + + + + + The URL for the login failure page. If no login failure URL is specified, Spring Security + will automatically create a failure login URL at /spring_security_login?login_error and a + corresponding filter to render that login failure URL when requested. + + + + + + Reference to an AuthenticationSuccessHandler bean which should be used to handle a + successful authentication request. Should not be used in combination with + default-target-url (or always-use-default-target-url) as the implementation should always + deal with navigation to the subsequent destination + + + + + + Reference to an AuthenticationFailureHandler bean which should be used to handle a failed + authentication request. Should not be used in combination with authentication-failure-url + as the implementation should always deal with navigation to the subsequent destination + + + + + + Reference to an AuthenticationDetailsSource which will be used by the authentication + filter + + + - - Sets up an attribute exchange configuration to request specified attributes from the OpenID identity provider. When multiple elements are used, each must have an identifier-attribute attribute. Each configuration will be matched in turn against the supplied login identifier until a match is found. - - - - - - + + + Sets up an attribute exchange configuration to request specified attributes from the + OpenID identity provider. When multiple elements are used, each must have an + identifier-attribute attribute. Each configuration will be matched in turn against the + supplied login identifier until a match is found. + + + + + + + + + - - - A regular expression which will be compared against the claimed identity, when deciding which attribute-exchange configuration to use during authentication. - - + + + A regular expression which will be compared against the claimed identity, when deciding + which attribute-exchange configuration to use during authentication. + + + - - Attributes used when making an OpenID AX Fetch Request - - - - - - - Specifies the name of the attribute that you wish to get back. For example, email. - - - + - Specifies the attribute type. For example, http://axschema.org/contact/email. See your OP's documentation for valid attribute types. + Attributes used when making an OpenID AX Fetch Request + - - - - Specifies if this attribute is required to the OP, but does not error out if the OP does not return the attribute. Default is false. - - - + + + + + + + + Specifies the name of the attribute that you wish to get back. For example, email. + + + + + + Specifies the attribute type. For example, http://axschema.org/contact/email. See your + OP's documentation for valid attribute types. + + + + + + Specifies if this attribute is required to the OP, but does not error out if the OP does + not return the attribute. Default is false. + + + + + + Specifies the number of attributes that you wish to get back. For example, return 3 + emails. The default value is 1. + + + + + - Specifies the number of attributes that you wish to get back. For example, return 3 emails. The default value is 1. + Used to explicitly configure a FilterChainProxy instance with a FilterChainMap + - - - - Used to explicitly configure a FilterChainProxy instance with a FilterChainMap - - - - - - + + + + + + + - - - Deprecated. Use request-matcher instead. - - - - - - - - - + + + Deprecated. Use request-matcher instead. + + + + + + + + + + + + Supersedes the 'path-type' attribute. Defines the strategy use for matching incoming + requests. Currently the options are 'ant' (for ant path patterns), 'regex' for regular + expressions and 'ciRegex' for case-insensitive regular expressions. + + + + + + + + + + + + - Supersedes the 'path-type' attribute. Defines the strategy use for matching incoming requests. Currently the options are 'ant' (for ant path patterns), 'regex' for regular expressions and 'ciRegex' for case-insensitive regular expressions. + Used within to define a specific URL pattern and the list of filters which apply to the + URLs matching that pattern. When multiple filter-chain elements are assembled in a list in + order to configure a FilterChainProxy, the most specific patterns must be placed at the + top of the list, with most general ones at the bottom. + - - - - - - - - - - - Used within to define a specific URL pattern and the list of filters which apply to the URLs matching that pattern. When multiple filter-chain elements are assembled in a list in order to configure a FilterChainProxy, the most specific patterns must be placed at the top of the list, with most general ones at the bottom. - - - + + + + - - - The request URL pattern which will be mapped to the FilterChain. - - - - - Allows a RequestMatcher instance to be used, as an alternative to pattern-matching. - - - - - A comma separated list of bean names that implement Filter that should be processed for this FilterChain. If the value is none, then no Filters will be used for this FilterChain. - - + + + The request URL pattern which will be mapped to the FilterChain. + + + + + + Allows a RequestMatcher instance to be used, as an alternative to pattern-matching. + + + + + + A comma separated list of bean names that implement Filter that should be processed for + this FilterChain. If the value is none, then no Filters will be used for this FilterChain. + + + - - - The request URL pattern which will be mapped to the FilterChain. - - + + + The request URL pattern which will be mapped to the FilterChain. + + + - - - Allows a RequestMatcher instance to be used, as an alternative to pattern-matching. - - - - - Used to explicitly configure a FilterSecurityMetadataSource bean for use with a FilterSecurityInterceptor. Usually only needed if you are configuring a FilterChainProxy explicitly, rather than using the <http> element. The intercept-url elements used should only contain pattern, method and access attributes. Any others will result in a configuration error. - - - - Specifies the access attributes and/or filter list for a particular set of URLs. - - - - - - + + + Allows a RequestMatcher instance to be used, as an alternative to pattern-matching. + + + + + + + Used to explicitly configure a FilterSecurityMetadataSource bean for use with a + FilterSecurityInterceptor. Usually only needed if you are configuring a FilterChainProxy + explicitly, rather than using the <http> element. The intercept-url elements used should + only contain pattern, method and access attributes. Any others will result in a + configuration error. + + + + + + + Specifies the access attributes and/or filter list for a particular set of URLs. + + + + + + + + + + - - - Enables the use of expressions in the 'access' attributes in <intercept-url> elements rather than the traditional list of configuration attributes. Defaults to 'false'. If enabled, each attribute should contain a single boolean expression. If the expression evaluates to 'true', access will be granted. - - - - - A bean identifier, used for referring to the bean elsewhere in the context. - - - - - Compare after forcing to lowercase - - - - - Deprecated. Use request-matcher instead. - - - - - - - - - - - Supersedes the 'path-type' attribute. Defines the strategy use for matching incoming requests. Currently the options are 'ant' (for ant path patterns), 'regex' for regular expressions and 'ciRegex' for case-insensitive regular expressions. - - - - - - - - - - - - Deprecated synonym for filter-security-metadata-source - - - - Specifies the access attributes and/or filter list for a particular set of URLs. - - - - - - + + + Enables the use of expressions in the 'access' attributes in <intercept-url> elements + rather than the traditional list of configuration attributes. Defaults to 'false'. If + enabled, each attribute should contain a single boolean expression. If the expression + evaluates to 'true', access will be granted. + + + + + + A bean identifier, used for referring to the bean elsewhere in the context. + + + + + + Compare after forcing to lowercase + + + + + + Deprecated. Use request-matcher instead. + + + + + + + + + + + + Supersedes the 'path-type' attribute. Defines the strategy use for matching incoming + requests. Currently the options are 'ant' (for ant path patterns), 'regex' for regular + expressions and 'ciRegex' for case-insensitive regular expressions. + + + + + + + + + + + + + + Deprecated synonym for filter-security-metadata-source + + + + + + + Specifies the access attributes and/or filter list for a particular set of URLs. + + + + + + + + + + - - - Sets the AuthenticationEntryPoint which is used by the BasicAuthenticationFilter. - - - - - Reference to an AuthenticationDetailsSource which will be used by the authentication filter - - + + + Sets the AuthenticationEntryPoint which is used by the BasicAuthenticationFilter. + + + + + + Reference to an AuthenticationDetailsSource which will be used by the authentication + filter + + + - - - Indicates whether an existing session should be invalidated when a user authenticates and a new session started. If set to "none" no change will be made. "newSession" will create a new empty session. "migrateSession" will create a new session and copy the session attributes to the new session. Defaults to "migrateSession". - - - - - - - - - - - - The URL to which a user will be redirected if they submit an invalid session indentifier. Typically used to detect session timeouts. - - - - - Allows injection of the SessionAuthenticationStrategy instance used by the SessionManagementFilter - - - - - Defines the URL of the error page which should be shown when the SessionAuthenticationStrategy raises an exception. If not set, an unauthorized (402) error code will be returned to the client. Note that this attribute doesn't apply if the error occurs during a form-based login, where the URL for authentication failure will take precedence. - - + + + Indicates whether an existing session should be invalidated when a user authenticates and + a new session started. If set to "none" no change will be made. "newSession" will create a + new empty session. "migrateSession" will create a new session and copy the session + attributes to the new session. Defaults to "migrateSession". + + + + + + + + + + + + + The URL to which a user will be redirected if they submit an invalid session indentifier. + Typically used to detect session timeouts. + + + + + + Allows injection of the SessionAuthenticationStrategy instance used by the + SessionManagementFilter + + + + + + Defines the URL of the error page which should be shown when the + SessionAuthenticationStrategy raises an exception. If not set, an unauthorized (402) error + code will be returned to the client. Note that this attribute doesn't apply if the error + occurs during a form-based login, where the URL for authentication failure will take + precedence. + + + - - - The maximum number of sessions a single authenticated user can have open at the same time. Defaults to "1". - - - - - The URL a user will be redirected to if they attempt to use a session which has been "expired" because they have logged in again. - - - - - Specifies that an unauthorized error should be reported when a user attempts to login when they already have the maximum configured sessions open. The default behaviour is to expire the original session. If the session-authentication-error-url attribute is set on the session-management URL, the user will be redirected to this URL. - - - - - Allows you to define an alias for the SessionRegistry bean in order to access it in your own configuration. - - - - - Allows you to define an external SessionRegistry bean to be used by the concurrency control setup. - - + + + The maximum number of sessions a single authenticated user can have open at the same time. + Defaults to "1". + + + + + + The URL a user will be redirected to if they attempt to use a session which has been + "expired" because they have logged in again. + + + + + + Specifies that an unauthorized error should be reported when a user attempts to login when + they already have the maximum configured sessions open. The default behaviour is to expire + the original session. If the session-authentication-error-url attribute is set on the + session-management URL, the user will be redirected to this URL. + + + + + + Allows you to define an alias for the SessionRegistry bean in order to access it in your + own configuration. + + + + + + Allows you to define an external SessionRegistry bean to be used by the concurrency + control setup. + + + - - - The "key" used to identify cookies from a specific token-based remember-me application. You should set this to a unique value for your application. - - - - - Reference to a PersistentTokenRepository bean for use with the persistent token remember-me implementation. - - - - - A reference to a DataSource bean - - - - - - A reference to a user-service (or UserDetailsService bean) Id - - - - - Exports the internally defined RememberMeServices as a bean alias, allowing it to be used by other beans in the application context. - - - - - Determines whether the "secure" flag will be set on the remember-me cookie. If set to true, the cookie will only be submitted over HTTPS (recommended). By default, secure cookies will be used if the request is made on a secure connection. - - - - - The period (in seconds) for which the remember-me cookie should be valid. - - - - - Reference to an AuthenticationSuccessHandler bean which should be used to handle a successful remember-me authentication. - - + + + The "key" used to identify cookies from a specific token-based remember-me application. + You should set this to a unique value for your application. + + + + + + Reference to a PersistentTokenRepository bean for use with the persistent token + remember-me implementation. + + + + + + A reference to a DataSource bean + + + + + + + A reference to a user-service (or UserDetailsService bean) Id + + + + + + Exports the internally defined RememberMeServices as a bean alias, allowing it to be used + by other beans in the application context. + + + + + + Determines whether the "secure" flag will be set on the remember-me cookie. If set to + true, the cookie will only be submitted over HTTPS (recommended). By default, secure + cookies will be used if the request is made on a secure connection. + + + + + + The period (in seconds) for which the remember-me cookie should be valid. + + + + + + Reference to an AuthenticationSuccessHandler bean which should be used to handle a + successful remember-me authentication. + + + - - - Reference to a PersistentTokenRepository bean for use with the persistent token remember-me implementation. - - + + + Reference to a PersistentTokenRepository bean for use with the persistent token + remember-me implementation. + + + - - - Allows a custom implementation of RememberMeServices to be used. Note that this implementation should return RememberMeAuthenticationToken instances with the same "key" value as specified in the remember-me element. Alternatively it should register its own AuthenticationProvider. It should also implement the LogoutHandler interface, which will be invoked when a user logs out. Typically the remember-me cookie would be removed on logout. - - + + + Allows a custom implementation of RememberMeServices to be used. Note that this + implementation should return RememberMeAuthenticationToken instances with the same "key" + value as specified in the remember-me element. Alternatively it should register its own + AuthenticationProvider. It should also implement the LogoutHandler interface, which will + be invoked when a user logs out. Typically the remember-me cookie would be removed on + logout. + + + - + - - - The key shared between the provider and filter. This generally does not need to be set. If unset, it will default to "doesNotMatter". - - - - - The username that should be assigned to the anonymous request. This allows the principal to be identified, which may be important for logging and auditing. if unset, defaults to "anonymousUser". - - - - - The granted authority that should be assigned to the anonymous request. Commonly this is used to assign the anonymous request particular roles, which can subsequently be used in authorization decisions. If unset, defaults to "ROLE_ANONYMOUS". - - - - - With the default namespace setup, the anonymous "authentication" facility is automatically enabled. You can disable it using this property. - - + + + The key shared between the provider and filter. This generally does not need to be set. If + unset, it will default to "doesNotMatter". + + + + + + The username that should be assigned to the anonymous request. This allows the principal + to be identified, which may be important for logging and auditing. if unset, defaults to + "anonymousUser". + + + + + + The granted authority that should be assigned to the anonymous request. Commonly this is + used to assign the anonymous request particular roles, which can subsequently be used in + authorization decisions. If unset, defaults to "ROLE_ANONYMOUS". + + + + + + With the default namespace setup, the anonymous "authentication" facility is automatically + enabled. You can disable it using this property. + + + - - - The http port to use. - - + + + The http port to use. + + + - - - The https port to use. - - + + + The https port to use. + + + - - - The regular expression used to obtain the username from the certificate's subject. Defaults to matching on the common name using the pattern "CN=(.*?),". - - - - - A reference to a user-service (or UserDetailsService bean) Id - - - - - Reference to an AuthenticationDetailsSource which will be used by the authentication filter - - + + + The regular expression used to obtain the username from the certificate's subject. + Defaults to matching on the common name using the pattern "CN=(.*?),". + + + + + + A reference to a user-service (or UserDetailsService bean) Id + + + + + + Reference to an AuthenticationDetailsSource which will be used by the authentication + filter + + + - - Adds a J2eePreAuthenticatedProcessingFilter to the filter chain to provide integration with container authentication. - - - - - - - A comma-separate list of roles to look for in the incoming HttpServletRequest. - - - + - A reference to a user-service (or UserDetailsService bean) Id + Adds a J2eePreAuthenticatedProcessingFilter to the filter chain to provide integration + with container authentication. + - - - - Registers the AuthenticationManager instance and allows its list of AuthenticationProviders to be defined. Also allows you to define an alias to allow you to reference the AuthenticationManager in your own beans. - - - - Indicates that the contained user-service should be used as an authentication source. - - - - - element which defines a password encoding strategy. Used by an authentication provider to convert submitted passwords to hashed versions, for example. - - - - Password salting strategy. A system-wide constant or a property from the UserDetails object can be used. - - - - A property of the UserDetails object which will be used as salt by a password encoder. Typically something like "username" might be used. - - - - - A single value that will be used as the salt for a password encoder. - + + + + + + + + A comma-separate list of roles to look for in the incoming HttpServletRequest. + + - - - Defines a reference to a Spring bean Id. - - - - - - - - - - - Sets up an ldap authentication provider - - - - Specifies that an LDAP provider should use an LDAP compare operation of the user's password to authenticate the user - - - - element which defines a password encoding strategy. Used by an authentication provider to convert submitted passwords to hashed versions, for example. - - - - Password salting strategy. A system-wide constant or a property from the UserDetails object can be used. - - - - A property of the UserDetails object which will be used as salt by a password encoder. Typically something like "username" might be used. - - - - - A single value that will be used as the salt for a password encoder. - + + + A reference to a user-service (or UserDetailsService bean) Id + + - - - Defines a reference to a Spring bean Id. - - - - - - - - - - - - - - - + + + + Registers the AuthenticationManager instance and allows its list of + AuthenticationProviders to be defined. Also allows you to define an alias to allow you to + reference the AuthenticationManager in your own beans. + + + + + + + Indicates that the contained user-service should be used as an authentication source. + + + + + + + + element which defines a password encoding strategy. Used by an authentication provider to + convert submitted passwords to hashed versions, for example. + + + + + + + Password salting strategy. A system-wide constant or a property from the UserDetails + object can be used. + + + + + + A property of the UserDetails object which will be used as salt by a password encoder. + Typically something like "username" might be used. + + + + + + A single value that will be used as the salt for a password encoder. + + + + + + Defines a reference to a Spring bean Id. + + + + + + + + + + + + + + + + Sets up an ldap authentication provider + + + + + + + Specifies that an LDAP provider should use an LDAP compare operation of the user's + password to authenticate the user + + + + + + + element which defines a password encoding strategy. Used by an authentication provider to + convert submitted passwords to hashed versions, for example. + + + + + + + Password salting strategy. A system-wide constant or a property from the UserDetails + object can be used. + + + + + + A property of the UserDetails object which will be used as salt by a password encoder. + Typically something like "username" might be used. + + + + + + A single value that will be used as the salt for a password encoder. + + + + + + Defines a reference to a Spring bean Id. + + + + + + + + + + + + + + + + + + + + + - - - A bean identifier, used for referring to the bean elsewhere in the context. - - - - - An alias you wish to use for the AuthenticationManager bean (not required it you are using a specific id) - - - - - If set to true, the AuthenticationManger will attempt to clear any credentials data in the returned Authentication object, once the user has been authenticated. - - + + + A bean identifier, used for referring to the bean elsewhere in the context. + + + + + + An alias you wish to use for the AuthenticationManager bean (not required it you are using + a specific id) + + + + + + If set to true, the AuthenticationManger will attempt to clear any credentials data in the + returned Authentication object, once the user has been authenticated. + + + - - - Defines a reference to a Spring bean Id. - - - - - A reference to a user-service (or UserDetailsService bean) Id - - - - - Creates an in-memory UserDetailsService from a properties file or a list of "user" child elements. Usernames are converted to lower-case internally to allow for case-insensitive lookups, so this should not be used if case-sensitivity is required. - - - - Represents a user in the application. - - - - - - - A bean identifier, used for referring to the bean elsewhere in the context. - + + + Defines a reference to a Spring bean Id. + + - - + + + A reference to a user-service (or UserDetailsService bean) Id + + + + + + + Creates an in-memory UserDetailsService from a properties file or a list of "user" child + elements. Usernames are converted to lower-case internally to allow for case-insensitive + lookups, so this should not be used if case-sensitivity is required. + + + + + + + Represents a user in the application. + + + + + + + + + + A bean identifier, used for referring to the bean elsewhere in the context. + + + + + + - - - The location of a Properties file where each line is in the format of username=password,grantedAuthority[,grantedAuthority][,enabled|disabled] - - + + + The location of a Properties file where each line is in the format of + username=password,grantedAuthority[,grantedAuthority][,enabled|disabled] + + + - - - The username assigned to the user. - - - - - The password assigned to the user. This may be hashed if the corresponding authentication provider supports hashing (remember to set the "hash" attribute of the "user-service" element). This attribute be omitted in the case where the data will not be used for authentication, but only for accessing authorities. If omitted, the namespace will generate a random value, preventing its accidental use for authentication. Cannot be empty. - - - - - One of more authorities granted to the user. Separate authorities with a comma (but no space). For example, "ROLE_USER,ROLE_ADMINISTRATOR" - - - - - Can be set to "true" to mark an account as locked and unusable. - - - - - Can be set to "true" to mark an account as disabled and unusable. - - - - - Causes creation of a JDBC-based UserDetailsService. - - - - A bean identifier, used for referring to the bean elsewhere in the context. - + + + The username assigned to the user. + + - - + + + The password assigned to the user. This may be hashed if the corresponding authentication + provider supports hashing (remember to set the "hash" attribute of the "user-service" + element). This attribute be omitted in the case where the data will not be used for + authentication, but only for accessing authorities. If omitted, the namespace will + generate a random value, preventing its accidental use for authentication. Cannot be + empty. + + + + + + One of more authorities granted to the user. Separate authorities with a comma (but no + space). For example, "ROLE_USER,ROLE_ADMINISTRATOR" + + + + + + Can be set to "true" to mark an account as locked and unusable. + + + + + + Can be set to "true" to mark an account as disabled and unusable. + + + + + + + Causes creation of a JDBC-based UserDetailsService. + + + + + + A bean identifier, used for referring to the bean elsewhere in the context. + + + + + + - - - The bean ID of the DataSource which provides the required tables. - - - - - Defines a reference to a cache for use with a UserDetailsService. - - - - - An SQL statement to query a username, password, and enabled status given a username. Default is "select username,password,enabled from users where username = ?" - - - - - An SQL statement to query for a user's granted authorities given a username. The default is "select username, authority from authorities where username = ?" - - - - - An SQL statement to query user's group authorities given a username. The default is "select g.id, g.group_name, ga.authority from groups g, group_members gm, group_authorities ga where gm.username = ? and g.id = ga.group_id and g.id = gm.group_id" - - - - - A non-empty string prefix that will be added to role strings loaded from persistent storage (e.g. "ROLE_"). Use the value "none" for no prefix in cases where the default is non-empty. - - + + + The bean ID of the DataSource which provides the required tables. + + + + + + Defines a reference to a cache for use with a UserDetailsService. + + + + + + An SQL statement to query a username, password, and enabled status given a username. + Default is "select username,password,enabled from users where username = ?" + + + + + + An SQL statement to query for a user's granted authorities given a username. The default + is "select username, authority from authorities where username = ?" + + + + + + An SQL statement to query user's group authorities given a username. The default is + "select g.id, g.group_name, ga.authority from groups g, group_members gm, + group_authorities ga where gm.username = ? and g.id = ga.group_id and g.id = gm.group_id" + + + + + + A non-empty string prefix that will be added to role strings loaded from persistent + storage (e.g. "ROLE_"). Use the value "none" for no prefix in cases where the default is + non-empty. + + + - - Used to indicate that a filter bean declaration should be incorporated into the security filter chain. - - - - - - + - The filter immediately after which the custom-filter should be placed in the chain. This feature will only be needed by advanced users who wish to mix their own filters into the security filter chain and have some knowledge of the standard Spring Security filters. The filter names map to specific Spring Security implementation filters. + Used to indicate that a filter bean declaration should be incorporated into the security + filter chain. + - - - - The filter immediately before which the custom-filter should be placed in the chain - - - - - The explicit position at which the custom-filter should be placed in the chain. Use if you are replacing a standard filter. - - + + + + + + + + + The filter immediately after which the custom-filter should be placed in the chain. This + feature will only be needed by advanced users who wish to mix their own filters into the + security filter chain and have some knowledge of the standard Spring Security filters. The + filter names map to specific Spring Security implementation filters. + + + + + + The filter immediately before which the custom-filter should be placed in the chain + + + + + + The explicit position at which the custom-filter should be placed in the chain. Use if you + are replacing a standard filter. + + + - - - The filter immediately after which the custom-filter should be placed in the chain. This feature will only be needed by advanced users who wish to mix their own filters into the security filter chain and have some knowledge of the standard Spring Security filters. The filter names map to specific Spring Security implementation filters. - - + + + The filter immediately after which the custom-filter should be placed in the chain. This + feature will only be needed by advanced users who wish to mix their own filters into the + security filter chain and have some knowledge of the standard Spring Security filters. The + filter names map to specific Spring Security implementation filters. + + + - - - The filter immediately before which the custom-filter should be placed in the chain - - + + + The filter immediately before which the custom-filter should be placed in the chain + + + - - - The explicit position at which the custom-filter should be placed in the chain. Use if you are replacing a standard filter. - - + + + The explicit position at which the custom-filter should be placed in the chain. Use if you + are replacing a standard filter. + + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - + \ No newline at end of file diff --git a/config/src/main/resources/org/springframework/security/config/spring-security.xsl b/config/src/main/resources/org/springframework/security/config/spring-security.xsl index 5f2d6581701..46b9e89acc0 100644 --- a/config/src/main/resources/org/springframework/security/config/spring-security.xsl +++ b/config/src/main/resources/org/springframework/security/config/spring-security.xsl @@ -5,8 +5,8 @@ --> - - + + ,access-denied-handler,anonymous,session-management,concurrency-control,after-invocation-provider,authentication-provider,ldap-authentication-provider,user,port-mapping,openid-login,expression-handler,form-login,http-basic,intercept-url,logout,password-encoder,port-mappings,port-mapper,password-compare,protect,protect-pointcut,pre-post-annotation-handling,pre-invocation-advice,post-invocation-advice,invocation-attribute-factory,remember-me,salt-source,x509,add-headers, @@ -42,4 +42,10 @@ + + + + + + From 8f1ad62e2f56058a3fd0be65f975ed3380378779 Mon Sep 17 00:00:00 2001 From: Rob Winch Date: Thu, 3 Jan 2013 17:06:03 -0600 Subject: [PATCH 06/11] Add spring-security-3.2.rnc --- .../security/config/spring-security-3.2.rnc | 40 +- .../security/config/spring-security-3.2.xsd | 3694 ++++++++++------- 2 files changed, 2142 insertions(+), 1592 deletions(-) diff --git a/config/src/main/resources/org/springframework/security/config/spring-security-3.2.rnc b/config/src/main/resources/org/springframework/security/config/spring-security-3.2.rnc index b2d810c9476..0003313513d 100644 --- a/config/src/main/resources/org/springframework/security/config/spring-security-3.2.rnc +++ b/config/src/main/resources/org/springframework/security/config/spring-security-3.2.rnc @@ -281,7 +281,7 @@ http-firewall = http = ## Container element for HTTP security configuration. Multiple elements can now be defined, each with a specific pattern to which the enclosed security configuration applies. A pattern can also be configured to bypass Spring Security's filters completely by setting the "secured" attribute to "false". - element http {http.attlist, (intercept-url* & access-denied-handler? & form-login? & openid-login? & x509? & jee? & http-basic? & logout? & session-management & remember-me? & anonymous? & port-mappings & custom-filter* & request-cache? & expression-handler? & add-headers?) } + element http {http.attlist, (intercept-url* & access-denied-handler? & form-login? & openid-login? & x509? & jee? & http-basic? & logout? & session-management & remember-me? & anonymous? & port-mappings & custom-filter* & request-cache? & expression-handler?) } http.attlist &= ## The request URL pattern which will be mapped to the filter chain created by this element. If omitted, the filter chain will match all requests. attribute pattern {xsd:token}? @@ -716,44 +716,6 @@ jdbc-user-service.attlist &= jdbc-user-service.attlist &= role-prefix? -headers = - ## Element for configuration of the HeadersFilter. Enables easy setting for the X-Frame-Options, X-XSS-Protection and X-Content-Type-Options headers. - element headers {xss-protection? & frame-options? & content-type-options? & header*} - -frame-options = - ## Enable basic clickjacking support for newer browsers (IE8+), will set the X-Frame-Options header. - element frame-options {frame-options.attlist, empty} -frame-options.attlist &= - ## Specify the policy to use for the X-Frame-Options-Header. - attribute policy {"DENY","SAMEORIGIN","ALLOW-FROM"}? -frame-options.attlist &= - ## Specify the origin to use when ALLOW-FROM is chosen. - attribute origin {xsd:token}? - -xss-protection = - ## Enable basic XSS browser protection, supported by newer browsers (IE8+), will set the X-XSS-Protection header. - element xss-protection {xss-protection.attlist, empty} -xss-protection.attlist &= - ## enable or disable the X-XSS-Protection header. Default is 'true' meaning it is enabled. - attribute enabled {xsd:boolean}? -xss-protection.attlist &= - ## Add mode=block to the header or not, default is on. - [ a:defaultValue = "true" ] - attribute block {xsd:boolean}? - -content-type-options = - ## Add a X-Content-Type-Options header to the resopnse. Value is always 'nosniff'. - element content-type-options {empty} - -header= - ## Add additional headers to the response. - element header {header.attlist, empty} -header.attlist &= - ## The name of the header to add. - attribute name {xsd:token} -header.attlist &= - ## The value for the header. - attribute value {xsd:token} any-user-service = user-service | jdbc-user-service | ldap-user-service diff --git a/config/src/main/resources/org/springframework/security/config/spring-security-3.2.xsd b/config/src/main/resources/org/springframework/security/config/spring-security-3.2.xsd index e6ec3ecdd09..2485e4eeb75 100644 --- a/config/src/main/resources/org/springframework/security/config/spring-security-3.2.xsd +++ b/config/src/main/resources/org/springframework/security/config/spring-security-3.2.xsd @@ -1,611 +1,834 @@ - - + + - - - Defines the hashing algorithm used on user passwords. We recommend strongly against using MD4, as it is a very weak hashing algorithm. - - - - - - - - - - - - - + + + Defines the hashing algorithm used on user passwords. We recommend strongly against using + MD4, as it is a very weak hashing algorithm. + + + + + + + + + + + + + + - - - Whether a string should be base64 encoded - - + + + Whether a string should be base64 encoded + + + - - - Supersedes the 'path-type' attribute. Defines the strategy use for matching incoming requests. Currently the options are 'ant' (for ant path patterns), 'regex' for regular expressions and 'ciRegex' for case-insensitive regular expressions. - - - - - - - - - + + + Supersedes the 'path-type' attribute. Defines the strategy use for matching incoming + requests. Currently the options are 'ant' (for ant path patterns), 'regex' for regular + expressions and 'ciRegex' for case-insensitive regular expressions. + + + + + + + + + + - - - Deprecated. Use request-matcher instead. - - - - - - - - + + + Deprecated. Use request-matcher instead. + + + + + + + + + - - - Specifies an IP port number. Used to configure an embedded LDAP server, for example. - - + + + Specifies an IP port number. Used to configure an embedded LDAP server, for example. + + + - - - Specifies a URL. - - + + + Specifies a URL. + + + - - - A bean identifier, used for referring to the bean elsewhere in the context. - - + + + A bean identifier, used for referring to the bean elsewhere in the context. + + + - - - A bean identifier, used for referring to the bean elsewhere in the context. - - + + + A bean identifier, used for referring to the bean elsewhere in the context. + + + - - - Defines a reference to a Spring bean Id. - - + + + Defines a reference to a Spring bean Id. + + + - - - Defines a reference to a cache for use with a UserDetailsService. - - + + + Defines a reference to a cache for use with a UserDetailsService. + + + - - - A reference to a user-service (or UserDetailsService bean) Id - - + + + A reference to a user-service (or UserDetailsService bean) Id + + + - - - A reference to an AuthenticationManager bean - - + + + A reference to an AuthenticationManager bean + + + - + + + A reference to a DataSource bean + + + + + - A reference to a DataSource bean + Enables Spring Security debugging infrastructure. This will provide human-readable + (multi-line) debugging information to monitor requests coming into the security filters. + This may include sensitive information, such as request parameters or headers, and should + only be used in a development environment. + - - - - Enables Spring Security debugging infrastructure. This will provide human-readable (multi-line) debugging information to monitor requests coming into the security filters. This may include sensitive information, such as request parameters or headers, and should only be used in a development environment. - + + - - - Defines a reference to a Spring bean Id. - - - - - Defines the hashing algorithm used on user passwords. We recommend strongly against using MD4, as it is a very weak hashing algorithm. - - - - - - - - - - - - - - - - Whether a string should be base64 encoded - - + + + Defines a reference to a Spring bean Id. + + + + + + Defines the hashing algorithm used on user passwords. We recommend strongly against using + MD4, as it is a very weak hashing algorithm. + + + + + + + + + + + + + + + + + Whether a string should be base64 encoded + + + - - - A property of the UserDetails object which will be used as salt by a password encoder. Typically something like "username" might be used. - - + + + A property of the UserDetails object which will be used as salt by a password encoder. + Typically something like "username" might be used. + + + - - - A single value that will be used as the salt for a password encoder. - - + + + A single value that will be used as the salt for a password encoder. + + + - - - A non-empty string prefix that will be added to role strings loaded from persistent storage (e.g. "ROLE_"). Use the value "none" for no prefix in cases where the default is non-empty. - - + + + A non-empty string prefix that will be added to role strings loaded from persistent + storage (e.g. "ROLE_"). Use the value "none" for no prefix in cases where the default is + non-empty. + + + - - - Enables the use of expressions in the 'access' attributes in <intercept-url> elements rather than the traditional list of configuration attributes. Defaults to 'false'. If enabled, each attribute should contain a single boolean expression. If the expression evaluates to 'true', access will be granted. - - + + + Enables the use of expressions in the 'access' attributes in <intercept-url> elements + rather than the traditional list of configuration attributes. Defaults to 'false'. If + enabled, each attribute should contain a single boolean expression. If the expression + evaluates to 'true', access will be granted. + + + - - Defines an LDAP server location or starts an embedded server. The url indicates the location of a remote server. If no url is given, an embedded server will be started, listening on the supplied port number. The port is optional and defaults to 33389. A Spring LDAP ContextSource bean will be registered for the server with the id supplied. - - - - - - - A bean identifier, used for referring to the bean elsewhere in the context. - - - + - Specifies a URL. + Defines an LDAP server location or starts an embedded server. The url indicates the + location of a remote server. If no url is given, an embedded server will be started, + listening on the supplied port number. The port is optional and defaults to 33389. A + Spring LDAP ContextSource bean will be registered for the server with the id supplied. + - - - - Specifies an IP port number. Used to configure an embedded LDAP server, for example. - - - - - Username (DN) of the "manager" user identity which will be used to authenticate to a (non-embedded) LDAP server. If omitted, anonymous access will be used. - - - - - The password for the manager DN. This is required if the manager-dn is specified. - - - - - Explicitly specifies an ldif file resource to load into an embedded LDAP server. The default is classpath*:*.ldiff - - - - - Optional root suffix for the embedded LDAP server. Default is "dc=springframework,dc=org" - - + + + + + + + + A bean identifier, used for referring to the bean elsewhere in the context. + + + + + + Specifies a URL. + + + + + + Specifies an IP port number. Used to configure an embedded LDAP server, for example. + + + + + + Username (DN) of the "manager" user identity which will be used to authenticate to a + (non-embedded) LDAP server. If omitted, anonymous access will be used. + + + + + + The password for the manager DN. This is required if the manager-dn is specified. + + + + + + Explicitly specifies an ldif file resource to load into an embedded LDAP server. The + default is classpath*:*.ldiff + + + + + + Optional root suffix for the embedded LDAP server. Default is "dc=springframework,dc=org" + + + - - - The optional server to use. If omitted, and a default LDAP server is registered (using <ldap-server> with no Id), that server will be used. - - + + + The optional server to use. If omitted, and a default LDAP server is registered (using + <ldap-server> with no Id), that server will be used. + + + - - - Group search filter. Defaults to (uniqueMember={0}). The substituted parameter is the DN of the user. - - + + + Group search filter. Defaults to (uniqueMember={0}). The substituted parameter is the DN + of the user. + + + - - - Search base for group membership searches. Defaults to "" (searching from the root). - - + + + Search base for group membership searches. Defaults to "" (searching from the root). + + + - - - The LDAP filter used to search for users (optional). For example "(uid={0})". The substituted parameter is the user's login name. - - + + + The LDAP filter used to search for users (optional). For example "(uid={0})". The + substituted parameter is the user's login name. + + + - - - Search base for user searches. Defaults to "". Only used with a 'user-search-filter'. - - + + + Search base for user searches. Defaults to "". Only used with a 'user-search-filter'. + + + - - - The LDAP attribute name which contains the role name which will be used within Spring Security. Defaults to "cn". - - + + + The LDAP attribute name which contains the role name which will be used within Spring + Security. Defaults to "cn". + + + - - - Allows the objectClass of the user entry to be specified. If set, the framework will attempt to load standard attributes for the defined class into the returned UserDetails object - - - - - - - - + + + Allows the objectClass of the user entry to be specified. If set, the framework will + attempt to load standard attributes for the defined class into the returned UserDetails + object + + + + + + + + + - - - Allows explicit customization of the loaded user object by specifying a UserDetailsContextMapper bean which will be called with the context information from the user's directory entry - - + + + Allows explicit customization of the loaded user object by specifying a + UserDetailsContextMapper bean which will be called with the context information from the + user's directory entry + + + - - This element configures a LdapUserDetailsService which is a combination of a FilterBasedLdapUserSearch and a DefaultLdapAuthoritiesPopulator. - - - - - - - A bean identifier, used for referring to the bean elsewhere in the context. - - - - - The optional server to use. If omitted, and a default LDAP server is registered (using <ldap-server> with no Id), that server will be used. - - - - - The LDAP filter used to search for users (optional). For example "(uid={0})". The substituted parameter is the user's login name. - - - - - Search base for user searches. Defaults to "". Only used with a 'user-search-filter'. - - - - - Group search filter. Defaults to (uniqueMember={0}). The substituted parameter is the DN of the user. - - - - - Search base for group membership searches. Defaults to "" (searching from the root). - - - - - The LDAP attribute name which contains the role name which will be used within Spring Security. Defaults to "cn". - - - - - Defines a reference to a cache for use with a UserDetailsService. - - - - - A non-empty string prefix that will be added to role strings loaded from persistent storage (e.g. "ROLE_"). Use the value "none" for no prefix in cases where the default is non-empty. - - - - - Allows the objectClass of the user entry to be specified. If set, the framework will attempt to load standard attributes for the defined class into the returned UserDetails object - - - - - - - - - + - Allows explicit customization of the loaded user object by specifying a UserDetailsContextMapper bean which will be called with the context information from the user's directory entry + This element configures a LdapUserDetailsService which is a combination of a + FilterBasedLdapUserSearch and a DefaultLdapAuthoritiesPopulator. + - + + + + + + + + A bean identifier, used for referring to the bean elsewhere in the context. + + + + + + The optional server to use. If omitted, and a default LDAP server is registered (using + <ldap-server> with no Id), that server will be used. + + + + + + The LDAP filter used to search for users (optional). For example "(uid={0})". The + substituted parameter is the user's login name. + + + + + + Search base for user searches. Defaults to "". Only used with a 'user-search-filter'. + + + + + + Group search filter. Defaults to (uniqueMember={0}). The substituted parameter is the DN + of the user. + + + + + + Search base for group membership searches. Defaults to "" (searching from the root). + + + + + + The LDAP attribute name which contains the role name which will be used within Spring + Security. Defaults to "cn". + + + + + + Defines a reference to a cache for use with a UserDetailsService. + + + + + + A non-empty string prefix that will be added to role strings loaded from persistent + storage (e.g. "ROLE_"). Use the value "none" for no prefix in cases where the default is + non-empty. + + + + + + Allows the objectClass of the user entry to be specified. If set, the framework will + attempt to load standard attributes for the defined class into the returned UserDetails + object + + + + + + + + + + + + Allows explicit customization of the loaded user object by specifying a + UserDetailsContextMapper bean which will be called with the context information from the + user's directory entry + + + - - - The optional server to use. If omitted, and a default LDAP server is registered (using <ldap-server> with no Id), that server will be used. - - - - - Search base for user searches. Defaults to "". Only used with a 'user-search-filter'. - - - - - The LDAP filter used to search for users (optional). For example "(uid={0})". The substituted parameter is the user's login name. - - - - - Search base for group membership searches. Defaults to "" (searching from the root). - - - - - Group search filter. Defaults to (uniqueMember={0}). The substituted parameter is the DN of the user. - - - - - The LDAP attribute name which contains the role name which will be used within Spring Security. Defaults to "cn". - - - - - A specific pattern used to build the user's DN, for example "uid={0},ou=people". The key "{0}" must be present and will be substituted with the username. - - - - - A non-empty string prefix that will be added to role strings loaded from persistent storage (e.g. "ROLE_"). Use the value "none" for no prefix in cases where the default is non-empty. - - - - - Allows the objectClass of the user entry to be specified. If set, the framework will attempt to load standard attributes for the defined class into the returned UserDetails object - - - - - - - - - - - Allows explicit customization of the loaded user object by specifying a UserDetailsContextMapper bean which will be called with the context information from the user's directory entry - - + + + The optional server to use. If omitted, and a default LDAP server is registered (using + <ldap-server> with no Id), that server will be used. + + + + + + Search base for user searches. Defaults to "". Only used with a 'user-search-filter'. + + + + + + The LDAP filter used to search for users (optional). For example "(uid={0})". The + substituted parameter is the user's login name. + + + + + + Search base for group membership searches. Defaults to "" (searching from the root). + + + + + + Group search filter. Defaults to (uniqueMember={0}). The substituted parameter is the DN + of the user. + + + + + + The LDAP attribute name which contains the role name which will be used within Spring + Security. Defaults to "cn". + + + + + + A specific pattern used to build the user's DN, for example "uid={0},ou=people". The key + "{0}" must be present and will be substituted with the username. + + + + + + A non-empty string prefix that will be added to role strings loaded from persistent + storage (e.g. "ROLE_"). Use the value "none" for no prefix in cases where the default is + non-empty. + + + + + + Allows the objectClass of the user entry to be specified. If set, the framework will + attempt to load standard attributes for the defined class into the returned UserDetails + object + + + + + + + + + + + + Allows explicit customization of the loaded user object by specifying a + UserDetailsContextMapper bean which will be called with the context information from the + user's directory entry + + + - - - The attribute in the directory which contains the user password. Defaults to "userPassword". - - - - - Defines the hashing algorithm used on user passwords. We recommend strongly against using MD4, as it is a very weak hashing algorithm. - - - - - - - - - - - - - - - - Can be used inside a bean definition to add a security interceptor to the bean and set up access configuration attributes for the bean's methods - - - - Defines a protected method and the access control configuration attributes that apply to it. We strongly advise you NOT to mix "protect" declarations with any services provided "global-method-security". - - - - - - + + + The attribute in the directory which contains the user password. Defaults to + "userPassword". + + + + + + Defines the hashing algorithm used on user passwords. We recommend strongly against using + MD4, as it is a very weak hashing algorithm. + + + + + + + + + + + + + + + + + + Can be used inside a bean definition to add a security interceptor to the bean and set up + access configuration attributes for the bean's methods + + + + + + + Defines a protected method and the access control configuration attributes that apply to + it. We strongly advise you NOT to mix "protect" declarations with any services provided + "global-method-security". + + + + + + + + + + - - - Optional AccessDecisionManager bean ID to be used by the created method security interceptor. - - + + + Optional AccessDecisionManager bean ID to be used by the created method security + interceptor. + + + - - - A method name - - - - - Access configuration attributes list that applies to the method, e.g. "ROLE_A,ROLE_B". - - - - - Creates a MethodSecurityMetadataSource instance - - - - Defines a protected method and the access control configuration attributes that apply to it. We strongly advise you NOT to mix "protect" declarations with any services provided "global-method-security". - - - - - - + + + A method name + + + + + + Access configuration attributes list that applies to the method, e.g. "ROLE_A,ROLE_B". + + + + + + + Creates a MethodSecurityMetadataSource instance + + + + + + + Defines a protected method and the access control configuration attributes that apply to + it. We strongly advise you NOT to mix "protect" declarations with any services provided + "global-method-security". + + + + + + + + + + - - - A bean identifier, used for referring to the bean elsewhere in the context. - - - - - Enables the use of expressions in the 'access' attributes in <intercept-url> elements rather than the traditional list of configuration attributes. Defaults to 'false'. If enabled, each attribute should contain a single boolean expression. If the expression evaluates to 'true', access will be granted. - - - - - Provides method security for all beans registered in the Spring application context. Specifically, beans will be scanned for matches with the ordered list of "protect-pointcut" sub-elements, Spring Security annotations and/or. Where there is a match, the beans will automatically be proxied and security authorization applied to the methods accordingly. If you use and enable all four sources of method security metadata (ie "protect-pointcut" declarations, expression annotations, @Secured and also JSR250 security annotations), the metadata sources will be queried in that order. In practical terms, this enables you to use XML to override method security metadata expressed in annotations. If using annotations, the order of precedence is EL-based (@PreAuthorize etc.), @Secured and finally JSR-250. - - - - - Allows the default expression-based mechanism for handling Spring Security's pre and post invocation annotations (@PreFilter, @PreAuthorize, @PostFilter, @PostAuthorize) to be replace entirely. Only applies if these annotations are enabled. - - - - Defines the PrePostInvocationAttributeFactory instance which is used to generate pre and post invocation metadata from the annotated methods. - - - - - Customizes the PreInvocationAuthorizationAdviceVoter with the ref as the PreInvocationAuthorizationAdviceVoter for the <pre-post-annotation-handling> element. - - - - - Customizes the PostInvocationAdviceProvider with the ref as the PostInvocationAuthorizationAdvice for the <pre-post-annotation-handling> element. - - - - - - - Defines the SecurityExpressionHandler instance which will be used if expression-based access-control is enabled. A default implementation (with no ACL support) will be used if not supplied. - - - - - - Defines a protected pointcut and the access control configuration attributes that apply to it. Every bean registered in the Spring application context that provides a method that matches the pointcut will receive security authorization. - - - - - Allows addition of extra AfterInvocationProvider beans which should be called by the MethodSecurityInterceptor created by global-method-security. - - - - - - + + + A bean identifier, used for referring to the bean elsewhere in the context. + + + + + + Enables the use of expressions in the 'access' attributes in <intercept-url> elements + rather than the traditional list of configuration attributes. Defaults to 'false'. If + enabled, each attribute should contain a single boolean expression. If the expression + evaluates to 'true', access will be granted. + + + + + + + Provides method security for all beans registered in the Spring application context. + Specifically, beans will be scanned for matches with the ordered list of + "protect-pointcut" sub-elements, Spring Security annotations and/or. Where there is a + match, the beans will automatically be proxied and security authorization applied to the + methods accordingly. If you use and enable all four sources of method security metadata + (ie "protect-pointcut" declarations, expression annotations, @Secured and also JSR250 + security annotations), the metadata sources will be queried in that order. In practical + terms, this enables you to use XML to override method security metadata expressed in + annotations. If using annotations, the order of precedence is EL-based (@PreAuthorize + etc.), @Secured and finally JSR-250. + + + + + + + + Allows the default expression-based mechanism for handling Spring Security's pre and post + invocation annotations (@PreFilter, @PreAuthorize, @PostFilter, @PostAuthorize) to be + replace entirely. Only applies if these annotations are enabled. + + + + + + + Defines the PrePostInvocationAttributeFactory instance which is used to generate pre and + post invocation metadata from the annotated methods. + + + + + + + + + Customizes the PreInvocationAuthorizationAdviceVoter with the ref as the + PreInvocationAuthorizationAdviceVoter for the <pre-post-annotation-handling> element. + + + + + + + + + Customizes the PostInvocationAdviceProvider with the ref as the + PostInvocationAuthorizationAdvice for the <pre-post-annotation-handling> element. + + + + + + + + + + + + Defines the SecurityExpressionHandler instance which will be used if expression-based + access-control is enabled. A default implementation (with no ACL support) will be used if + not supplied. + + + + + + + + + + Defines a protected pointcut and the access control configuration attributes that apply to + it. Every bean registered in the Spring application context that provides a method that + matches the pointcut will receive security authorization. + + + + + + + + + Allows addition of extra AfterInvocationProvider beans which should be called by the + MethodSecurityInterceptor created by global-method-security. + + + + + + + + + + - - - Specifies whether the use of Spring Security's pre and post invocation annotations (@PreFilter, @PreAuthorize, @PostFilter, @PostAuthorize) should be enabled for this application context. Defaults to "disabled". - - - - - - - - - - - Specifies whether the use of Spring Security's @Secured annotations should be enabled for this application context. Defaults to "disabled". - - - - - - - - - - - Specifies whether JSR-250 style attributes are to be used (for example "RolesAllowed"). This will require the javax.annotation.security classes on the classpath. Defaults to "disabled". - - - - - - - - - - - Optional AccessDecisionManager bean ID to override the default used for method security. - - - - - Optional RunAsmanager implementation which will be used by the configured MethodSecurityInterceptor - - - - - Allows the advice "order" to be set for the method security interceptor. - - - - - If true, class based proxying will be used instead of interface based proxying. - - - - - Can be used to specify that AspectJ should be used instead of the default Spring AOP. If set, secured classes must be woven with the AnnotationSecurityAspect from the spring-security-aspects module. - - - - - - - - - - An external MethodSecurityMetadataSource instance can be supplied which will take priority over other sources (such as the default annotations). - - - - - A reference to an AuthenticationManager bean - - + + + Specifies whether the use of Spring Security's pre and post invocation annotations + (@PreFilter, @PreAuthorize, @PostFilter, @PostAuthorize) should be enabled for this + application context. Defaults to "disabled". + + + + + + + + + + + + Specifies whether the use of Spring Security's @Secured annotations should be enabled for + this application context. Defaults to "disabled". + + + + + + + + + + + + Specifies whether JSR-250 style attributes are to be used (for example "RolesAllowed"). + This will require the javax.annotation.security classes on the classpath. Defaults to + "disabled". + + + + + + + + + + + + Optional AccessDecisionManager bean ID to override the default used for method security. + + + + + + Optional RunAsmanager implementation which will be used by the configured + MethodSecurityInterceptor + + + + + + Allows the advice "order" to be set for the method security interceptor. + + + + + + If true, class based proxying will be used instead of interface based proxying. + + + + + + Can be used to specify that AspectJ should be used instead of the default Spring AOP. If + set, secured classes must be woven with the AnnotationSecurityAspect from the + spring-security-aspects module. + + + + + + + + + + + An external MethodSecurityMetadataSource instance can be supplied which will take priority + over other sources (such as the default annotations). + + + + + + A reference to an AuthenticationManager bean + + + @@ -615,1112 +838,1477 @@ - - - An AspectJ expression, including the 'execution' keyword. For example, 'execution(int com.foo.TargetObject.countLength(String))' (without the quotes). - - - - - Access configuration attributes list that applies to all methods matching the pointcut, e.g. "ROLE_A,ROLE_B" - - + + + An AspectJ expression, including the 'execution' keyword. For example, 'execution(int + com.foo.TargetObject.countLength(String))' (without the quotes). + + + + + + Access configuration attributes list that applies to all methods matching the pointcut, + e.g. "ROLE_A,ROLE_B" + + + - - Allows a custom instance of HttpFirewall to be injected into the FilterChainProxy created by the namespace. - - - - - Container element for HTTP security configuration. Multiple elements can now be defined, each with a specific pattern to which the enclosed security configuration applies. A pattern can also be configured to bypass Spring Security's filters completely by setting the "secured" attribute to "false". - - - - Specifies the access attributes and/or filter list for a particular set of URLs. - - - - - Defines the access-denied strategy that should be used. An access denied page can be defined or a reference to an AccessDeniedHandler instance. - - - - - Sets up a form login configuration for authentication with a username and password - - - - - Sets up form login for authentication with an Open ID identity - - - - - - - - A reference to a user-service (or UserDetailsService bean) Id - - - - - Adds support for X.509 client authentication. - - - - - - Adds support for basic authentication - - - - - Incorporates a logout processing filter. Most web applications require a logout filter, although you may not require one if you write a controller to provider similar logic. - - - - - Session-management related functionality is implemented by the addition of a SessionManagementFilter to the filter stack. - - - - Enables concurrent session control, limiting the number of authenticated sessions a user may have at the same time. - - - - - - - - Sets up remember-me authentication. If used with the "key" attribute (or no attributes) the cookie-only implementation will be used. Specifying "token-repository-ref" or "remember-me-data-source-ref" will use the more secure, persisten token approach. - - - - - Adds support for automatically granting all anonymous web requests a particular principal identity and a corresponding granted authority. - - - - - Defines the list of mappings between http and https ports for use in redirects - - - - Provides a method to map http ports to https ports when forcing a redirect. - - - - - - - - - - Defines the SecurityExpressionHandler instance which will be used if expression-based access-control is enabled. A default implementation (with no ACL support) will be used if not supplied. - - - - - Element for configuration of the AddHeadersFilter. Enables easy setting for the X-Frame-Options, X-XSS-Protection and X-Content-Type-Options headers. - - - - - - - - - - - + + + Allows a custom instance of HttpFirewall to be injected into the FilterChainProxy created + by the namespace. + + + + + + + + + Container element for HTTP security configuration. Multiple elements can now be defined, + each with a specific pattern to which the enclosed security configuration applies. A + pattern can also be configured to bypass Spring Security's filters completely by setting + the "secured" attribute to "false". + + + + + + + Specifies the access attributes and/or filter list for a particular set of URLs. + + + + + + + + + Defines the access-denied strategy that should be used. An access denied page can be + defined or a reference to an AccessDeniedHandler instance. + + + + + + + + + Sets up a form login configuration for authentication with a username and password + + + + + + + + + Sets up form login for authentication with an Open ID identity + + + + + + + + + + A reference to a user-service (or UserDetailsService bean) Id + + + + + + + + Adds support for X.509 client authentication. + + + + + + + + + + Adds support for basic authentication + + + + + + + + + Incorporates a logout processing filter. Most web applications require a logout filter, + although you may not require one if you write a controller to provider similar logic. + + + + + + + + + Session-management related functionality is implemented by the addition of a + SessionManagementFilter to the filter stack. + + + + + + + Enables concurrent session control, limiting the number of authenticated sessions a user + may have at the same time. + + + + + + + + + + + + + Sets up remember-me authentication. If used with the "key" attribute (or no attributes) + the cookie-only implementation will be used. Specifying "token-repository-ref" or + "remember-me-data-source-ref" will use the more secure, persisten token approach. + + + + + + + + + Adds support for automatically granting all anonymous web requests a particular principal + identity and a corresponding granted authority. + + + + + + + + + Defines the list of mappings between http and https ports for use in redirects + + + + + + + Provides a method to map http ports to https ports when forcing a redirect. + + + + + + + + + + + + + + + Defines the SecurityExpressionHandler instance which will be used if expression-based + access-control is enabled. A default implementation (with no ACL support) will be used if + not supplied. + + + + + + + + + + - - - The request URL pattern which will be mapped to the filter chain created by this <http> element. If omitted, the filter chain will match all requests. - - - - - When set to 'none', requests matching the pattern attribute will be ignored by Spring Security. No security filters will be applied and no SecurityContext will be available. If set, the <http> element must be empty, with no children. - - - - - - - - - - Allows a RequestMatcher instance to be used, as an alternative to pattern-matching. - - - - - Automatically registers a login form, BASIC authentication, anonymous authentication, logout services, remember-me and servlet-api-integration. If set to "true", all of these capabilities are added (although you can still customize the configuration of each by providing the respective element). If unspecified, defaults to "false". - - - - - Enables the use of expressions in the 'access' attributes in <intercept-url> elements rather than the traditional list of configuration attributes. Defaults to 'false'. If enabled, each attribute should contain a single boolean expression. If the expression evaluates to 'true', access will be granted. - - - - - Controls the eagerness with which an HTTP session is created by Spring Security classes. If not set, defaults to "ifRequired". If "stateless" is used, this implies that the application guarantees that it will not create a session. This differs from the use of "never" which mans that Spring Security will not create a session, but will make use of one if the application does. - - - - - - - - - - - - - A reference to a SecurityContextRepository bean. This can be used to customize how the SecurityContext is stored between requests. - - - - - Supersedes the 'path-type' attribute. Defines the strategy use for matching incoming requests. Currently the options are 'ant' (for ant path patterns), 'regex' for regular expressions and 'ciRegex' for case-insensitive regular expressions. - - - - - - - - - - - - Deprecated. Use request-matcher instead. - - - - - - - - - - - Provides versions of HttpServletRequest security methods such as isUserInRole() and getPrincipal() which are implemented by accessing the Spring SecurityContext. Defaults to "true". - - - - - If available, runs the request as the Subject acquired from the JaasAuthenticationToken. Defaults to "false". - - - - - Optional attribute specifying the ID of the AccessDecisionManager implementation which should be used for authorizing HTTP requests. - - - - - Optional attribute specifying the realm name that will be used for all authentication features that require a realm name (eg BASIC and Digest authentication). If unspecified, defaults to "Spring Security Application". - - - - - Allows a customized AuthenticationEntryPoint to be set on the ExceptionTranslationFilter. - - - - - Corresponds to the observeOncePerRequest property of FilterSecurityInterceptor. Defaults to "true" - - - - - Deprecated in favour of the access-denied-handler element. - - - - - Prevents the jsessionid parameter from being added to rendered URLs. - - - - - A bean identifier, used for referring to the bean elsewhere in the context. - - - - - A reference to an AuthenticationManager bean - - + + + The request URL pattern which will be mapped to the filter chain created by this <http> + element. If omitted, the filter chain will match all requests. + + + + + + When set to 'none', requests matching the pattern attribute will be ignored by Spring + Security. No security filters will be applied and no SecurityContext will be available. If + set, the <http> element must be empty, with no children. + + + + + + + + + + + Allows a RequestMatcher instance to be used, as an alternative to pattern-matching. + + + + + + Automatically registers a login form, BASIC authentication, anonymous authentication, + logout services, remember-me and servlet-api-integration. If set to "true", all of these + capabilities are added (although you can still customize the configuration of each by + providing the respective element). If unspecified, defaults to "false". + + + + + + Enables the use of expressions in the 'access' attributes in <intercept-url> elements + rather than the traditional list of configuration attributes. Defaults to 'false'. If + enabled, each attribute should contain a single boolean expression. If the expression + evaluates to 'true', access will be granted. + + + + + + Controls the eagerness with which an HTTP session is created by Spring Security classes. + If not set, defaults to "ifRequired". If "stateless" is used, this implies that the + application guarantees that it will not create a session. This differs from the use of + "never" which mans that Spring Security will not create a session, but will make use of + one if the application does. + + + + + + + + + + + + + + A reference to a SecurityContextRepository bean. This can be used to customize how the + SecurityContext is stored between requests. + + + + + + Supersedes the 'path-type' attribute. Defines the strategy use for matching incoming + requests. Currently the options are 'ant' (for ant path patterns), 'regex' for regular + expressions and 'ciRegex' for case-insensitive regular expressions. + + + + + + + + + + + + + Deprecated. Use request-matcher instead. + + + + + + + + + + + + Provides versions of HttpServletRequest security methods such as isUserInRole() and + getPrincipal() which are implemented by accessing the Spring SecurityContext. Defaults to + "true". + + + + + + If available, runs the request as the Subject acquired from the JaasAuthenticationToken. + Defaults to "false". + + + + + + Optional attribute specifying the ID of the AccessDecisionManager implementation which + should be used for authorizing HTTP requests. + + + + + + Optional attribute specifying the realm name that will be used for all authentication + features that require a realm name (eg BASIC and Digest authentication). If unspecified, + defaults to "Spring Security Application". + + + + + + Allows a customized AuthenticationEntryPoint to be set on the ExceptionTranslationFilter. + + + + + + Corresponds to the observeOncePerRequest property of FilterSecurityInterceptor. Defaults + to "true" + + + + + + Deprecated in favour of the access-denied-handler element. + + + + + + Prevents the jsessionid parameter from being added to rendered URLs. + + + + + + A bean identifier, used for referring to the bean elsewhere in the context. + + + + + + A reference to an AuthenticationManager bean + + + - - - Defines a reference to a Spring bean Id. - - - - - The access denied page that an authenticated user will be redirected to if they request a page which they don't have the authority to access. - - + + + Defines a reference to a Spring bean Id. + + + + + + The access denied page that an authenticated user will be redirected to if they request a + page which they don't have the authority to access. + + + - - - The access denied page that an authenticated user will be redirected to if they request a page which they don't have the authority to access. - - + + + The access denied page that an authenticated user will be redirected to if they request a + page which they don't have the authority to access. + + + - - - The pattern which defines the URL path. The content will depend on the type set in the containing http element, so will default to ant path syntax. - - - - - The access configuration attributes that apply for the configured path. - - - - - The HTTP Method for which the access configuration attributes should apply. If not specified, the attributes will apply to any method. - - - - - - - - - - - - - - - - The filter list for the path. Currently can be set to "none" to remove a path from having any filters applied. The full filter stack (consisting of all filters created by the namespace configuration, and any added using 'custom-filter'), will be applied to any other paths. - - - - - - - - - - Used to specify that a URL must be accessed over http or https, or that there is no preference. The value should be "http", "https" or "any", respectively. - - + + + The pattern which defines the URL path. The content will depend on the type set in the + containing http element, so will default to ant path syntax. + + + + + + The access configuration attributes that apply for the configured path. + + + + + + The HTTP Method for which the access configuration attributes should apply. If not + specified, the attributes will apply to any method. + + + + + + + + + + + + + + + + + The filter list for the path. Currently can be set to "none" to remove a path from having + any filters applied. The full filter stack (consisting of all filters created by the + namespace configuration, and any added using 'custom-filter'), will be applied to any + other paths. + + + + + + + + + + + Used to specify that a URL must be accessed over http or https, or that there is no + preference. The value should be "http", "https" or "any", respectively. + + + - - - Specifies the URL that will cause a logout. Spring Security will initialize a filter that responds to this particular URL. Defaults to /j_spring_security_logout if unspecified. - - - - - Specifies the URL to display once the user has logged out. If not specified, defaults to /. - - - - - Specifies whether a logout also causes HttpSession invalidation, which is generally desirable. If unspecified, defaults to true. - - - - - A reference to a LogoutSuccessHandler implementation which will be used to determine the destination to which the user is taken after logging out. - - - + + + Specifies the URL that will cause a logout. Spring Security will initialize a filter that + responds to this particular URL. Defaults to /j_spring_security_logout if unspecified. + + + + + + Specifies the URL to display once the user has logged out. If not specified, defaults to + /. + + + + + + Specifies whether a logout also causes HttpSession invalidation, which is generally + desirable. If unspecified, defaults to true. + + + + + + A reference to a LogoutSuccessHandler implementation which will be used to determine the + destination to which the user is taken after logging out. + + + + + + A comma-separated list of the names of cookies which should be deleted when the user logs + out + + + + + - A comma-separated list of the names of cookies which should be deleted when the user logs out + Allow the RequestCache used for saving requests during the login process to be set + - - - - Allow the RequestCache used for saving requests during the login process to be set - - - + + + + - - - The URL that the login form is posted to. If unspecified, it defaults to /j_spring_security_check. - - - - - The name of the request parameter which contains the username. Defaults to 'j_username'. - - - - - The name of the request parameter which contains the password. Defaults to 'j_password'. - - - - - The URL that will be redirected to after successful authentication, if the user's previous action could not be resumed. This generally happens if the user visits a login page without having first requested a secured operation that triggers authentication. If unspecified, defaults to the root of the application. - - - - - Whether the user should always be redirected to the default-target-url after login. - - - - - The URL for the login page. If no login URL is specified, Spring Security will automatically create a login URL at /spring_security_login and a corresponding filter to render that login URL when requested. - - - - - The URL for the login failure page. If no login failure URL is specified, Spring Security will automatically create a failure login URL at /spring_security_login?login_error and a corresponding filter to render that login failure URL when requested. - - - - - Reference to an AuthenticationSuccessHandler bean which should be used to handle a successful authentication request. Should not be used in combination with default-target-url (or always-use-default-target-url) as the implementation should always deal with navigation to the subsequent destination - - - - - Reference to an AuthenticationFailureHandler bean which should be used to handle a failed authentication request. Should not be used in combination with authentication-failure-url as the implementation should always deal with navigation to the subsequent destination - - - - - Reference to an AuthenticationDetailsSource which will be used by the authentication filter - - + + + The URL that the login form is posted to. If unspecified, it defaults to + /j_spring_security_check. + + + + + + The name of the request parameter which contains the username. Defaults to 'j_username'. + + + + + + The name of the request parameter which contains the password. Defaults to 'j_password'. + + + + + + The URL that will be redirected to after successful authentication, if the user's previous + action could not be resumed. This generally happens if the user visits a login page + without having first requested a secured operation that triggers authentication. If + unspecified, defaults to the root of the application. + + + + + + Whether the user should always be redirected to the default-target-url after login. + + + + + + The URL for the login page. If no login URL is specified, Spring Security will + automatically create a login URL at /spring_security_login and a corresponding filter to + render that login URL when requested. + + + + + + The URL for the login failure page. If no login failure URL is specified, Spring Security + will automatically create a failure login URL at /spring_security_login?login_error and a + corresponding filter to render that login failure URL when requested. + + + + + + Reference to an AuthenticationSuccessHandler bean which should be used to handle a + successful authentication request. Should not be used in combination with + default-target-url (or always-use-default-target-url) as the implementation should always + deal with navigation to the subsequent destination + + + + + + Reference to an AuthenticationFailureHandler bean which should be used to handle a failed + authentication request. Should not be used in combination with authentication-failure-url + as the implementation should always deal with navigation to the subsequent destination + + + + + + Reference to an AuthenticationDetailsSource which will be used by the authentication + filter + + + - - Sets up an attribute exchange configuration to request specified attributes from the OpenID identity provider. When multiple elements are used, each must have an identifier-attribute attribute. Each configuration will be matched in turn against the supplied login identifier until a match is found. - - - - - - + + + Sets up an attribute exchange configuration to request specified attributes from the + OpenID identity provider. When multiple elements are used, each must have an + identifier-attribute attribute. Each configuration will be matched in turn against the + supplied login identifier until a match is found. + + + + + + + + + - - - A regular expression which will be compared against the claimed identity, when deciding which attribute-exchange configuration to use during authentication. - - + + + A regular expression which will be compared against the claimed identity, when deciding + which attribute-exchange configuration to use during authentication. + + + - - Attributes used when making an OpenID AX Fetch Request - - - - - + - Specifies the name of the attribute that you wish to get back. For example, email. + Attributes used when making an OpenID AX Fetch Request + - - - - Specifies the attribute type. For example, http://axschema.org/contact/email. See your OP's documentation for valid attribute types. - - - - - Specifies if this attribute is required to the OP, but does not error out if the OP does not return the attribute. Default is false. - - - + + + + + + + + Specifies the name of the attribute that you wish to get back. For example, email. + + + + + + Specifies the attribute type. For example, http://axschema.org/contact/email. See your + OP's documentation for valid attribute types. + + + + + + Specifies if this attribute is required to the OP, but does not error out if the OP does + not return the attribute. Default is false. + + + + + + Specifies the number of attributes that you wish to get back. For example, return 3 + emails. The default value is 1. + + + + + - Specifies the number of attributes that you wish to get back. For example, return 3 emails. The default value is 1. + Used to explicitly configure a FilterChainProxy instance with a FilterChainMap + - - - - Used to explicitly configure a FilterChainProxy instance with a FilterChainMap - - - - - - + + + + + + + - - - Deprecated. Use request-matcher instead. - - - - - - - - - + + + Deprecated. Use request-matcher instead. + + + + + + + + + + + + Supersedes the 'path-type' attribute. Defines the strategy use for matching incoming + requests. Currently the options are 'ant' (for ant path patterns), 'regex' for regular + expressions and 'ciRegex' for case-insensitive regular expressions. + + + + + + + + + + + + - Supersedes the 'path-type' attribute. Defines the strategy use for matching incoming requests. Currently the options are 'ant' (for ant path patterns), 'regex' for regular expressions and 'ciRegex' for case-insensitive regular expressions. + Used within to define a specific URL pattern and the list of filters which apply to the + URLs matching that pattern. When multiple filter-chain elements are assembled in a list in + order to configure a FilterChainProxy, the most specific patterns must be placed at the + top of the list, with most general ones at the bottom. + - - - - - - - - - - - Used within to define a specific URL pattern and the list of filters which apply to the URLs matching that pattern. When multiple filter-chain elements are assembled in a list in order to configure a FilterChainProxy, the most specific patterns must be placed at the top of the list, with most general ones at the bottom. - - - + + + + - - - The request URL pattern which will be mapped to the FilterChain. - - - - - Allows a RequestMatcher instance to be used, as an alternative to pattern-matching. - - - - - A comma separated list of bean names that implement Filter that should be processed for this FilterChain. If the value is none, then no Filters will be used for this FilterChain. - - + + + The request URL pattern which will be mapped to the FilterChain. + + + + + + Allows a RequestMatcher instance to be used, as an alternative to pattern-matching. + + + + + + A comma separated list of bean names that implement Filter that should be processed for + this FilterChain. If the value is none, then no Filters will be used for this FilterChain. + + + - - - The request URL pattern which will be mapped to the FilterChain. - - + + + The request URL pattern which will be mapped to the FilterChain. + + + - - - Allows a RequestMatcher instance to be used, as an alternative to pattern-matching. - - - - - Used to explicitly configure a FilterSecurityMetadataSource bean for use with a FilterSecurityInterceptor. Usually only needed if you are configuring a FilterChainProxy explicitly, rather than using the <http> element. The intercept-url elements used should only contain pattern, method and access attributes. Any others will result in a configuration error. - - - - Specifies the access attributes and/or filter list for a particular set of URLs. - - - - - - + + + Allows a RequestMatcher instance to be used, as an alternative to pattern-matching. + + + + + + + Used to explicitly configure a FilterSecurityMetadataSource bean for use with a + FilterSecurityInterceptor. Usually only needed if you are configuring a FilterChainProxy + explicitly, rather than using the <http> element. The intercept-url elements used should + only contain pattern, method and access attributes. Any others will result in a + configuration error. + + + + + + + Specifies the access attributes and/or filter list for a particular set of URLs. + + + + + + + + + + - - - Enables the use of expressions in the 'access' attributes in <intercept-url> elements rather than the traditional list of configuration attributes. Defaults to 'false'. If enabled, each attribute should contain a single boolean expression. If the expression evaluates to 'true', access will be granted. - - - - - A bean identifier, used for referring to the bean elsewhere in the context. - - - - - Compare after forcing to lowercase - - - - - Deprecated. Use request-matcher instead. - - - - - - - - - - - Supersedes the 'path-type' attribute. Defines the strategy use for matching incoming requests. Currently the options are 'ant' (for ant path patterns), 'regex' for regular expressions and 'ciRegex' for case-insensitive regular expressions. - - - - - - - - - - - - Deprecated synonym for filter-security-metadata-source - - - - Specifies the access attributes and/or filter list for a particular set of URLs. - - - - - - + + + Enables the use of expressions in the 'access' attributes in <intercept-url> elements + rather than the traditional list of configuration attributes. Defaults to 'false'. If + enabled, each attribute should contain a single boolean expression. If the expression + evaluates to 'true', access will be granted. + + + + + + A bean identifier, used for referring to the bean elsewhere in the context. + + + + + + Compare after forcing to lowercase + + + + + + Deprecated. Use request-matcher instead. + + + + + + + + + + + + Supersedes the 'path-type' attribute. Defines the strategy use for matching incoming + requests. Currently the options are 'ant' (for ant path patterns), 'regex' for regular + expressions and 'ciRegex' for case-insensitive regular expressions. + + + + + + + + + + + + + + Deprecated synonym for filter-security-metadata-source + + + + + + + Specifies the access attributes and/or filter list for a particular set of URLs. + + + + + + + + + + - - - Sets the AuthenticationEntryPoint which is used by the BasicAuthenticationFilter. - - - - - Reference to an AuthenticationDetailsSource which will be used by the authentication filter - - + + + Sets the AuthenticationEntryPoint which is used by the BasicAuthenticationFilter. + + + + + + Reference to an AuthenticationDetailsSource which will be used by the authentication + filter + + + - - - Indicates whether an existing session should be invalidated when a user authenticates and a new session started. If set to "none" no change will be made. "newSession" will create a new empty session. "migrateSession" will create a new session and copy the session attributes to the new session. Defaults to "migrateSession". - - - - - - - - - - - - The URL to which a user will be redirected if they submit an invalid session indentifier. Typically used to detect session timeouts. - - - - - Allows injection of the SessionAuthenticationStrategy instance used by the SessionManagementFilter - - - - - Defines the URL of the error page which should be shown when the SessionAuthenticationStrategy raises an exception. If not set, an unauthorized (402) error code will be returned to the client. Note that this attribute doesn't apply if the error occurs during a form-based login, where the URL for authentication failure will take precedence. - - + + + Indicates whether an existing session should be invalidated when a user authenticates and + a new session started. If set to "none" no change will be made. "newSession" will create a + new empty session. "migrateSession" will create a new session and copy the session + attributes to the new session. Defaults to "migrateSession". + + + + + + + + + + + + + The URL to which a user will be redirected if they submit an invalid session indentifier. + Typically used to detect session timeouts. + + + + + + Allows injection of the SessionAuthenticationStrategy instance used by the + SessionManagementFilter + + + + + + Defines the URL of the error page which should be shown when the + SessionAuthenticationStrategy raises an exception. If not set, an unauthorized (402) error + code will be returned to the client. Note that this attribute doesn't apply if the error + occurs during a form-based login, where the URL for authentication failure will take + precedence. + + + - - - The maximum number of sessions a single authenticated user can have open at the same time. Defaults to "1". - - - - - The URL a user will be redirected to if they attempt to use a session which has been "expired" because they have logged in again. - - - - - Specifies that an unauthorized error should be reported when a user attempts to login when they already have the maximum configured sessions open. The default behaviour is to expire the original session. If the session-authentication-error-url attribute is set on the session-management URL, the user will be redirected to this URL. - - - - - Allows you to define an alias for the SessionRegistry bean in order to access it in your own configuration. - - - - - Allows you to define an external SessionRegistry bean to be used by the concurrency control setup. - - + + + The maximum number of sessions a single authenticated user can have open at the same time. + Defaults to "1". + + + + + + The URL a user will be redirected to if they attempt to use a session which has been + "expired" because they have logged in again. + + + + + + Specifies that an unauthorized error should be reported when a user attempts to login when + they already have the maximum configured sessions open. The default behaviour is to expire + the original session. If the session-authentication-error-url attribute is set on the + session-management URL, the user will be redirected to this URL. + + + + + + Allows you to define an alias for the SessionRegistry bean in order to access it in your + own configuration. + + + + + + Allows you to define an external SessionRegistry bean to be used by the concurrency + control setup. + + + - - - The "key" used to identify cookies from a specific token-based remember-me application. You should set this to a unique value for your application. - - - - - Reference to a PersistentTokenRepository bean for use with the persistent token remember-me implementation. - - - - - A reference to a DataSource bean - - - - - - A reference to a user-service (or UserDetailsService bean) Id - - - - - Exports the internally defined RememberMeServices as a bean alias, allowing it to be used by other beans in the application context. - - - - - Determines whether the "secure" flag will be set on the remember-me cookie. If set to true, the cookie will only be submitted over HTTPS (recommended). By default, secure cookies will be used if the request is made on a secure connection. - - - - - The period (in seconds) for which the remember-me cookie should be valid. - - - - - Reference to an AuthenticationSuccessHandler bean which should be used to handle a successful remember-me authentication. - - + + + The "key" used to identify cookies from a specific token-based remember-me application. + You should set this to a unique value for your application. + + + + + + Reference to a PersistentTokenRepository bean for use with the persistent token + remember-me implementation. + + + + + + A reference to a DataSource bean + + + + + + + A reference to a user-service (or UserDetailsService bean) Id + + + + + + Exports the internally defined RememberMeServices as a bean alias, allowing it to be used + by other beans in the application context. + + + + + + Determines whether the "secure" flag will be set on the remember-me cookie. If set to + true, the cookie will only be submitted over HTTPS (recommended). By default, secure + cookies will be used if the request is made on a secure connection. + + + + + + The period (in seconds) for which the remember-me cookie should be valid. + + + + + + Reference to an AuthenticationSuccessHandler bean which should be used to handle a + successful remember-me authentication. + + + - - - Reference to a PersistentTokenRepository bean for use with the persistent token remember-me implementation. - - + + + Reference to a PersistentTokenRepository bean for use with the persistent token + remember-me implementation. + + + - - - Allows a custom implementation of RememberMeServices to be used. Note that this implementation should return RememberMeAuthenticationToken instances with the same "key" value as specified in the remember-me element. Alternatively it should register its own AuthenticationProvider. It should also implement the LogoutHandler interface, which will be invoked when a user logs out. Typically the remember-me cookie would be removed on logout. - - + + + Allows a custom implementation of RememberMeServices to be used. Note that this + implementation should return RememberMeAuthenticationToken instances with the same "key" + value as specified in the remember-me element. Alternatively it should register its own + AuthenticationProvider. It should also implement the LogoutHandler interface, which will + be invoked when a user logs out. Typically the remember-me cookie would be removed on + logout. + + + - + - - - The key shared between the provider and filter. This generally does not need to be set. If unset, it will default to "doesNotMatter". - - - - - The username that should be assigned to the anonymous request. This allows the principal to be identified, which may be important for logging and auditing. if unset, defaults to "anonymousUser". - - - - - The granted authority that should be assigned to the anonymous request. Commonly this is used to assign the anonymous request particular roles, which can subsequently be used in authorization decisions. If unset, defaults to "ROLE_ANONYMOUS". - - - - - With the default namespace setup, the anonymous "authentication" facility is automatically enabled. You can disable it using this property. - - + + + The key shared between the provider and filter. This generally does not need to be set. If + unset, it will default to "doesNotMatter". + + + + + + The username that should be assigned to the anonymous request. This allows the principal + to be identified, which may be important for logging and auditing. if unset, defaults to + "anonymousUser". + + + + + + The granted authority that should be assigned to the anonymous request. Commonly this is + used to assign the anonymous request particular roles, which can subsequently be used in + authorization decisions. If unset, defaults to "ROLE_ANONYMOUS". + + + + + + With the default namespace setup, the anonymous "authentication" facility is automatically + enabled. You can disable it using this property. + + + - - - The http port to use. - - + + + The http port to use. + + + - - - The https port to use. - - + + + The https port to use. + + + - - - The regular expression used to obtain the username from the certificate's subject. Defaults to matching on the common name using the pattern "CN=(.*?),". - - - - - A reference to a user-service (or UserDetailsService bean) Id - - - - - Reference to an AuthenticationDetailsSource which will be used by the authentication filter - - + + + The regular expression used to obtain the username from the certificate's subject. + Defaults to matching on the common name using the pattern "CN=(.*?),". + + + + + + A reference to a user-service (or UserDetailsService bean) Id + + + + + + Reference to an AuthenticationDetailsSource which will be used by the authentication + filter + + + - - Adds a J2eePreAuthenticatedProcessingFilter to the filter chain to provide integration with container authentication. - - - - - - - A comma-separate list of roles to look for in the incoming HttpServletRequest. - - - + - A reference to a user-service (or UserDetailsService bean) Id + Adds a J2eePreAuthenticatedProcessingFilter to the filter chain to provide integration + with container authentication. + - - - - Registers the AuthenticationManager instance and allows its list of AuthenticationProviders to be defined. Also allows you to define an alias to allow you to reference the AuthenticationManager in your own beans. - - - - Indicates that the contained user-service should be used as an authentication source. - - - - - element which defines a password encoding strategy. Used by an authentication provider to convert submitted passwords to hashed versions, for example. - - - - Password salting strategy. A system-wide constant or a property from the UserDetails object can be used. - - - - A property of the UserDetails object which will be used as salt by a password encoder. Typically something like "username" might be used. - - - - - A single value that will be used as the salt for a password encoder. - + + + + + + + + A comma-separate list of roles to look for in the incoming HttpServletRequest. + + - - - Defines a reference to a Spring bean Id. - - - - - - - - - - - Sets up an ldap authentication provider - - - - Specifies that an LDAP provider should use an LDAP compare operation of the user's password to authenticate the user - - - - element which defines a password encoding strategy. Used by an authentication provider to convert submitted passwords to hashed versions, for example. - - - - Password salting strategy. A system-wide constant or a property from the UserDetails object can be used. - - - - A property of the UserDetails object which will be used as salt by a password encoder. Typically something like "username" might be used. - - - - - A single value that will be used as the salt for a password encoder. - + + + A reference to a user-service (or UserDetailsService bean) Id + + - - - Defines a reference to a Spring bean Id. - - - - - - - - - - - - - - - + + + + Registers the AuthenticationManager instance and allows its list of + AuthenticationProviders to be defined. Also allows you to define an alias to allow you to + reference the AuthenticationManager in your own beans. + + + + + + + Indicates that the contained user-service should be used as an authentication source. + + + + + + + + element which defines a password encoding strategy. Used by an authentication provider to + convert submitted passwords to hashed versions, for example. + + + + + + + Password salting strategy. A system-wide constant or a property from the UserDetails + object can be used. + + + + + + A property of the UserDetails object which will be used as salt by a password encoder. + Typically something like "username" might be used. + + + + + + A single value that will be used as the salt for a password encoder. + + + + + + Defines a reference to a Spring bean Id. + + + + + + + + + + + + + + + + Sets up an ldap authentication provider + + + + + + + Specifies that an LDAP provider should use an LDAP compare operation of the user's + password to authenticate the user + + + + + + + element which defines a password encoding strategy. Used by an authentication provider to + convert submitted passwords to hashed versions, for example. + + + + + + + Password salting strategy. A system-wide constant or a property from the UserDetails + object can be used. + + + + + + A property of the UserDetails object which will be used as salt by a password encoder. + Typically something like "username" might be used. + + + + + + A single value that will be used as the salt for a password encoder. + + + + + + Defines a reference to a Spring bean Id. + + + + + + + + + + + + + + + + + + + + + - - - A bean identifier, used for referring to the bean elsewhere in the context. - - - - - An alias you wish to use for the AuthenticationManager bean (not required it you are using a specific id) - - - - - If set to true, the AuthenticationManger will attempt to clear any credentials data in the returned Authentication object, once the user has been authenticated. - - + + + A bean identifier, used for referring to the bean elsewhere in the context. + + + + + + An alias you wish to use for the AuthenticationManager bean (not required it you are using + a specific id) + + + + + + If set to true, the AuthenticationManger will attempt to clear any credentials data in the + returned Authentication object, once the user has been authenticated. + + + - - - Defines a reference to a Spring bean Id. - - - - - A reference to a user-service (or UserDetailsService bean) Id - - - - - Creates an in-memory UserDetailsService from a properties file or a list of "user" child elements. Usernames are converted to lower-case internally to allow for case-insensitive lookups, so this should not be used if case-sensitivity is required. - - - - Represents a user in the application. - - - - - - - A bean identifier, used for referring to the bean elsewhere in the context. - + + + Defines a reference to a Spring bean Id. + + - - + + + A reference to a user-service (or UserDetailsService bean) Id + + + + + + + Creates an in-memory UserDetailsService from a properties file or a list of "user" child + elements. Usernames are converted to lower-case internally to allow for case-insensitive + lookups, so this should not be used if case-sensitivity is required. + + + + + + + Represents a user in the application. + + + + + + + + + + A bean identifier, used for referring to the bean elsewhere in the context. + + + + + + - - - The location of a Properties file where each line is in the format of username=password,grantedAuthority[,grantedAuthority][,enabled|disabled] - - + + + The location of a Properties file where each line is in the format of + username=password,grantedAuthority[,grantedAuthority][,enabled|disabled] + + + - - - The username assigned to the user. - - - - - The password assigned to the user. This may be hashed if the corresponding authentication provider supports hashing (remember to set the "hash" attribute of the "user-service" element). This attribute be omitted in the case where the data will not be used for authentication, but only for accessing authorities. If omitted, the namespace will generate a random value, preventing its accidental use for authentication. Cannot be empty. - - - - - One of more authorities granted to the user. Separate authorities with a comma (but no space). For example, "ROLE_USER,ROLE_ADMINISTRATOR" - - - - - Can be set to "true" to mark an account as locked and unusable. - - - - - Can be set to "true" to mark an account as disabled and unusable. - - - - - Causes creation of a JDBC-based UserDetailsService. - - - - A bean identifier, used for referring to the bean elsewhere in the context. - + + + The username assigned to the user. + + + + + + The password assigned to the user. This may be hashed if the corresponding authentication + provider supports hashing (remember to set the "hash" attribute of the "user-service" + element). This attribute be omitted in the case where the data will not be used for + authentication, but only for accessing authorities. If omitted, the namespace will + generate a random value, preventing its accidental use for authentication. Cannot be + empty. + + + + + + One of more authorities granted to the user. Separate authorities with a comma (but no + space). For example, "ROLE_USER,ROLE_ADMINISTRATOR" + + + + + + Can be set to "true" to mark an account as locked and unusable. + + + + + + Can be set to "true" to mark an account as disabled and unusable. + + - - - - - - The bean ID of the DataSource which provides the required tables. - - - - - Defines a reference to a cache for use with a UserDetailsService. - - - - - An SQL statement to query a username, password, and enabled status given a username. Default is "select username,password,enabled from users where username = ?" - - - - - An SQL statement to query for a user's granted authorities given a username. The default is "select username, authority from authorities where username = ?" - - - - - An SQL statement to query user's group authorities given a username. The default is "select g.id, g.group_name, ga.authority from groups g, group_members gm, group_authorities ga where gm.username = ? and g.id = ga.group_id and g.id = gm.group_id" - - - - - A non-empty string prefix that will be added to role strings loaded from persistent storage (e.g. "ROLE_"). Use the value "none" for no prefix in cases where the default is non-empty. - - - - - Enable basic clickjacking support for newer browsers (IE8+), will set the X-Frame-Options header. - - - - - - - Specify the policy to use for the X-Frame-Options-Header. - - - - - - - - - - - - Specify the origin to use when ALLOW-FROM is chosen. - - - - - Enable basic XSS browser protection, supported by newer browsers (IE8+), will set the X-XSS-Protection header. - - - - - - - enable or disable the X-XSS-Protection header. Default is 'true' meaning it is enabled. - - - - - Add mode=block to the header or not, default is on. - - - - - Add a X-Content-Type-Options header to the resopnse. Value is always 'nosniff'. - - - Add additional headers to the response. - - - - - - - The name of the header to add. - - - - - The value for the header. - - + + + Causes creation of a JDBC-based UserDetailsService. + + + + + + A bean identifier, used for referring to the bean elsewhere in the context. + + + + + + + + + + The bean ID of the DataSource which provides the required tables. + + + + + + Defines a reference to a cache for use with a UserDetailsService. + + + + + + An SQL statement to query a username, password, and enabled status given a username. + Default is "select username,password,enabled from users where username = ?" + + + + + + An SQL statement to query for a user's granted authorities given a username. The default + is "select username, authority from authorities where username = ?" + + + + + + An SQL statement to query user's group authorities given a username. The default is + "select g.id, g.group_name, ga.authority from groups g, group_members gm, + group_authorities ga where gm.username = ? and g.id = ga.group_id and g.id = gm.group_id" + + + + + + A non-empty string prefix that will be added to role strings loaded from persistent + storage (e.g. "ROLE_"). Use the value "none" for no prefix in cases where the default is + non-empty. + + + - - Used to indicate that a filter bean declaration should be incorporated into the security filter chain. - - - - - - - - The filter immediately after which the custom-filter should be placed in the chain. This feature will only be needed by advanced users who wish to mix their own filters into the security filter chain and have some knowledge of the standard Spring Security filters. The filter names map to specific Spring Security implementation filters. - - - + - The filter immediately before which the custom-filter should be placed in the chain + Used to indicate that a filter bean declaration should be incorporated into the security + filter chain. + - - - - The explicit position at which the custom-filter should be placed in the chain. Use if you are replacing a standard filter. - - + + + + + + + + + The filter immediately after which the custom-filter should be placed in the chain. This + feature will only be needed by advanced users who wish to mix their own filters into the + security filter chain and have some knowledge of the standard Spring Security filters. The + filter names map to specific Spring Security implementation filters. + + + + + + The filter immediately before which the custom-filter should be placed in the chain + + + + + + The explicit position at which the custom-filter should be placed in the chain. Use if you + are replacing a standard filter. + + + - - - The filter immediately after which the custom-filter should be placed in the chain. This feature will only be needed by advanced users who wish to mix their own filters into the security filter chain and have some knowledge of the standard Spring Security filters. The filter names map to specific Spring Security implementation filters. - - + + + The filter immediately after which the custom-filter should be placed in the chain. This + feature will only be needed by advanced users who wish to mix their own filters into the + security filter chain and have some knowledge of the standard Spring Security filters. The + filter names map to specific Spring Security implementation filters. + + + - - - The filter immediately before which the custom-filter should be placed in the chain - - + + + The filter immediately before which the custom-filter should be placed in the chain + + + - - - The explicit position at which the custom-filter should be placed in the chain. Use if you are replacing a standard filter. - - + + + The explicit position at which the custom-filter should be placed in the chain. Use if you + are replacing a standard filter. + + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - + \ No newline at end of file From 956b35792cd54f238231c81c6e0e6a7d2d350190 Mon Sep 17 00:00:00 2001 From: Marten Deinum Date: Thu, 3 Jan 2013 12:54:39 +0100 Subject: [PATCH 07/11] SEC-2114: Provide Spring Cache Abstraction based cache implementations As of Spring 3.1 spring has its own cache abstraction. This commit adds cache imlpementations based on that abstraction. --- .../acls/domain/SpringCacheBasedAclCache.java | 145 +++++++++++++++ .../jdbc/SpringCacheBasedAclCacheTests.java | 172 ++++++++++++++++++ .../SpringCacheBasedTicketCache.java | 86 +++++++++ .../SpringCacheBasedTicketCacheTests.java | 80 ++++++++ .../cache/SpringCacheBasedUserCache.java | 74 ++++++++ .../cache/SpringCacheBasedUserCacheTests.java | 92 ++++++++++ 6 files changed, 649 insertions(+) create mode 100644 acl/src/main/java/org/springframework/security/acls/domain/SpringCacheBasedAclCache.java create mode 100644 acl/src/test/java/org/springframework/security/acls/jdbc/SpringCacheBasedAclCacheTests.java create mode 100644 cas/src/main/java/org/springframework/security/cas/authentication/SpringCacheBasedTicketCache.java create mode 100644 cas/src/test/java/org/springframework/security/cas/authentication/SpringCacheBasedTicketCacheTests.java create mode 100644 core/src/main/java/org/springframework/security/core/userdetails/cache/SpringCacheBasedUserCache.java create mode 100644 core/src/test/java/org/springframework/security/core/userdetails/cache/SpringCacheBasedUserCacheTests.java diff --git a/acl/src/main/java/org/springframework/security/acls/domain/SpringCacheBasedAclCache.java b/acl/src/main/java/org/springframework/security/acls/domain/SpringCacheBasedAclCache.java new file mode 100644 index 00000000000..87dba1873cd --- /dev/null +++ b/acl/src/main/java/org/springframework/security/acls/domain/SpringCacheBasedAclCache.java @@ -0,0 +1,145 @@ +/* + * Copyright 2002-2013 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.security.acls.domain; + +import net.sf.ehcache.CacheException; +import net.sf.ehcache.Ehcache; +import net.sf.ehcache.Element; +import org.springframework.cache.Cache; +import org.springframework.security.acls.model.AclCache; +import org.springframework.security.acls.model.MutableAcl; +import org.springframework.security.acls.model.ObjectIdentity; +import org.springframework.security.acls.model.PermissionGrantingStrategy; +import org.springframework.security.util.FieldUtils; +import org.springframework.util.Assert; + +import java.io.Serializable; + + +/** + * Simple implementation of {@link org.springframework.security.acls.model.AclCache} that delegates to {@link Cache} implementation. + *

+ * Designed to handle the transient fields in {@link org.springframework.security.acls.domain.AclImpl}. Note that this implementation assumes all + * {@link org.springframework.security.acls.domain.AclImpl} instances share the same {@link org.springframework.security.acls.model.PermissionGrantingStrategy} and {@link org.springframework.security.acls.domain.AclAuthorizationStrategy} + * instances. + * + * @author Marten Deinum + * @since 3.2 + */ +public class SpringCacheBasedAclCache implements AclCache { + //~ Instance fields ================================================================================================ + + private final Cache cache; + private PermissionGrantingStrategy permissionGrantingStrategy; + private AclAuthorizationStrategy aclAuthorizationStrategy; + + //~ Constructors =================================================================================================== + + public SpringCacheBasedAclCache(Cache cache, PermissionGrantingStrategy permissionGrantingStrategy, + AclAuthorizationStrategy aclAuthorizationStrategy) { + Assert.notNull(cache, "Cache required"); + Assert.notNull(permissionGrantingStrategy, "PermissionGrantingStrategy required"); + Assert.notNull(aclAuthorizationStrategy, "AclAuthorizationStrategy required"); + this.cache = cache; + this.permissionGrantingStrategy = permissionGrantingStrategy; + this.aclAuthorizationStrategy = aclAuthorizationStrategy; + } + + //~ Methods ======================================================================================================== + + public void evictFromCache(Serializable pk) { + Assert.notNull(pk, "Primary key (identifier) required"); + + MutableAcl acl = getFromCache(pk); + + if (acl != null) { + cache.evict(acl.getId()); + cache.evict(acl.getObjectIdentity()); + } + } + + public void evictFromCache(ObjectIdentity objectIdentity) { + Assert.notNull(objectIdentity, "ObjectIdentity required"); + + MutableAcl acl = getFromCache(objectIdentity); + + if (acl != null) { + cache.evict(acl.getId()); + cache.evict(acl.getObjectIdentity()); + } + } + + public MutableAcl getFromCache(ObjectIdentity objectIdentity) { + Assert.notNull(objectIdentity, "ObjectIdentity required"); + + Cache.ValueWrapper element = null; + + try { + element = cache.get(objectIdentity); + } catch (CacheException ignored) {} + + if (element == null) { + return null; + } + + return initializeTransientFields((MutableAcl)element.get()); + } + + public MutableAcl getFromCache(Serializable pk) { + Assert.notNull(pk, "Primary key (identifier) required"); + + Cache.ValueWrapper element = null; + + try { + element = cache.get(pk); + } catch (CacheException ignored) {} + + if (element == null) { + return null; + } + + return initializeTransientFields((MutableAcl) element.get()); + } + + public void putInCache(MutableAcl acl) { + Assert.notNull(acl, "Acl required"); + Assert.notNull(acl.getObjectIdentity(), "ObjectIdentity required"); + Assert.notNull(acl.getId(), "ID required"); + + if ((acl.getParentAcl() != null) && (acl.getParentAcl() instanceof MutableAcl)) { + putInCache((MutableAcl) acl.getParentAcl()); + } + + cache.put(acl.getObjectIdentity(), acl); + cache.put(acl.getId(), acl); + } + + private MutableAcl initializeTransientFields(MutableAcl value) { + if (value instanceof AclImpl) { + FieldUtils.setProtectedFieldValue("aclAuthorizationStrategy", value, this.aclAuthorizationStrategy); + FieldUtils.setProtectedFieldValue("permissionGrantingStrategy", value, this.permissionGrantingStrategy); + } + + if (value.getParentAcl() != null) { + initializeTransientFields((MutableAcl) value.getParentAcl()); + } + return value; + } + + public void clearCache() { + cache.clear(); + } +} diff --git a/acl/src/test/java/org/springframework/security/acls/jdbc/SpringCacheBasedAclCacheTests.java b/acl/src/test/java/org/springframework/security/acls/jdbc/SpringCacheBasedAclCacheTests.java new file mode 100644 index 00000000000..05ced8ae67c --- /dev/null +++ b/acl/src/test/java/org/springframework/security/acls/jdbc/SpringCacheBasedAclCacheTests.java @@ -0,0 +1,172 @@ +package org.springframework.security.acls.jdbc; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.springframework.cache.Cache; +import org.springframework.cache.CacheManager; +import org.springframework.cache.concurrent.ConcurrentMapCacheManager; +import org.springframework.security.acls.domain.*; +import org.springframework.security.acls.model.MutableAcl; +import org.springframework.security.acls.model.ObjectIdentity; +import org.springframework.security.acls.model.PermissionGrantingStrategy; +import org.springframework.security.authentication.TestingAuthenticationToken; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.authority.SimpleGrantedAuthority; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.security.util.FieldUtils; + +import java.io.*; +import java.util.Map; + +import static org.junit.Assert.*; + +/** + * Tests {@link org.springframework.security.acls.domain.EhCacheBasedAclCache} + * + * @author Andrei Stefan + */ +public class SpringCacheBasedAclCacheTests { + private static final String TARGET_CLASS = "org.springframework.security.acls.TargetObject"; + + private static CacheManager cacheManager; + + @BeforeClass + public static void initCacheManaer() { + cacheManager = new ConcurrentMapCacheManager(); + // Use disk caching immediately (to test for serialization issue reported in SEC-527) + cacheManager.getCache("springcasebasedacltests"); + } + + @After + public void clearContext() { + SecurityContextHolder.clearContext(); + } + + private Cache getCache() { + Cache cache = cacheManager.getCache("springcasebasedacltests"); + cache.clear(); + return cache; + } + + @Test(expected=IllegalArgumentException.class) + public void constructorRejectsNullParameters() throws Exception { + new SpringCacheBasedAclCache(null, null, null); + } + + @Test + public void cacheOperationsAclWithoutParent() throws Exception { + Cache cache = getCache(); + Map realCache = (Map) cache.getNativeCache(); + ObjectIdentity identity = new ObjectIdentityImpl(TARGET_CLASS, Long.valueOf(100)); + AclAuthorizationStrategy aclAuthorizationStrategy = new AclAuthorizationStrategyImpl( + new SimpleGrantedAuthority("ROLE_OWNERSHIP"), new SimpleGrantedAuthority("ROLE_AUDITING"), + new SimpleGrantedAuthority("ROLE_GENERAL")); + AuditLogger auditLogger = new ConsoleAuditLogger(); + + PermissionGrantingStrategy permissionGrantingStrategy = new DefaultPermissionGrantingStrategy(auditLogger); + SpringCacheBasedAclCache myCache = new SpringCacheBasedAclCache(cache, permissionGrantingStrategy, aclAuthorizationStrategy); + MutableAcl acl = new AclImpl(identity, Long.valueOf(1), aclAuthorizationStrategy, auditLogger); + + assertEquals(0, realCache.size()); + myCache.putInCache(acl); + + // Check we can get from cache the same objects we put in + assertEquals(myCache.getFromCache(Long.valueOf(1)), acl); + assertEquals(myCache.getFromCache(identity), acl); + + // Put another object in cache + ObjectIdentity identity2 = new ObjectIdentityImpl(TARGET_CLASS, Long.valueOf(101)); + MutableAcl acl2 = new AclImpl(identity2, Long.valueOf(2), aclAuthorizationStrategy, new ConsoleAuditLogger()); + + myCache.putInCache(acl2); + + // Try to evict an entry that doesn't exist + myCache.evictFromCache(Long.valueOf(3)); + myCache.evictFromCache(new ObjectIdentityImpl(TARGET_CLASS, Long.valueOf(102))); + assertEquals(realCache.size(), 4); + + myCache.evictFromCache(Long.valueOf(1)); + assertEquals(realCache.size(), 2); + + // Check the second object inserted + assertEquals(myCache.getFromCache(Long.valueOf(2)), acl2); + assertEquals(myCache.getFromCache(identity2), acl2); + + myCache.evictFromCache(identity2); + assertEquals(realCache.size(), 0); + } + + @SuppressWarnings("unchecked") + @Test + public void cacheOperationsAclWithParent() throws Exception { + Cache cache = getCache(); + Map realCache = (Map) cache.getNativeCache(); + + Authentication auth = new TestingAuthenticationToken("user", "password", "ROLE_GENERAL"); + auth.setAuthenticated(true); + SecurityContextHolder.getContext().setAuthentication(auth); + + ObjectIdentity identity = new ObjectIdentityImpl(TARGET_CLASS, Long.valueOf(1)); + ObjectIdentity identityParent = new ObjectIdentityImpl(TARGET_CLASS, Long.valueOf(2)); + AclAuthorizationStrategy aclAuthorizationStrategy = new AclAuthorizationStrategyImpl( + new SimpleGrantedAuthority("ROLE_OWNERSHIP"), new SimpleGrantedAuthority("ROLE_AUDITING"), + new SimpleGrantedAuthority("ROLE_GENERAL")); + AuditLogger auditLogger = new ConsoleAuditLogger(); + + PermissionGrantingStrategy permissionGrantingStrategy = new DefaultPermissionGrantingStrategy(auditLogger); + SpringCacheBasedAclCache myCache = new SpringCacheBasedAclCache(cache, permissionGrantingStrategy, aclAuthorizationStrategy); + + MutableAcl acl = new AclImpl(identity, Long.valueOf(1), aclAuthorizationStrategy, auditLogger); + MutableAcl parentAcl = new AclImpl(identityParent, Long.valueOf(2), aclAuthorizationStrategy, auditLogger); + + acl.setParent(parentAcl); + + assertEquals(0, realCache.size()); + myCache.putInCache(acl); + assertEquals(realCache.size(), 4); + + // Check we can get from cache the same objects we put in + AclImpl aclFromCache = (AclImpl) myCache.getFromCache(Long.valueOf(1)); + assertEquals(acl, aclFromCache); + // SEC-951 check transient fields are set on parent + assertNotNull(FieldUtils.getFieldValue(aclFromCache.getParentAcl(), "aclAuthorizationStrategy")); + assertNotNull(FieldUtils.getFieldValue(aclFromCache.getParentAcl(), "permissionGrantingStrategy")); + assertEquals(acl, myCache.getFromCache(identity)); + assertNotNull(FieldUtils.getFieldValue(aclFromCache, "aclAuthorizationStrategy")); + AclImpl parentAclFromCache = (AclImpl) myCache.getFromCache(Long.valueOf(2)); + assertEquals(parentAcl, parentAclFromCache); + assertNotNull(FieldUtils.getFieldValue(parentAclFromCache, "aclAuthorizationStrategy")); + assertEquals(parentAcl, myCache.getFromCache(identityParent)); + } + + //~ Inner Classes ================================================================================================== + + private class MockCache implements Cache { + + @Override + public String getName() { + return "mockcache"; + } + + @Override + public Object getNativeCache() { + return null; + } + + @Override + public ValueWrapper get(Object key) { + return null; + } + + @Override + public void put(Object key, Object value) {} + + @Override + public void evict(Object key) {} + + @Override + public void clear() {} + } +} diff --git a/cas/src/main/java/org/springframework/security/cas/authentication/SpringCacheBasedTicketCache.java b/cas/src/main/java/org/springframework/security/cas/authentication/SpringCacheBasedTicketCache.java new file mode 100644 index 00000000000..caddb8f89d7 --- /dev/null +++ b/cas/src/main/java/org/springframework/security/cas/authentication/SpringCacheBasedTicketCache.java @@ -0,0 +1,86 @@ +/* + * Copyright 2002-2013 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.security.cas.authentication; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.InitializingBean; +import org.springframework.cache.Cache; +import org.springframework.util.Assert; + + +/** + * Caches tickets using a Spring IoC defined {@link Cache}. + * + * @author Marten Deinum + * @since 3.2 + * + */ +public class SpringCacheBasedTicketCache implements StatelessTicketCache, InitializingBean { + //~ Static fields/initializers ===================================================================================== + + private static final Log logger = LogFactory.getLog(SpringCacheBasedTicketCache.class); + + //~ Instance fields ================================================================================================ + + private Cache cache; + + //~ Methods ======================================================================================================== + + public void afterPropertiesSet() throws Exception { + Assert.notNull(cache, "cache mandatory"); + } + + public CasAuthenticationToken getByTicketId(final String serviceTicket) { + final Cache.ValueWrapper element = serviceTicket != null ? cache.get(serviceTicket) : null; + + if (logger.isDebugEnabled()) { + logger.debug("Cache hit: " + (element != null) + "; service ticket: " + serviceTicket); + } + + return element == null ? null : (CasAuthenticationToken) element.get(); + } + + public Cache getCache() { + return cache; + } + + public void putTicketInCache(final CasAuthenticationToken token) { + String key = token.getCredentials().toString(); + + if (logger.isDebugEnabled()) { + logger.debug("Cache put: " + key); + } + + cache.put(key, token); + } + + public void removeTicketFromCache(final CasAuthenticationToken token) { + if (logger.isDebugEnabled()) { + logger.debug("Cache remove: " + token.getCredentials().toString()); + } + + this.removeTicketFromCache(token.getCredentials().toString()); + } + + public void removeTicketFromCache(final String serviceTicket) { + cache.evict(serviceTicket); + } + + public void setCache(final Cache cache) { + this.cache = cache; + } +} diff --git a/cas/src/test/java/org/springframework/security/cas/authentication/SpringCacheBasedTicketCacheTests.java b/cas/src/test/java/org/springframework/security/cas/authentication/SpringCacheBasedTicketCacheTests.java new file mode 100644 index 00000000000..40dd9f49ae3 --- /dev/null +++ b/cas/src/test/java/org/springframework/security/cas/authentication/SpringCacheBasedTicketCacheTests.java @@ -0,0 +1,80 @@ +/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.security.cas.authentication; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.springframework.cache.Cache; +import org.springframework.cache.CacheManager; +import org.springframework.cache.concurrent.ConcurrentMapCacheManager; + +import static org.junit.Assert.*; + + +/** + * Tests {@link org.springframework.security.cas.authentication.SpringCacheBasedTicketCache}. + * + * @author Marten Deinum + * @since 3.2 + */ +public class SpringCacheBasedTicketCacheTests extends AbstractStatelessTicketCacheTests { + private static CacheManager cacheManager; + + //~ Methods ======================================================================================================== + @BeforeClass + public static void initCacheManaer() { + cacheManager = new ConcurrentMapCacheManager(); + cacheManager.getCache("castickets"); + } + + @Test + public void testCacheOperation() throws Exception { + SpringCacheBasedTicketCache cache = new SpringCacheBasedTicketCache(); + cache.setCache(cacheManager.getCache("castickets")); + cache.afterPropertiesSet(); + + final CasAuthenticationToken token = getToken(); + + // Check it gets stored in the cache + cache.putTicketInCache(token); + assertEquals(token, cache.getByTicketId("ST-0-ER94xMJmn6pha35CQRoZ")); + + // Check it gets removed from the cache + cache.removeTicketFromCache(getToken()); + assertNull(cache.getByTicketId("ST-0-ER94xMJmn6pha35CQRoZ")); + + // Check it doesn't return values for null or unknown service tickets + assertNull(cache.getByTicketId(null)); + assertNull(cache.getByTicketId("UNKNOWN_SERVICE_TICKET")); + } + + @Test + public void testStartupDetectsMissingCache() throws Exception { + SpringCacheBasedTicketCache cache = new SpringCacheBasedTicketCache(); + + try { + cache.afterPropertiesSet(); + fail("Should have thrown IllegalArgumentException"); + } catch (IllegalArgumentException expected) { + assertTrue(true); + } + + Cache myCache = cacheManager.getCache("castickets"); + cache.setCache(myCache); + assertEquals(myCache, cache.getCache()); + } +} diff --git a/core/src/main/java/org/springframework/security/core/userdetails/cache/SpringCacheBasedUserCache.java b/core/src/main/java/org/springframework/security/core/userdetails/cache/SpringCacheBasedUserCache.java new file mode 100644 index 00000000000..b2625a2946d --- /dev/null +++ b/core/src/main/java/org/springframework/security/core/userdetails/cache/SpringCacheBasedUserCache.java @@ -0,0 +1,74 @@ +package org.springframework.security.core.userdetails.cache; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.InitializingBean; +import org.springframework.cache.Cache; +import org.springframework.security.core.userdetails.UserCache; +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.util.Assert; + +/** + * Caches {@link UserDetails} intances in a Spring defined {@link Cache}. + * + * @author Marten Deinum + * @since 3.2 + */ +public class SpringCacheBasedUserCache implements UserCache, InitializingBean { + + + //~ Static fields/initializers ===================================================================================== + + private static final Log logger = LogFactory.getLog(SpringCacheBasedUserCache.class); + + //~ Instance fields ================================================================================================ + + private Cache cache; + + //~ Methods ======================================================================================================== + + public void afterPropertiesSet() throws Exception { + Assert.notNull(cache, "cache mandatory"); + } + + public Cache getCache() { + return cache; + } + + public UserDetails getUserFromCache(String username) { + Cache.ValueWrapper element = username != null ? cache.get(username) : null; + + if (logger.isDebugEnabled()) { + logger.debug("Cache hit: " + (element != null) + "; username: " + username); + } + + if (element == null) { + return null; + } else { + return (UserDetails) element.get(); + } + } + + public void putUserInCache(UserDetails user) { + if (logger.isDebugEnabled()) { + logger.debug("Cache put: " + user.getUsername()); + } + cache.put(user.getUsername(), user); + } + + public void removeUserFromCache(UserDetails user) { + if (logger.isDebugEnabled()) { + logger.debug("Cache remove: " + user.getUsername()); + } + + this.removeUserFromCache(user.getUsername()); + } + + public void removeUserFromCache(String username) { + cache.evict(username); + } + + public void setCache(Cache cache) { + this.cache = cache; + } +} diff --git a/core/src/test/java/org/springframework/security/core/userdetails/cache/SpringCacheBasedUserCacheTests.java b/core/src/test/java/org/springframework/security/core/userdetails/cache/SpringCacheBasedUserCacheTests.java new file mode 100644 index 00000000000..4045d8bcf94 --- /dev/null +++ b/core/src/test/java/org/springframework/security/core/userdetails/cache/SpringCacheBasedUserCacheTests.java @@ -0,0 +1,92 @@ +/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.security.core.userdetails.cache; + + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.springframework.cache.Cache; +import org.springframework.cache.CacheManager; +import org.springframework.cache.concurrent.ConcurrentMapCacheManager; +import org.springframework.security.core.authority.AuthorityUtils; +import org.springframework.security.core.userdetails.User; + +import static org.junit.Assert.*; + +/** + * Tests {@link org.springframework.security.core.userdetails.cache.SpringCacheBasedUserCache}. + * + * @author Marten Deinum + * @since 3.2 + * + */ +public class SpringCacheBasedUserCacheTests { + private static CacheManager cacheManager; + + //~ Methods ======================================================================================================== + @BeforeClass + public static void initCacheManaer() { + cacheManager = new ConcurrentMapCacheManager(); + cacheManager.getCache("springbasedusercachetests"); + } + + @AfterClass + public static void shutdownCacheManager() { + } + + private Cache getCache() { + Cache cache = cacheManager.getCache("springbasedusercachetests"); + cache.clear(); + return cache; + } + + private User getUser() { + return new User("john", "password", true, true, true, true, + AuthorityUtils.createAuthorityList("ROLE_ONE", "ROLE_TWO")); + } + + @Test + public void cacheOperationsAreSuccessful() throws Exception { + SpringCacheBasedUserCache cache = new SpringCacheBasedUserCache(); + cache.setCache(getCache()); + cache.afterPropertiesSet(); + + // Check it gets stored in the cache + cache.putUserInCache(getUser()); + assertEquals(getUser().getPassword(), cache.getUserFromCache(getUser().getUsername()).getPassword()); + + // Check it gets removed from the cache + cache.removeUserFromCache(getUser()); + assertNull(cache.getUserFromCache(getUser().getUsername())); + + // Check it doesn't return values for null or unknown users + assertNull(cache.getUserFromCache(null)); + assertNull(cache.getUserFromCache("UNKNOWN_USER")); + } + + @Test(expected = IllegalArgumentException.class) + public void startupDetectsMissingCache() throws Exception { + SpringCacheBasedUserCache cache = new SpringCacheBasedUserCache(); + + cache.afterPropertiesSet(); + fail("Should have thrown IllegalArgumentException"); + + Cache myCache = getCache(); + cache.setCache(myCache); + assertEquals(myCache, cache.getCache()); + } +} From 8179a2d3141b0457ccdd66a8a5eff81b43fb34af Mon Sep 17 00:00:00 2001 From: Rob Winch Date: Fri, 4 Jan 2013 11:12:08 -0600 Subject: [PATCH 08/11] SEC-2114: Polishing Spring Based Cache --- .../acls/domain/SpringCacheBasedAclCache.java | 39 ++++++------------- .../jdbc/SpringCacheBasedAclCacheTests.java | 38 ++---------------- .../SpringCacheBasedTicketCache.java | 20 ++++------ .../SpringCacheBasedTicketCacheTests.java | 22 ++--------- .../cache/SpringCacheBasedUserCache.java | 20 ++++------ .../cache/SpringCacheBasedUserCacheTests.java | 13 +------ 6 files changed, 36 insertions(+), 116 deletions(-) diff --git a/acl/src/main/java/org/springframework/security/acls/domain/SpringCacheBasedAclCache.java b/acl/src/main/java/org/springframework/security/acls/domain/SpringCacheBasedAclCache.java index 87dba1873cd..b266ab91425 100644 --- a/acl/src/main/java/org/springframework/security/acls/domain/SpringCacheBasedAclCache.java +++ b/acl/src/main/java/org/springframework/security/acls/domain/SpringCacheBasedAclCache.java @@ -15,9 +15,6 @@ */ package org.springframework.security.acls.domain; -import net.sf.ehcache.CacheException; -import net.sf.ehcache.Ehcache; -import net.sf.ehcache.Element; import org.springframework.cache.Cache; import org.springframework.security.acls.model.AclCache; import org.springframework.security.acls.model.MutableAcl; @@ -84,34 +81,12 @@ public void evictFromCache(ObjectIdentity objectIdentity) { public MutableAcl getFromCache(ObjectIdentity objectIdentity) { Assert.notNull(objectIdentity, "ObjectIdentity required"); - - Cache.ValueWrapper element = null; - - try { - element = cache.get(objectIdentity); - } catch (CacheException ignored) {} - - if (element == null) { - return null; - } - - return initializeTransientFields((MutableAcl)element.get()); + return getFromCache((Object)objectIdentity); } public MutableAcl getFromCache(Serializable pk) { Assert.notNull(pk, "Primary key (identifier) required"); - - Cache.ValueWrapper element = null; - - try { - element = cache.get(pk); - } catch (CacheException ignored) {} - - if (element == null) { - return null; - } - - return initializeTransientFields((MutableAcl) element.get()); + return getFromCache((Object)pk); } public void putInCache(MutableAcl acl) { @@ -127,6 +102,16 @@ public void putInCache(MutableAcl acl) { cache.put(acl.getId(), acl); } + private MutableAcl getFromCache(Object key) { + Cache.ValueWrapper element = cache.get(key); + + if (element == null) { + return null; + } + + return initializeTransientFields((MutableAcl) element.get()); + } + private MutableAcl initializeTransientFields(MutableAcl value) { if (value instanceof AclImpl) { FieldUtils.setProtectedFieldValue("aclAuthorizationStrategy", value, this.aclAuthorizationStrategy); diff --git a/acl/src/test/java/org/springframework/security/acls/jdbc/SpringCacheBasedAclCacheTests.java b/acl/src/test/java/org/springframework/security/acls/jdbc/SpringCacheBasedAclCacheTests.java index 05ced8ae67c..5b4338b5bbe 100644 --- a/acl/src/test/java/org/springframework/security/acls/jdbc/SpringCacheBasedAclCacheTests.java +++ b/acl/src/test/java/org/springframework/security/acls/jdbc/SpringCacheBasedAclCacheTests.java @@ -1,7 +1,6 @@ package org.springframework.security.acls.jdbc; import org.junit.After; -import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; import org.springframework.cache.Cache; @@ -17,15 +16,14 @@ import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.util.FieldUtils; -import java.io.*; import java.util.Map; import static org.junit.Assert.*; /** - * Tests {@link org.springframework.security.acls.domain.EhCacheBasedAclCache} + * Tests {@link org.springframework.security.acls.domain.SpringCacheBasedAclCache} * - * @author Andrei Stefan + * @author Marten Deinum */ public class SpringCacheBasedAclCacheTests { private static final String TARGET_CLASS = "org.springframework.security.acls.TargetObject"; @@ -55,6 +53,7 @@ public void constructorRejectsNullParameters() throws Exception { new SpringCacheBasedAclCache(null, null, null); } + @SuppressWarnings("rawtypes") @Test public void cacheOperationsAclWithoutParent() throws Exception { Cache cache = getCache(); @@ -98,7 +97,7 @@ public void cacheOperationsAclWithoutParent() throws Exception { assertEquals(realCache.size(), 0); } - @SuppressWarnings("unchecked") + @SuppressWarnings("rawtypes") @Test public void cacheOperationsAclWithParent() throws Exception { Cache cache = getCache(); @@ -140,33 +139,4 @@ public void cacheOperationsAclWithParent() throws Exception { assertNotNull(FieldUtils.getFieldValue(parentAclFromCache, "aclAuthorizationStrategy")); assertEquals(parentAcl, myCache.getFromCache(identityParent)); } - - //~ Inner Classes ================================================================================================== - - private class MockCache implements Cache { - - @Override - public String getName() { - return "mockcache"; - } - - @Override - public Object getNativeCache() { - return null; - } - - @Override - public ValueWrapper get(Object key) { - return null; - } - - @Override - public void put(Object key, Object value) {} - - @Override - public void evict(Object key) {} - - @Override - public void clear() {} - } } diff --git a/cas/src/main/java/org/springframework/security/cas/authentication/SpringCacheBasedTicketCache.java b/cas/src/main/java/org/springframework/security/cas/authentication/SpringCacheBasedTicketCache.java index caddb8f89d7..fb94bd32ccb 100644 --- a/cas/src/main/java/org/springframework/security/cas/authentication/SpringCacheBasedTicketCache.java +++ b/cas/src/main/java/org/springframework/security/cas/authentication/SpringCacheBasedTicketCache.java @@ -17,7 +17,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.springframework.beans.factory.InitializingBean; import org.springframework.cache.Cache; import org.springframework.util.Assert; @@ -29,21 +28,24 @@ * @since 3.2 * */ -public class SpringCacheBasedTicketCache implements StatelessTicketCache, InitializingBean { +public class SpringCacheBasedTicketCache implements StatelessTicketCache { //~ Static fields/initializers ===================================================================================== private static final Log logger = LogFactory.getLog(SpringCacheBasedTicketCache.class); //~ Instance fields ================================================================================================ - private Cache cache; + private final Cache cache; - //~ Methods ======================================================================================================== + //~ Constructors =================================================================================================== - public void afterPropertiesSet() throws Exception { + public SpringCacheBasedTicketCache(Cache cache) throws Exception { Assert.notNull(cache, "cache mandatory"); + this.cache = cache; } + //~ Methods ======================================================================================================== + public CasAuthenticationToken getByTicketId(final String serviceTicket) { final Cache.ValueWrapper element = serviceTicket != null ? cache.get(serviceTicket) : null; @@ -54,10 +56,6 @@ public CasAuthenticationToken getByTicketId(final String serviceTicket) { return element == null ? null : (CasAuthenticationToken) element.get(); } - public Cache getCache() { - return cache; - } - public void putTicketInCache(final CasAuthenticationToken token) { String key = token.getCredentials().toString(); @@ -79,8 +77,4 @@ public void removeTicketFromCache(final CasAuthenticationToken token) { public void removeTicketFromCache(final String serviceTicket) { cache.evict(serviceTicket); } - - public void setCache(final Cache cache) { - this.cache = cache; - } } diff --git a/cas/src/test/java/org/springframework/security/cas/authentication/SpringCacheBasedTicketCacheTests.java b/cas/src/test/java/org/springframework/security/cas/authentication/SpringCacheBasedTicketCacheTests.java index 40dd9f49ae3..c8abf77f94e 100644 --- a/cas/src/test/java/org/springframework/security/cas/authentication/SpringCacheBasedTicketCacheTests.java +++ b/cas/src/test/java/org/springframework/security/cas/authentication/SpringCacheBasedTicketCacheTests.java @@ -15,10 +15,8 @@ package org.springframework.security.cas.authentication; -import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; -import org.springframework.cache.Cache; import org.springframework.cache.CacheManager; import org.springframework.cache.concurrent.ConcurrentMapCacheManager; @@ -35,6 +33,7 @@ public class SpringCacheBasedTicketCacheTests extends AbstractStatelessTicketCac private static CacheManager cacheManager; //~ Methods ======================================================================================================== + @BeforeClass public static void initCacheManaer() { cacheManager = new ConcurrentMapCacheManager(); @@ -43,9 +42,7 @@ public static void initCacheManaer() { @Test public void testCacheOperation() throws Exception { - SpringCacheBasedTicketCache cache = new SpringCacheBasedTicketCache(); - cache.setCache(cacheManager.getCache("castickets")); - cache.afterPropertiesSet(); + SpringCacheBasedTicketCache cache = new SpringCacheBasedTicketCache(cacheManager.getCache("castickets")); final CasAuthenticationToken token = getToken(); @@ -62,19 +59,8 @@ public void testCacheOperation() throws Exception { assertNull(cache.getByTicketId("UNKNOWN_SERVICE_TICKET")); } - @Test + @Test(expected = IllegalArgumentException.class) public void testStartupDetectsMissingCache() throws Exception { - SpringCacheBasedTicketCache cache = new SpringCacheBasedTicketCache(); - - try { - cache.afterPropertiesSet(); - fail("Should have thrown IllegalArgumentException"); - } catch (IllegalArgumentException expected) { - assertTrue(true); - } - - Cache myCache = cacheManager.getCache("castickets"); - cache.setCache(myCache); - assertEquals(myCache, cache.getCache()); + new SpringCacheBasedTicketCache(null); } } diff --git a/core/src/main/java/org/springframework/security/core/userdetails/cache/SpringCacheBasedUserCache.java b/core/src/main/java/org/springframework/security/core/userdetails/cache/SpringCacheBasedUserCache.java index b2625a2946d..efd3741e8b7 100644 --- a/core/src/main/java/org/springframework/security/core/userdetails/cache/SpringCacheBasedUserCache.java +++ b/core/src/main/java/org/springframework/security/core/userdetails/cache/SpringCacheBasedUserCache.java @@ -2,19 +2,18 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.springframework.beans.factory.InitializingBean; import org.springframework.cache.Cache; import org.springframework.security.core.userdetails.UserCache; import org.springframework.security.core.userdetails.UserDetails; import org.springframework.util.Assert; /** - * Caches {@link UserDetails} intances in a Spring defined {@link Cache}. + * Caches {@link UserDetails} instances in a Spring defined {@link Cache}. * * @author Marten Deinum * @since 3.2 */ -public class SpringCacheBasedUserCache implements UserCache, InitializingBean { +public class SpringCacheBasedUserCache implements UserCache { //~ Static fields/initializers ===================================================================================== @@ -23,17 +22,16 @@ public class SpringCacheBasedUserCache implements UserCache, InitializingBean { //~ Instance fields ================================================================================================ - private Cache cache; + private final Cache cache; - //~ Methods ======================================================================================================== + //~ Constructors =================================================================================================== - public void afterPropertiesSet() throws Exception { + public SpringCacheBasedUserCache(Cache cache) throws Exception { Assert.notNull(cache, "cache mandatory"); + this.cache = cache; } - public Cache getCache() { - return cache; - } + //~ Methods ======================================================================================================== public UserDetails getUserFromCache(String username) { Cache.ValueWrapper element = username != null ? cache.get(username) : null; @@ -67,8 +65,4 @@ public void removeUserFromCache(UserDetails user) { public void removeUserFromCache(String username) { cache.evict(username); } - - public void setCache(Cache cache) { - this.cache = cache; - } } diff --git a/core/src/test/java/org/springframework/security/core/userdetails/cache/SpringCacheBasedUserCacheTests.java b/core/src/test/java/org/springframework/security/core/userdetails/cache/SpringCacheBasedUserCacheTests.java index 4045d8bcf94..f77422a00d3 100644 --- a/core/src/test/java/org/springframework/security/core/userdetails/cache/SpringCacheBasedUserCacheTests.java +++ b/core/src/test/java/org/springframework/security/core/userdetails/cache/SpringCacheBasedUserCacheTests.java @@ -61,9 +61,7 @@ private User getUser() { @Test public void cacheOperationsAreSuccessful() throws Exception { - SpringCacheBasedUserCache cache = new SpringCacheBasedUserCache(); - cache.setCache(getCache()); - cache.afterPropertiesSet(); + SpringCacheBasedUserCache cache = new SpringCacheBasedUserCache(getCache()); // Check it gets stored in the cache cache.putUserInCache(getUser()); @@ -80,13 +78,6 @@ public void cacheOperationsAreSuccessful() throws Exception { @Test(expected = IllegalArgumentException.class) public void startupDetectsMissingCache() throws Exception { - SpringCacheBasedUserCache cache = new SpringCacheBasedUserCache(); - - cache.afterPropertiesSet(); - fail("Should have thrown IllegalArgumentException"); - - Cache myCache = getCache(); - cache.setCache(myCache); - assertEquals(myCache, cache.getCache()); + new SpringCacheBasedUserCache(null); } } From 38629d499ddbcd0b8a2b50c65e02961c58fbef68 Mon Sep 17 00:00:00 2001 From: Georges-Etienne Legendre Date: Wed, 5 Dec 2012 11:51:25 -0500 Subject: [PATCH 09/11] SEC-2115: Improve French translation for "credentials" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit "Créances" is not the right translation. "Identifications" is a lot better in this case. --- .../security/messages_fr.properties | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/core/src/main/resources/org/springframework/security/messages_fr.properties b/core/src/main/resources/org/springframework/security/messages_fr.properties index aa810351a8b..d4d7049d139 100644 --- a/core/src/main/resources/org/springframework/security/messages_fr.properties +++ b/core/src/main/resources/org/springframework/security/messages_fr.properties @@ -4,19 +4,19 @@ # Translation by Valentin Crettaz (valentin.crettaz@consulthys.com) AbstractAccessDecisionManager.accessDenied=Acc\u00E8s refus\u00E9 AbstractSecurityInterceptor.authenticationNotFound=Aucun objet Authentication n'a \u00E9t\u00E9 trouv\u00E9 dans le SecurityContext -AbstractUserDetailsAuthenticationProvider.badCredentials=Les cr\u00E9ances sont erron\u00E9es -AbstractUserDetailsAuthenticationProvider.credentialsExpired=Les cr\u00E9ances de l'utilisateur ont expir\u00E9 +AbstractUserDetailsAuthenticationProvider.badCredentials=Les identifications sont erron\u00E9es +AbstractUserDetailsAuthenticationProvider.credentialsExpired=Les identifications de l'utilisateur ont expir\u00E9 AbstractUserDetailsAuthenticationProvider.disabled=Le compte utilisateur est d\u00E9sactiv\u00E9 AbstractUserDetailsAuthenticationProvider.expired=Le compte utilisateur a expir\u00E9 AbstractUserDetailsAuthenticationProvider.locked=Le compte utilisateur est bloqu\u00E9 AbstractUserDetailsAuthenticationProvider.onlySupports=Seul UsernamePasswordAuthenticationToken est pris en charge -AccountStatusUserDetailsChecker.credentialsExpired=Les cr\u00E9ances de l'utilisateur ont expir\u00E9 +AccountStatusUserDetailsChecker.credentialsExpired=Les identifications de l'utilisateur ont expir\u00E9 AccountStatusUserDetailsChecker.disabled=Le compte utilisateur est d\u00E9sactiv\u00E9 AccountStatusUserDetailsChecker.expired=Le compte utilisateur a expir\u00E9 AccountStatusUserDetailsChecker.locked=Le compte utilisateur est bloqu\u00E9 AclEntryAfterInvocationProvider.noPermission=L'authentification {0} n'a AUCUNE permission pour l'objet de domaine {1} AnonymousAuthenticationProvider.incorrectKey=L'AnonymousAuthenticationToken pr\u00E9sent\u00E9 ne contient pas la cl\u00E9 attendue -BindAuthenticator.badCredentials=Les cr\u00E9ances sont erron\u00E9es +BindAuthenticator.badCredentials=Les identifications sont erron\u00E9es BindAuthenticator.emptyPassword=Le mot de passe est obligatoire CasAuthenticationProvider.incorrectKey=Le CasAuthenticationToken pr\u00E9sent\u00E9 ne contient pas la cl\u00E9 attendue CasAuthenticationProvider.noServiceTicket=Echec d'obtention d'un ticket CAS \u00E0 valider @@ -33,14 +33,14 @@ DigestAuthenticationFilter.nonceNotTwoTokens=Le nonce aurait d\u00FB g\u00E9n\u0 DigestAuthenticationFilter.usernameNotFound=Le nom d'utilisateur {0} n'a pas \u00E9t\u00E9 trouv\u00E9 JdbcDaoImpl.noAuthority=Le compte utilisateur {0} n'a pas de permission JdbcDaoImpl.notFound=Le nom d'utilisateur {0} n'a pas \u00E9t\u00E9 trouv\u00E9 -LdapAuthenticationProvider.badCredentials=Les cr\u00E9ances sont erron\u00E9es -LdapAuthenticationProvider.credentialsExpired=Les cr\u00E9ances de l'utilisateur ont expir\u00E9 +LdapAuthenticationProvider.badCredentials=Les identifications sont erron\u00E9es +LdapAuthenticationProvider.credentialsExpired=Les identifications de l'utilisateur ont expir\u00E9 LdapAuthenticationProvider.disabled=Le compte utilisateur est d\u00E9sactiv\u00E9 LdapAuthenticationProvider.expired=Le compte utilisateur a expir\u00E9 LdapAuthenticationProvider.locked=Le compte utilisateur est bloqu\u00E9 LdapAuthenticationProvider.emptyUsername=Le nom d'utilisateur est obligatoire LdapAuthenticationProvider.onlySupports=Seul UsernamePasswordAuthenticationToken est pris en charge -PasswordComparisonAuthenticator.badCredentials=Les cr\u00E9ances sont erron\u00E9es +PasswordComparisonAuthenticator.badCredentials=Les identifications sont erron\u00E9es PersistentTokenBasedRememberMeServices.cookieStolen=Invalid remember-me token (Series/token) mismatch. Implies previous cookie theft attack. ProviderManager.providerNotFound=Aucun AuthenticationProvider n'a \u00E9t\u00E9 trouv\u00E9 pour {0} RememberMeAuthenticationProvider.incorrectKey=Le RememberMeAuthenticationToken pr\u00E9sent\u00E9 ne contient pas la cl\u00E9 attendue From 2411c621b7d5c93ce69441a3da0cf90e43835975 Mon Sep 17 00:00:00 2001 From: Marten Deinum Date: Fri, 21 Dec 2012 14:56:18 +0100 Subject: [PATCH 10/11] Issues: SEC-2098, SEC-2099 AddHeadersFilter for setting security headers added including a bean definition parser for easy configuration of the headers. Enables easy configuration for the X-Frame-Options, X-XSS-Protection and X-Content-Type-Options headers. Also allows for additional headers to be added. --- .../config/SecurityNamespaceHandler.java | 2 +- .../config/http/HttpConfigurationBuilder.java | 2 +- .../security/config/spring-security-3.2.rnc | 39 ++++++- .../security/config/spring-security-3.2.xsd | 101 ++++++++++++++++++ .../config/SecurityNamespaceHandlerTests.java | 4 +- ...ationManagerBeanDefinitionParserTests.java | 8 +- .../util/InMemoryXmlApplicationContext.java | 4 +- .../manual/src/docbook/appendix-namespace.xml | 86 +++------------ docs/manual/src/docbook/namespace-config.xml | 4 +- .../http-path-param-stripping-app-context.xml | 2 +- ...otect-pointcut-performance-app-context.xml | 2 +- .../resources/sec-936-app-context.xml | 2 +- .../webapp/WEB-INF/http-security-basic.xml | 2 +- .../WEB-INF/http-security-concurrency.xml | 2 +- .../http-security-custom-concurrency.xml | 2 +- .../src/main/webapp/WEB-INF/http-security.xml | 2 +- .../webapp/WEB-INF/in-memory-provider.xml | 2 +- .../src/main/resources/aspectj-context.xml | 2 +- .../WEB-INF/applicationContext-security.xml | 2 +- .../applicationContext-dms-secure.xml | 2 +- .../WEB-INF/applicationContext-security.xml | 2 +- .../resources/applicationContext-security.xml | 2 +- .../WEB-INF/applicationContext-security.xml | 2 +- .../WEB-INF/applicationContext-security.xml | 2 +- .../resources/applicationContext-security.xml | 2 +- .../WEB-INF/applicationContext-security.xml | 2 +- .../web/headers/HeadersFilterTest.java | 73 +++++++++++++ 27 files changed, 253 insertions(+), 104 deletions(-) create mode 100644 web/src/test/java/org/springframework/security/web/headers/HeadersFilterTest.java diff --git a/config/src/main/java/org/springframework/security/config/SecurityNamespaceHandler.java b/config/src/main/java/org/springframework/security/config/SecurityNamespaceHandler.java index 6f18f410f3f..43f479bc481 100644 --- a/config/src/main/java/org/springframework/security/config/SecurityNamespaceHandler.java +++ b/config/src/main/java/org/springframework/security/config/SecurityNamespaceHandler.java @@ -67,7 +67,7 @@ public BeanDefinition parse(Element element, ParserContext pc) { if (!namespaceMatchesVersion(element)) { pc.getReaderContext().fatal("You cannot use a spring-security-2.0.xsd, spring-security-3.0.xsd schema " + "or spring-security-3.1.xsd with Spring Security 3.2. Please update your schema declarations to the " - + " 3.2 schema.", element); + + "3.2 schema.", element); } String name = pc.getDelegate().getLocalName(element); BeanDefinitionParser parser = parsers.get(name); diff --git a/config/src/main/java/org/springframework/security/config/http/HttpConfigurationBuilder.java b/config/src/main/java/org/springframework/security/config/http/HttpConfigurationBuilder.java index d3a8220baa0..65fca173706 100644 --- a/config/src/main/java/org/springframework/security/config/http/HttpConfigurationBuilder.java +++ b/config/src/main/java/org/springframework/security/config/http/HttpConfigurationBuilder.java @@ -612,7 +612,7 @@ List getFilters() { } if (addHeadersFilter != null) { - filters.add(new OrderDecorator(addHeadersFilter, ADD_HEADERS_FILTER)); + filters.add(new OrderDecorator(addHeadersFilter, HEADERS_FILTER)); } return filters; diff --git a/config/src/main/resources/org/springframework/security/config/spring-security-3.2.rnc b/config/src/main/resources/org/springframework/security/config/spring-security-3.2.rnc index 0003313513d..7e94da80c6f 100644 --- a/config/src/main/resources/org/springframework/security/config/spring-security-3.2.rnc +++ b/config/src/main/resources/org/springframework/security/config/spring-security-3.2.rnc @@ -281,7 +281,7 @@ http-firewall = http = ## Container element for HTTP security configuration. Multiple elements can now be defined, each with a specific pattern to which the enclosed security configuration applies. A pattern can also be configured to bypass Spring Security's filters completely by setting the "secured" attribute to "false". - element http {http.attlist, (intercept-url* & access-denied-handler? & form-login? & openid-login? & x509? & jee? & http-basic? & logout? & session-management & remember-me? & anonymous? & port-mappings & custom-filter* & request-cache? & expression-handler?) } + element http {http.attlist, (intercept-url* & access-denied-handler? & form-login? & openid-login? & x509? & jee? & http-basic? & logout? & session-management & remember-me? & anonymous? & port-mappings & custom-filter* & request-cache? & expression-handler? & headers?) } http.attlist &= ## The request URL pattern which will be mapped to the filter chain created by this element. If omitted, the filter chain will match all requests. attribute pattern {xsd:token}? @@ -716,6 +716,43 @@ jdbc-user-service.attlist &= jdbc-user-service.attlist &= role-prefix? +headers = + ## Element for configuration of the AddHeadersFilter. Enables easy setting for the X-Frame-Options, X-XSS-Protection and X-Content-Type-Options headers. + element headers {xss-protection? & frame-options? & content-type-options? & header*} + +frame-options = + ## Enable basic clickjacking support for newer browsers (IE8+), will set the X-Frame-Options header. + element frame-options {frame-options.attlist,empty} +frame-options.attlist &= + ## Specify the policy to use for the X-Frame-Options-Header. + attribute policy {"DENY","SAMEORIGIN","ALLOW-FROM"}? +frame-options.attlist &= + ## Specify the origin to use when ALLOW-FROM is chosen. + attribute origin {xsd:token}? + +xss-protection = + ## Enable basic XSS browser protection, supported by newer browsers (IE8+), will set the X-XSS-Protection header. + element xss-protection {xss-protection.attlist,empty} +xss-protection.attlist &= + ## enable or disable the X-XSS-Protection header. Default is 'true' meaning it is enabled. + attribute enabled {xsd:boolean}? +xss-protection.attlist &= + ## Add mode=block to the header or not, default is on. + attribute block {xsd:boolean}? + +content-type-options = + ## Add a X-Content-Type-Options header to the resopnse. Value is always 'nosniff'. + element content-type-options {empty} + +header= + ## Add additional headers to the response. + element header {header.attlist} +header.attlist &= + ## The name of the header to add. + attribute name {xsd:token} +header.attlist &= + ## The value for the header. + attribute value {xsd:token} any-user-service = user-service | jdbc-user-service | ldap-user-service diff --git a/config/src/main/resources/org/springframework/security/config/spring-security-3.2.xsd b/config/src/main/resources/org/springframework/security/config/spring-security-3.2.xsd index 2485e4eeb75..294a924a1f4 100644 --- a/config/src/main/resources/org/springframework/security/config/spring-security-3.2.xsd +++ b/config/src/main/resources/org/springframework/security/config/spring-security-3.2.xsd @@ -1024,6 +1024,7 @@ + @@ -2224,6 +2225,106 @@ + + + Element for configuration of the AddHeadersFilter. Enables easy setting for the + X-Frame-Options, X-XSS-Protection and X-Content-Type-Options headers. + + + + + + + + + + + + + + Enable basic clickjacking support for newer browsers (IE8+), will set the X-Frame-Options + header. + + + + + + + + + + Specify the policy to use for the X-Frame-Options-Header. + + + + + + + + + + + + + Specify the origin to use when ALLOW-FROM is chosen. + + + + + + + Enable basic XSS browser protection, supported by newer browsers (IE8+), will set the + X-XSS-Protection header. + + + + + + + + + + enable or disable the X-XSS-Protection header. Default is 'true' meaning it is enabled. + + + + + + Add mode=block to the header or not, default is on. + + + + + + + Add a X-Content-Type-Options header to the resopnse. Value is always 'nosniff'. + + + + + + + Add additional headers to the response. + + + + + + + + + + The name of the header to add. + + + + + + The value for the header. + + + + diff --git a/config/src/test/java/org/springframework/security/config/SecurityNamespaceHandlerTests.java b/config/src/test/java/org/springframework/security/config/SecurityNamespaceHandlerTests.java index 566e3803e25..9b65a7f3aeb 100644 --- a/config/src/test/java/org/springframework/security/config/SecurityNamespaceHandlerTests.java +++ b/config/src/test/java/org/springframework/security/config/SecurityNamespaceHandlerTests.java @@ -48,7 +48,7 @@ public void constructionSucceeds() { } @Test - public void pre31SchemaAreNotSupported() throws Exception { + public void pre32SchemaAreNotSupported() throws Exception { try { new InMemoryXmlApplicationContext( "" + @@ -57,7 +57,7 @@ public void pre31SchemaAreNotSupported() throws Exception { ); fail("Expected BeanDefinitionParsingException"); } catch (BeanDefinitionParsingException expected) { - assertTrue(expected.getMessage().contains("You cannot use a spring-security-2.0.xsd or")); + assertTrue(expected.getMessage().contains("You cannot use a spring-security-2.0.xsd")); } } diff --git a/config/src/test/java/org/springframework/security/config/authentication/AuthenticationManagerBeanDefinitionParserTests.java b/config/src/test/java/org/springframework/security/config/authentication/AuthenticationManagerBeanDefinitionParserTests.java index 73d7830aa61..551fcedadd3 100644 --- a/config/src/test/java/org/springframework/security/config/authentication/AuthenticationManagerBeanDefinitionParserTests.java +++ b/config/src/test/java/org/springframework/security/config/authentication/AuthenticationManagerBeanDefinitionParserTests.java @@ -34,13 +34,13 @@ public class AuthenticationManagerBeanDefinitionParserTests { @Test // SEC-1225 public void providersAreRegisteredAsTopLevelBeans() throws Exception { - setContext(CONTEXT, "3.1"); + setContext(CONTEXT, "3.2"); assertEquals(1, appContext.getBeansOfType(AuthenticationProvider.class).size()); } @Test public void eventsArePublishedByDefault() throws Exception { - setContext(CONTEXT, "3.1"); + setContext(CONTEXT, "3.2"); AuthListener listener = new AuthListener(); appContext.addApplicationListener(listener); @@ -55,14 +55,14 @@ public void eventsArePublishedByDefault() throws Exception { @Test public void credentialsAreClearedByDefault() throws Exception { - setContext(CONTEXT, "3.1"); + setContext(CONTEXT, "3.2"); ProviderManager pm = (ProviderManager) appContext.getBeansOfType(ProviderManager.class).values().toArray()[0]; assertTrue(pm.isEraseCredentialsAfterAuthentication()); } @Test public void clearCredentialsPropertyIsRespected() throws Exception { - setContext("", "3.1"); + setContext("", "3.2"); ProviderManager pm = (ProviderManager) appContext.getBeansOfType(ProviderManager.class).values().toArray()[0]; assertFalse(pm.isEraseCredentialsAfterAuthentication()); } diff --git a/config/src/test/java/org/springframework/security/config/util/InMemoryXmlApplicationContext.java b/config/src/test/java/org/springframework/security/config/util/InMemoryXmlApplicationContext.java index b83058c0bc4..21f5f48f582 100644 --- a/config/src/test/java/org/springframework/security/config/util/InMemoryXmlApplicationContext.java +++ b/config/src/test/java/org/springframework/security/config/util/InMemoryXmlApplicationContext.java @@ -25,11 +25,11 @@ public class InMemoryXmlApplicationContext extends AbstractXmlApplicationContext Resource inMemoryXml; public InMemoryXmlApplicationContext(String xml) { - this(xml, "3.1", null); + this(xml, "3.2", null); } public InMemoryXmlApplicationContext(String xml, ApplicationContext parent) { - this(xml, "3.1", parent); + this(xml, "3.2", parent); } public InMemoryXmlApplicationContext(String xml, String secVersion, ApplicationContext parent) { diff --git a/docs/manual/src/docbook/appendix-namespace.xml b/docs/manual/src/docbook/appendix-namespace.xml index 8d92d2ee12b..591c54e7a7d 100644 --- a/docs/manual/src/docbook/appendix-namespace.xml +++ b/docs/manual/src/docbook/appendix-namespace.xml @@ -15,7 +15,7 @@ explaining their purpose. The namespace is written in RELAX NG Compact format and later converted into an XSD schema. If you are familiar with this format, you may wish to examine the schema file directly.

Web Application Security @@ -204,68 +204,6 @@ access-control.
-
- <literal><headers></literal> - This element allows for configuring additional (security) headers to be send with the response. - It enables easy configuration for several headers and also allows for setting additional custom - headers through the header element. - - X-Frame-Options - Can be set using the - frame-options element. The - X-Frame-Options - header can be used to prevent clickjacking attacks. - X-XSS-Protection - Can be set using the - xss-protection element. - The X-XSS-Protection - header can be used by browser to do basic control. - X-Content-Type-Options - Can be set using the - content-type-options element. The - X-Content-Type-Options header prevents Internet Explorer from - MIME-sniffing a response away from the declared content-type. This also applies to Google - Chrome, when downloading extensions. - - - -
- <literal><frame-options></literal> -
-
-
-
-
-
- <literal><xss-protection></literal> -
-
-
-
-
-
- <literal><content-type-options></literal> -
-
- <literal><header></literal> -
-
-
-
-
-
- Parent Elements of <literal><headers></literal> - - http - -
-
- Child Elements of <literal><headers></literal> - - frame-options - xss-protection - content-type-options - header - -
-
Child Elements of <http> @@ -285,7 +223,7 @@ request-cache session-management x509 - add-headers + headers
@@ -319,8 +257,8 @@ -
- <literal><add-headers></literal> +
+ <literal><headers></literal> This element allows for configuring additional (security) headers to be send with the response. It enables easy configuration for several headers and also allows for setting custom headers through the header element. @@ -340,14 +278,14 @@ Chrome, when downloading extensions. -
- Parent Elements of <literal><add-headers></literal> +
+ Parent Elements of <literal><headers></literal> http
-
- Child Elements of <literal><add-headers></literal> +
+ Child Elements of <literal><headers></literal> content-type-options frame-options @@ -388,7 +326,7 @@
Parent Elements of <literal><frame-options></literal> - add-headers + headers
@@ -408,7 +346,7 @@
Parent Elements of <literal><xss-protection></literal> - add-headers + headers
@@ -419,7 +357,7 @@
Parent Elements of <literal><content-type-options></literal> - add-headers + headers
@@ -440,7 +378,7 @@
Parent Elements of <literal><header></literal> - add-headers + headers
diff --git a/docs/manual/src/docbook/namespace-config.xml b/docs/manual/src/docbook/namespace-config.xml index fcf9f8a880a..48176aed7a7 100644 --- a/docs/manual/src/docbook/namespace-config.xml +++ b/docs/manual/src/docbook/namespace-config.xml @@ -39,7 +39,7 @@ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/security - http://www.springframework.org/schema/security/spring-security-3.1.xsd"> + http://www.springframework.org/schema/security/spring-security-3.2.xsd"> ... ]]> In many of the examples you will see (and in the sample) applications, we @@ -54,7 +54,7 @@ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/security - http://www.springframework.org/schema/security/spring-security-3.1.xsd"> + http://www.springframework.org/schema/security/spring-security-3.2.xsd"> ... ]]> We'll assume this syntax is being used from now on in this chapter. diff --git a/itest/context/src/integration-test/resources/http-path-param-stripping-app-context.xml b/itest/context/src/integration-test/resources/http-path-param-stripping-app-context.xml index 4ea30cfb1c3..f7bf0693c79 100644 --- a/itest/context/src/integration-test/resources/http-path-param-stripping-app-context.xml +++ b/itest/context/src/integration-test/resources/http-path-param-stripping-app-context.xml @@ -8,7 +8,7 @@ xmlns:b="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd - http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd"> + http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd"> diff --git a/itest/context/src/integration-test/resources/protect-pointcut-performance-app-context.xml b/itest/context/src/integration-test/resources/protect-pointcut-performance-app-context.xml index a1cadeb00f7..fdb4b47d2e8 100644 --- a/itest/context/src/integration-test/resources/protect-pointcut-performance-app-context.xml +++ b/itest/context/src/integration-test/resources/protect-pointcut-performance-app-context.xml @@ -2,7 +2,7 @@ xmlns:sec="http://www.springframework.org/schema/security" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd - http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd"> + http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd"> diff --git a/itest/context/src/integration-test/resources/sec-936-app-context.xml b/itest/context/src/integration-test/resources/sec-936-app-context.xml index 1d5c9a8bec6..855efe773b3 100755 --- a/itest/context/src/integration-test/resources/sec-936-app-context.xml +++ b/itest/context/src/integration-test/resources/sec-936-app-context.xml @@ -5,7 +5,7 @@ xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd - http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd"> + http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd"> diff --git a/itest/web/src/main/webapp/WEB-INF/http-security-basic.xml b/itest/web/src/main/webapp/WEB-INF/http-security-basic.xml index 0f74a285904..66d670504bf 100644 --- a/itest/web/src/main/webapp/WEB-INF/http-security-basic.xml +++ b/itest/web/src/main/webapp/WEB-INF/http-security-basic.xml @@ -4,7 +4,7 @@ xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd - http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd"> + http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd"> diff --git a/itest/web/src/main/webapp/WEB-INF/http-security-concurrency.xml b/itest/web/src/main/webapp/WEB-INF/http-security-concurrency.xml index cda86313765..b93aaeccc27 100644 --- a/itest/web/src/main/webapp/WEB-INF/http-security-concurrency.xml +++ b/itest/web/src/main/webapp/WEB-INF/http-security-concurrency.xml @@ -4,7 +4,7 @@ xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd - http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd"> + http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd"> diff --git a/itest/web/src/main/webapp/WEB-INF/http-security-custom-concurrency.xml b/itest/web/src/main/webapp/WEB-INF/http-security-custom-concurrency.xml index 2177c12e09c..57b88440473 100644 --- a/itest/web/src/main/webapp/WEB-INF/http-security-custom-concurrency.xml +++ b/itest/web/src/main/webapp/WEB-INF/http-security-custom-concurrency.xml @@ -4,7 +4,7 @@ xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd - http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd"> + http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd"> diff --git a/itest/web/src/main/webapp/WEB-INF/http-security.xml b/itest/web/src/main/webapp/WEB-INF/http-security.xml index 004c1f0ad11..4565eae0cf3 100644 --- a/itest/web/src/main/webapp/WEB-INF/http-security.xml +++ b/itest/web/src/main/webapp/WEB-INF/http-security.xml @@ -4,7 +4,7 @@ xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd - http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd"> + http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd">