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..b266ab91425 --- /dev/null +++ b/acl/src/main/java/org/springframework/security/acls/domain/SpringCacheBasedAclCache.java @@ -0,0 +1,130 @@ +/* + * 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 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"); + return getFromCache((Object)objectIdentity); + } + + public MutableAcl getFromCache(Serializable pk) { + Assert.notNull(pk, "Primary key (identifier) required"); + return getFromCache((Object)pk); + } + + 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 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); + 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..5b4338b5bbe --- /dev/null +++ b/acl/src/test/java/org/springframework/security/acls/jdbc/SpringCacheBasedAclCacheTests.java @@ -0,0 +1,142 @@ +package org.springframework.security.acls.jdbc; + +import org.junit.After; +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.util.Map; + +import static org.junit.Assert.*; + +/** + * Tests {@link org.springframework.security.acls.domain.SpringCacheBasedAclCache} + * + * @author Marten Deinum + */ +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); + } + + @SuppressWarnings("rawtypes") + @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("rawtypes") + @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)); + } +} 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/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..fb94bd32ccb --- /dev/null +++ b/cas/src/main/java/org/springframework/security/cas/authentication/SpringCacheBasedTicketCache.java @@ -0,0 +1,80 @@ +/* + * 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.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 { + //~ Static fields/initializers ===================================================================================== + + private static final Log logger = LogFactory.getLog(SpringCacheBasedTicketCache.class); + + //~ Instance fields ================================================================================================ + + private final Cache cache; + + //~ Constructors =================================================================================================== + + 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; + + if (logger.isDebugEnabled()) { + logger.debug("Cache hit: " + (element != null) + "; service ticket: " + serviceTicket); + } + + return element == null ? null : (CasAuthenticationToken) element.get(); + } + + 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); + } +} 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..c8abf77f94e --- /dev/null +++ b/cas/src/test/java/org/springframework/security/cas/authentication/SpringCacheBasedTicketCacheTests.java @@ -0,0 +1,66 @@ +/* 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.BeforeClass; +import org.junit.Test; +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(cacheManager.getCache("castickets")); + + 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(expected = IllegalArgumentException.class) + public void testStartupDetectsMissingCache() throws Exception { + new SpringCacheBasedTicketCache(null); + } +} 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 d52f5eff8ef..6f182f77e9e 100755 --- a/config/convert_schema.sh +++ b/config/convert_schema.sh @@ -1,11 +1,8 @@ -#! /bin/sh - -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..43f479bc481 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\\.1.*.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/HeadersBeanDefinitionParser.java b/config/src/main/java/org/springframework/security/config/http/HeadersBeanDefinitionParser.java new file mode 100644 index 00000000000..388cf53f13d --- /dev/null +++ b/config/src/main/java/org/springframework/security/config/http/HeadersBeanDefinitionParser.java @@ -0,0 +1,188 @@ +/* + * 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.config.RuntimeBeanReference; +import org.springframework.beans.factory.support.BeanDefinitionBuilder; +import org.springframework.beans.factory.support.ManagedList; +import org.springframework.beans.factory.xml.BeanDefinitionParser; +import org.springframework.beans.factory.xml.ParserContext; +import org.springframework.security.web.headers.HeadersFilter; +import org.springframework.security.web.headers.StaticHeaderFactory; +import org.springframework.security.web.headers.frameoptions.*; +import org.springframework.util.StringUtils; +import org.springframework.util.xml.DomUtils; +import org.w3c.dom.Element; + +import java.net.URI; +import java.net.URISyntaxException; +import java.util.List; +import java.util.regex.PatternSyntaxException; + +/** + * Parser for the {@code HeadersFilter}. + * + * @author Marten Deinum + * @since 3.2 + */ +public class HeadersBeanDefinitionParser 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_STRATEGY = "strategy"; + private static final String ATT_FROM_PARAMETER = "from-parameter"; + + private static final String ATT_NAME = "name"; + private static final String ATT_VALUE = "value"; + private static final String ATT_REF = "ref"; + + 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 CONTENT_TYPE_OPTIONS_HEADER = "X-Content-Type-Options"; + + private static final String ALLOW_FROM = "ALLOW-FROM"; + + private ManagedList headerFactories; + + public BeanDefinition parse(Element element, ParserContext parserContext) { + headerFactories = new ManagedList(); + BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(HeadersFilter.class); + + parseXssElement(element, parserContext); + parseFrameOptionsElement(element, parserContext); + parseContentTypeOptionsElement(element); + + parseHeaderElements(element); + + builder.addConstructorArgValue(headerFactories); + return builder.getBeanDefinition(); + } + + private void parseHeaderElements(Element element) { + List headerElts = DomUtils.getChildElementsByTagName(element, GENERIC_HEADER_ELEMENT); + for (Element headerElt : headerElts) { + String headerFactoryRef = headerElt.getAttribute(ATT_REF); + if (StringUtils.hasText(headerFactoryRef)) { + headerFactories.add(new RuntimeBeanReference(headerFactoryRef)); + } else { + BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(StaticHeaderFactory.class); + builder.addConstructorArgValue(headerElt.getAttribute(ATT_NAME)); + builder.addConstructorArgValue(headerElt.getAttribute(ATT_VALUE)); + headerFactories.add(builder.getBeanDefinition()); + } + } + } + + private void parseContentTypeOptionsElement(Element element) { + Element contentTypeElt = DomUtils.getChildElementByTagName(element, CONTENT_TYPE_ELEMENT); + if (contentTypeElt != null) { + BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(StaticHeaderFactory.class); + builder.addConstructorArgValue(CONTENT_TYPE_OPTIONS_HEADER); + builder.addConstructorArgValue("nosniff"); + headerFactories.add(builder.getBeanDefinition()); + } + } + + private void parseFrameOptionsElement(Element element, ParserContext parserContext) { + BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(FrameOptionsHeaderFactory.class); + + Element frameElt = DomUtils.getChildElementByTagName(element, FRAME_OPTIONS_ELEMENT); + if (frameElt != null) { + String header = getAttribute(frameElt, ATT_POLICY, "DENY"); + builder.addConstructorArgValue(header); + if (ALLOW_FROM.equals(header) ) { + String strategyRef = getAttribute(frameElt, ATT_REF, null); + String strategy = getAttribute(frameElt, ATT_STRATEGY, null); + + if (StringUtils.hasText(strategy) && StringUtils.hasText(strategyRef)) { + parserContext.getReaderContext().error("Only one of 'strategy' or 'strategy-ref' can be set.", + frameElt); + } else if (strategyRef != null) { + builder.addConstructorArgReference(strategyRef); + } else if (strategy != null) { + String value = getAttribute(frameElt, ATT_VALUE, null); + if (!StringUtils.hasText(value)) { + parserContext.getReaderContext().error("Strategy requires a 'value' to be set.", frameElt); + } + // static, whitelist, regexp + if ("static".equals(strategy)) { + try { + builder.addConstructorArgValue(new StaticAllowFromStrategy(new URI(value))); + } catch (URISyntaxException e) { + parserContext.getReaderContext().error( + "'value' attribute doesn't represent a valid URI.", frameElt, e); + } + } else { + RequestParameterAllowFromStrategy allowFromStrategy = null; + if ("whitelist".equals(strategy)) { + allowFromStrategy = new WhiteListedAllowFromStrategy( + StringUtils.commaDelimitedListToSet(value)); + } else { + try { + allowFromStrategy = new RegExpAllowFromStrategy(value); + } catch (PatternSyntaxException e) { + parserContext.getReaderContext().error( + "'value' attribute doesn't represent a valid regular expression.", frameElt, e); + } + } + String fromParameter = getAttribute(frameElt, ATT_FROM_PARAMETER, "from"); + allowFromStrategy.setParameterName(fromParameter); + builder.addConstructorArgValue(allowFromStrategy); + } + } else { + parserContext.getReaderContext().error("One of 'strategy' and 'strategy-ref' must be set.", + frameElt); + } + } + headerFactories.add(builder.getBeanDefinition()); + } + } + + private void parseXssElement(Element element, ParserContext parserContext) { + 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, enabled ? "true" : "false")); + + String value = enabled ? "1" : "0"; + if (enabled && block) { + value += "; mode=block"; + } else if (!enabled && block) { + parserContext.getReaderContext().error(" does not allow block=\"true\".", xssElt); + } + BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(StaticHeaderFactory.class); + builder.addConstructorArgValue(XSS_PROTECTION_HEADER); + builder.addConstructorArgValue(value); + headerFactories.add(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 a568307d4e7..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 @@ -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 HeadersBeanDefinitionParser().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, 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..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,6 +29,7 @@ enum SecurityFilters { CONCURRENT_SESSION_FILTER, /** {@link WebAsyncManagerIntegrationFilter} */ WEB_ASYNC_MANAGER_FILTER, + 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.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-3.2.rnc b/config/src/main/resources/org/springframework/security/config/spring-security-3.2.rnc new file mode 100644 index 00000000000..6864a0e37cd --- /dev/null +++ b/config/src/main/resources/org/springframework/security/config/spring-security-3.2.rnc @@ -0,0 +1,792 @@ +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? & 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? + +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 strategy to use when ALLOW-FROM is chosen. + attribute strategy {"static","whitelist","regexp"}? +frame-options.attlist &= + ## Specify the a reference to the custom AllowFromStrategy to use when ALLOW-FROM is chosen. + ref? +frame-options.attlist &= + ## Specify the a value to use for the chosen strategy. + attribute value {xsd:string}? +frame-options.attlist &= + ## Specify the request parameter to use for the origin when using a 'whitelist' or 'regexp' based strategy. Default is 'from'. + attribute from-parameter {xsd:string}? + + +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}? +header.attlist &= + ## Reference to a custom HeaderFactory implementation. + ref? + +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..43036b90489 --- /dev/null +++ b/config/src/main/resources/org/springframework/security/config/spring-security-3.2.xsd @@ -0,0 +1,2447 @@ + + + + + + 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. + + + + + + + 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 strategy to use when ALLOW-FROM is chosen. + + + + + + + + + + + + + Defines a reference to a Spring bean Id. + + + + + + Specify the a value to use for the chosen strategy. + + + + + + Specify the request parameter to use for the origin when using a 'whitelist' or 'regexp' + based strategy. Default is 'from'. + + + + + + + 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. + + + + + + Defines a reference to a Spring bean Id. + + + + + + + + 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. + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ 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 fe34d23d6e3..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,11 +5,11 @@ --> - - + + - ,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, @@ -42,4 +42,10 @@ + + + + + + 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/groovy/org/springframework/security/config/http/HttpHeadersConfigTests.groovy b/config/src/test/groovy/org/springframework/security/config/http/HttpHeadersConfigTests.groovy new file mode 100644 index 00000000000..062c1ede903 --- /dev/null +++ b/config/src/test/groovy/org/springframework/security/config/http/HttpHeadersConfigTests.groovy @@ -0,0 +1,298 @@ +/* + * 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.security.util.FieldUtils + +import javax.servlet.Filter +import javax.servlet.http.HttpServletRequest + +import org.springframework.beans.factory.parsing.BeanDefinitionParsingException +import org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException; +import org.springframework.mock.web.MockFilterChain +import org.springframework.mock.web.MockHttpServletRequest +import org.springframework.mock.web.MockHttpServletResponse +import org.springframework.security.config.BeanIds +import org.springframework.security.openid.OpenIDAuthenticationFilter +import org.springframework.security.openid.OpenIDAuthenticationToken +import org.springframework.security.openid.OpenIDConsumer +import org.springframework.security.openid.OpenIDConsumerException +import org.springframework.security.web.access.ExceptionTranslationFilter +import org.springframework.security.web.authentication.rememberme.AbstractRememberMeServices +import org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter +import org.springframework.security.web.headers.HeadersFilter + +/** + * + * @author Rob Winch + */ +class HttpHeadersConfigTests extends AbstractHttpConfigTests { + + def 'no http headers filter'() { + httpAutoConfig { + } + createAppContext() + + def hf = getFilter(HeadersFilter) + + expect: + !hf + } + + def 'http headers with empty headers'() { + httpAutoConfig { + 'headers'() + } + createAppContext() + + def hf = getFilter(HeadersFilter) + MockHttpServletResponse response = new MockHttpServletResponse(); + hf.doFilter(new MockHttpServletRequest(), response); + + expect: + hf + response.headers.isEmpty() + } + + def 'http headers content-type-options'() { + httpAutoConfig { + 'headers'() { + 'content-type-options'() + } + } + createAppContext() + + def hf = getFilter(HeadersFilter) + MockHttpServletResponse response = new MockHttpServletResponse(); + hf.doFilter(new MockHttpServletRequest(), response); + expect: + hf + response.headers == ['X-Content-Type-Options':'nosniff'] + } + + def 'http headers frame-options defaults to DENY'() { + httpAutoConfig { + 'headers'() { + 'frame-options'() + } + } + createAppContext() + + def hf = getFilter(HeadersFilter) + + expect: + hf + hf.headers == ['X-Frame-Options':'DENY'] + } + + def 'http headers frame-options DENY'() { + httpAutoConfig { + 'headers'() { + 'frame-options'(policy : 'DENY') + } + } + createAppContext() + + def hf = getFilter(HeadersFilter) + + expect: + hf + hf.headers == ['X-Frame-Options':'DENY'] + } + + def 'http headers frame-options SAMEORIGIN'() { + httpAutoConfig { + 'headers'() { + 'frame-options'(policy : 'SAMEORIGIN') + } + } + createAppContext() + + def hf = getFilter(HeadersFilter) + + expect: + hf + hf.headers == ['X-Frame-Options':'SAMEORIGIN'] + } + + def 'http headers frame-options ALLOW-FROM no origin reports error'() { + when: + httpAutoConfig { + 'headers'() { + 'frame-options'(policy : 'ALLOW-FROM') + } + } + createAppContext() + + def hf = getFilter(HeadersFilter) + + then: + BeanDefinitionParsingException e = thrown() + e.message.contains ' requires a non-empty string value for the origin attribute to be specified.' + } + + def 'http headers frame-options ALLOW-FROM spaces only origin reports error'() { + when: + httpAutoConfig { + 'headers'() { + 'frame-options'(policy : 'ALLOW-FROM', origin : ' ') + } + } + createAppContext() + + def hf = getFilter(HeadersFilter) + + then: + BeanDefinitionParsingException e = thrown() + e.message.contains ' requires a non-empty string value for the origin attribute to be specified.' + } + + def 'http headers frame-options ALLOW-FROM'() { + when: + httpAutoConfig { + 'headers'() { + 'frame-options'(policy : 'ALLOW-FROM', origin : 'https://example.com') + } + } + createAppContext() + + def hf = getFilter(HeadersFilter) + + then: + hf + hf.headers == ['X-Frame-Options':'ALLOW-FROM https://example.com'] + } + + def 'http headers header a=b'() { + when: + httpAutoConfig { + 'headers'() { + 'header'(name : 'a', value: 'b') + } + } + createAppContext() + + def hf = getFilter(HeadersFilter) + + then: + hf + hf.headers == ['a':'b'] + } + + def 'http headers header a=b and c=d'() { + when: + httpAutoConfig { + 'headers'() { + 'header'(name : 'a', value: 'b') + 'header'(name : 'c', value: 'd') + } + } + createAppContext() + + def hf = getFilter(HeadersFilter) + + then: + hf + hf.headers.sort() == ['a':'b', 'c':'d'].sort() + } + + def 'http headers header no name produces error'() { + when: + httpAutoConfig { + 'headers'() { + 'header'(value: 'b') + } + } + createAppContext() + + then: + thrown(XmlBeanDefinitionStoreException) + } + + def 'http headers header no value produces error'() { + when: + httpAutoConfig { + 'headers'() { + 'header'(name: 'a') + } + } + createAppContext() + + then: + thrown(XmlBeanDefinitionStoreException) + } + + def 'http headers xss-protection defaults'() { + when: + httpAutoConfig { + 'headers'() { + 'xss-protection'() + } + } + createAppContext() + + def hf = getFilter(HeadersFilter) + + then: + hf + hf.headers == ['X-XSS-Protection':'1; mode=block'] + } + + def 'http headers xss-protection enabled=true'() { + when: + httpAutoConfig { + 'headers'() { + 'xss-protection'(enabled:'true') + } + } + createAppContext() + + def hf = getFilter(HeadersFilter) + + then: + hf + hf.headers == ['X-XSS-Protection':'1; mode=block'] + } + + def 'http headers xss-protection enabled=false'() { + when: + httpAutoConfig { + 'headers'() { + 'xss-protection'(enabled:'false') + } + } + createAppContext() + + def hf = getFilter(HeadersFilter) + + then: + hf + hf.headers == ['X-XSS-Protection':'0'] + } + + def 'http headers xss-protection enabled=false and block=true produces error'() { + when: + httpAutoConfig { + 'headers'() { + 'xss-protection'(enabled:'false', block:'true') + } + } + createAppContext() + + def hf = getFilter(HeadersFilter) + + then: + BeanDefinitionParsingException e = thrown() + e.message.contains ' does not allow block="true".' + } +} 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/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/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..efd3741e8b7 --- /dev/null +++ b/core/src/main/java/org/springframework/security/core/userdetails/cache/SpringCacheBasedUserCache.java @@ -0,0 +1,68 @@ +package org.springframework.security.core.userdetails.cache; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +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} instances in a Spring defined {@link Cache}. + * + * @author Marten Deinum + * @since 3.2 + */ +public class SpringCacheBasedUserCache implements UserCache { + + + //~ Static fields/initializers ===================================================================================== + + private static final Log logger = LogFactory.getLog(SpringCacheBasedUserCache.class); + + //~ Instance fields ================================================================================================ + + private final Cache cache; + + //~ Constructors =================================================================================================== + + public SpringCacheBasedUserCache(Cache cache) throws Exception { + Assert.notNull(cache, "cache mandatory"); + this.cache = cache; + } + + //~ Methods ======================================================================================================== + + 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); + } +} 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 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..f77422a00d3 --- /dev/null +++ b/core/src/test/java/org/springframework/security/core/userdetails/cache/SpringCacheBasedUserCacheTests.java @@ -0,0 +1,83 @@ +/* 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(getCache()); + + // 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 { + new SpringCacheBasedUserCache(null); + } +} diff --git a/docs/manual/src/docbook/appendix-namespace.xml b/docs/manual/src/docbook/appendix-namespace.xml index 88efb40deb3..51afd65a495 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 @@ -208,6 +208,7 @@ Child Elements of <http> access-denied-handler + headers anonymous custom-filter expression-handler @@ -222,6 +223,7 @@ request-cache session-management x509 + headers
@@ -255,6 +257,170 @@ +
+ <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. + + 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><headers></literal> + + http + +
+
+ Child Elements of <literal><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-strategy</literal> + + Select the AllowFromStrategy to use when using the ALLOW-FROM policy. + + static Use a single static ALLOW-FROM value. The value can be set + through the value attribute. + + regexp Use a regelur expression to validate incoming requests and + if they are allowed. The regular expression can be set through the value + attribute. The request parameter used to retrieve the value to validate can be specified + using the from-parameter. + + whitelistA comma-seperated list containing the allowed domains. + The comma-seperated list can be set through the value + attribute. The request parameter used to retrieve the value to validate can be specified + using the from-parameter. + + + +
+
+ <literal>frame-options-ref</literal> + + Instead of using one of the predefined strategies it is also possible to use a custom AllowFromStrategy. + The reference to this bean can be specified through this ref attribute. + +
+
+ <literal>frame-options-value</literal> + The value to use when ALLOW-FROM is used a strategy. +
+
+ <literal>frame-options-from-parameter</literal> + + Specify the name of the request parameter to use when using regexp or whitelist for the ALLOW-FROM + strategy. + +
+
+
+ Parent Elements of <literal><frame-options></literal> + + 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> + + 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> + + 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. +
+
+ <literal>header-ref</literal> + Reference to a custom implementation of the HeaderFactory interface. +
+
+
+ Parent Elements of <literal><header></literal> + + headers + +
+
<literal><anonymous></literal> Adds an AnonymousAuthenticationFilter to the stack and an diff --git a/docs/manual/src/docbook/namespace-config.xml b/docs/manual/src/docbook/namespace-config.xml index 0759c12b8d2..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. @@ -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/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">