[[nsa-web]]
= Web Application Security

[[nsa-debug]]
== <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.

[[nsa-http]]
== <http>
If you use an `<http>` element within your application, a `FilterChainProxy` bean named "springSecurityFilterChain" is created and the configuration within the element is used to build a filter chain within
`FilterChainProxy`.
As of Spring Security 3.1, additional `http` elements can be used to add extra filter chains footnote:[See the pass:specialcharacters,macros[xref:servlet/configuration/xml-namespace.adoc#ns-web-xml[introductory chapter]] for how to set up the mapping from your `web.xml` ].
Some core filters are always created in a filter chain and others will be added to the stack depending on the attributes and child elements which are present.
The positions of the standard filters are fixed (see
xref:servlet/configuration/xml-namespace.adoc#filter-stack[the filter order table] in the namespace introduction), removing a common source of errors with previous versions of the framework when users had to configure the filter chain explicitly in the
`FilterChainProxy` bean.
You can, of course, still do this if you need full control of the configuration.


All filters which require a reference to the xref:servlet/authentication/architecture.adoc#servlet-authentication-authenticationmanager[`AuthenticationManager`] will be automatically injected with the internal instance created by the namespace configuration.

Each `<http>` namespace block always creates an `SecurityContextPersistenceFilter`, an `ExceptionTranslationFilter` and a `FilterSecurityInterceptor`.
These are fixed and cannot be replaced with alternatives.


[[nsa-http-attributes]]
=== <http> Attributes
The attributes on the `<http>` element control some of the properties on the core filters.

[[nsa-http-use-authorization-manager]]
* **use-authorization-manager**
Use AuthorizationManager API instead of SecurityMetadataSource (defaults to true)

[[nsa-http-authorization-manager-ref]]
* **use-authorization-manager**
Use this AuthorizationManager instead of deriving one from <intercept-url> elements

[[nsa-http-access-decision-manager-ref]]
* **access-decision-manager-ref**
Optional attribute specifying the ID of the `AccessDecisionManager` implementation which should be used for authorizing HTTP requests.
By default an `AffirmativeBased` implementation is used for with a `RoleVoter` and an `AuthenticatedVoter`.


[[nsa-http-authentication-manager-ref]]
* **authentication-manager-ref**
A reference to the `AuthenticationManager` used for the `FilterChain` created by this http element.

[[nsa-http-observation-registry-ref]]
* **observation-registry-ref**
A reference to the `ObservationRegistry` used for the `FilterChain` and related components

[[nsa-http-auto-config]]
* **auto-config**
Automatically registers a login form, BASIC authentication, logout services.
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".
Use of this attribute is not recommended.
Use explicit configuration elements instead to avoid confusion.


[[nsa-http-create-session]]
* **create-session**
Controls the eagerness with which an HTTP session is created by Spring Security classes.
Options include:

** `always` - Spring Security will proactively create a session if one does not exist.
** `ifRequired` - Spring Security will only create a session only if one is required (default value).
** `never` - Spring Security will never create a session, but will make use of one if the application does.
** `stateless` - Spring Security will not create a session and ignore the session for obtaining a Spring `Authentication`.

[[nsa-http-disable-url-rewriting]]
* **disable-url-rewriting**
Prevents session IDs from being appended to URLs in the application.
Clients must use cookies if this attribute is set to `true`.
The default is `true`.


[[nsa-http-entry-point-ref]]
* **entry-point-ref**
Normally the `AuthenticationEntryPoint` used will be set depending on which authentication mechanisms have been configured.
This attribute allows this behaviour to be overridden by defining a customized `AuthenticationEntryPoint` bean which will start the authentication process.


[[nsa-http-jaas-api-provision]]
* **jaas-api-provision**
If available, runs the request as the `Subject` acquired from the `JaasAuthenticationToken` which is implemented by adding a `JaasApiIntegrationFilter` bean to the stack.
Defaults to `false`.


[[nsa-http-name]]
* **name**
A bean identifier, used for referring to the bean elsewhere in the context.


[[nsa-http-once-per-request]]
* **once-per-request**
Corresponds to the `observeOncePerRequest` property of `FilterSecurityInterceptor`.
Defaults to `false`.


[[nsa-http-filter-all-dispatcher-types]]
* **filter-all-dispatcher-types**
Corresponds to the `shouldFilterAllDispatcherTypes` property of the `AuthorizationFilter`. Does not work when `use-authorization-manager=false`.
Defaults to `true`.


[[nsa-http-pattern]]
* **pattern**
Defining a pattern for the <<nsa-http,http>> element controls the requests which will be filtered through the list of filters which it defines.
The interpretation is dependent on the configured <<nsa-http-request-matcher,request-matcher>>.
If no pattern is defined, all requests will be matched, so the most specific patterns should be declared first.


[[nsa-http-realm]]
* **realm**
Sets the realm name used for basic authentication (if enabled).
Corresponds to the `realmName` property on `BasicAuthenticationEntryPoint`.

[[nsa-http-redirect-to-https-request-matcher-ref]]
* **redirect-to-https-request-matcher-ref**
A reference to a bean that implements `RequestMatcher` that will determine which requests must redirect to HTTPS.
This is helpful when, for example, wanting to run HTTP locally and HTTPS in production using a request header.

[[nsa-http-request-matcher]]
* **request-matcher**
Defines the `RequestMatcher` strategy used in the `FilterChainProxy` and the beans created by the `intercept-url` to match incoming requests.
Options are currently `mvc`, `ant`, `regex` and `ciRegex`, for Spring MVC, ant, regular-expression and case-insensitive regular-expression respectively.
A separate instance is created for each <<nsa-intercept-url,intercept-url>> element using its <<nsa-intercept-url-pattern,pattern>>, <<nsa-intercept-url-method,method>> and <<nsa-intercept-url-servlet-path,servlet-path>> attributes.
By default, paths are matched using a `PathPatternRequestMatcher`; however, regular expressions are matched using a `RegexRequestMatcher`.
See the Javadoc for these classes for more details on exactly how the matching is performed.
MVC is the default strategy if Spring MVC is present in the classpath, if not, Ant paths are used.


[[nsa-http-request-matcher-ref]]
* **request-matcher-ref**
A reference to a bean that implements `RequestMatcher` that will determine if this `FilterChain` should be used.
This is a more powerful alternative to <<nsa-http-pattern,pattern>>.


[[nsa-http-security]]
* **security**
A request pattern can be mapped to an empty filter chain, by setting this attribute to `none`.
No security will be applied and none of Spring Security's features will be available.

[[nsa-http-security-context-holder-strategy-ref]]
* **security-context-repository-ref**
Allows injection of a custom `SecurityContextHolderStrategy` into `SecurityContextPersistenceFilter`, `SecurityContextHolderFilter`, `BasicAuthenticationFilter`, `UsernamePasswordAuthenticationFilter`, `ExceptionTranslationFilter`, `LogoutFilter`, and others.

[[nsa-http-security-context-explicit-save]]
* **security-context-explicit-save**
If true, use `SecurityContextHolderFilter` instead of `SecurityContextPersistenceFilter`.
Requires explicit save


[[nsa-http-security-context-repository-ref]]
* **security-context-repository-ref**
Allows injection of a custom `SecurityContextRepository` into the `SecurityContextPersistenceFilter`.


[[nsa-http-servlet-api-provision]]
* **servlet-api-provision**
Provides versions of `HttpServletRequest` security methods such as `isUserInRole()` and `getPrincipal()` which are implemented by adding a `SecurityContextHolderAwareRequestFilter` bean to the stack.
Defaults to `true`.


[[nsa-http-use-expressions]]
* **use-expressions**
Enables EL-expressions in the `access` attribute, as described in the chapter on xref:servlet/authorization/authorize-http-requests.adoc#authorization-expressions[expression-based access-control].
The default value is true.


[[nsa-http-children]]
=== Child Elements of <http>
* <<nsa-access-denied-handler,access-denied-handler>>
* <<nsa-anonymous,anonymous>>
* <<nsa-cors,cors>>
* <<nsa-csrf,csrf>>
* <<nsa-custom-filter,custom-filter>>
* <<nsa-expression-handler,expression-handler>>
* <<nsa-form-login,form-login>>
* <<nsa-headers,headers>>
* <<nsa-http-basic,http-basic>>
* <<nsa-intercept-url,intercept-url>>
* <<nsa-jee,jee>>
* <<nsa-logout,logout>>
* <<nsa-oauth2-client,oauth2-client>>
* <<nsa-oauth2-login,oauth2-login>>
* <<nsa-oauth2-resource-server,oauth2-resource-server>>
* <<nsa-password-management,password-management>>
* <<nsa-port-mappings,port-mappings>>
* <<nsa-remember-me,remember-me>>
* <<nsa-request-cache,request-cache>>
* <<nsa-saml2-login,saml2-login>>
* <<nsa-saml2-logout,saml2-logout>>
* <<nsa-session-management,session-management>>
* <<nsa-x509,x509>>


[[nsa-access-denied-handler]]
== <access-denied-handler>
This element allows you to set the `errorPage` property for the default `AccessDeniedHandler` used by the `ExceptionTranslationFilter`, using the <<nsa-access-denied-handler-error-page,error-page>> attribute, or to supply your own implementation using the <<nsa-access-denied-handler-ref,ref>> attribute.
This is discussed in more detail in the section on the xref:servlet/architecture.adoc#servlet-exceptiontranslationfilter[ExceptionTranslationFilter].


[[nsa-access-denied-handler-parents]]
=== Parent Elements of <access-denied-handler>

* <<nsa-http,http>>

[[nsa-access-denied-handler-attributes]]
=== <access-denied-handler> Attributes


[[nsa-access-denied-handler-error-page]]
* **error-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.


[[nsa-access-denied-handler-ref]]
* **ref**
Defines a reference to a Spring bean of type `AccessDeniedHandler`.


[[nsa-cors]]
== <cors>
This element allows for configuring a `CorsFilter`.
Either a `CorsFilter` or a `CorsConfigurationSource` must be specified.
If Spring MVC is present, then it will attempt to look up its `CorsConfigurationSource`.

[[nsa-cors-attributes]]
=== <cors> Attributes
The attributes on the `<cors>` element control the headers element.

[[nsa-cors-ref]]
* **ref**
Optional attribute that specifies the bean name of a `CorsFilter`.

[[nsa-cors-configuration-source-ref]]
* **cors-configuration-source-ref**
Optional attribute that specifies the bean name of a `CorsConfigurationSource` to be injected into a `CorsFilter` created by the XML namespace.

[[nsa-cors-parents]]
=== Parent Elements of <cors>

* <<nsa-http,http>>

[[nsa-headers]]
== <headers>
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 <<nsa-header,header>> element.
Additional information, can be found in the xref:features/exploits/headers.adoc#headers[Security Headers] section of the reference.

** `Cache-Control`, `Pragma`, and `Expires` - Can be set using the <<nsa-cache-control,cache-control>> element.
This ensures that the browser does not cache your secured pages.
** `Strict-Transport-Security` - Can be set using the <<nsa-hsts,hsts>> element.
This ensures that the browser automatically requests HTTPS for future requests.
** `X-Frame-Options` - Can be set using the <<nsa-frame-options,frame-options>> element.
The https://en.wikipedia.org/wiki/Clickjacking#X-Frame-Options[X-Frame-Options] header can be used to prevent clickjacking attacks.
** `X-XSS-Protection` - Can be set using the <<nsa-xss-protection,xss-protection>> element.
The https://en.wikipedia.org/wiki/Cross-site_scripting[X-XSS-Protection ] header can be used by browser to do basic control.
** `X-Content-Type-Options` - Can be set using the <<nsa-content-type-options,content-type-options>> element.
The https://blogs.msdn.com/b/ie/archive/2008/09/02/ie8-security-part-vi-beta-2-update.aspx[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.
** `Public-Key-Pinning` or `Public-Key-Pinning-Report-Only` - Can be set using the <<nsa-hpkp,hpkp>> element.
This allows HTTPS websites to resist impersonation by attackers using mis-issued or otherwise fraudulent certificates.
** `Content-Security-Policy` or `Content-Security-Policy-Report-Only` - Can be set using the <<nsa-content-security-policy,content-security-policy>> element.
https://www.w3.org/TR/CSP2/[Content Security Policy (CSP)] is a mechanism that web applications can leverage to mitigate content injection vulnerabilities, such as cross-site scripting (XSS).
** `Referrer-Policy` - Can be set using the <<nsa-referrer-policy,referrer-policy>> element, https://www.w3.org/TR/referrer-policy/[Referrer-Policy] is a mechanism that web applications can leverage to manage the referrer field, which contains the last page the user was on.
** `Feature-Policy` - Can be set using the <<nsa-feature-policy,feature-policy>> element, https://wicg.github.io/feature-policy/[Feature-Policy] is a mechanism that allows web developers to selectively enable, disable, and modify the behavior of certain APIs and web features in the browser.
** `Cross-Origin-Opener-Policy` - Can be set using the <<nsa-cross-origin-opener-policy,cross-origin-opener-policy>> element, https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cross-Origin-Opener-Policy[Cross-Origin-Opener-Policy] is a mechanism that allows you to ensure a top-level document does not share a browsing context group with cross-origin documents.
** `Cross-Origin-Embedder-Policy` - Can be set using the <<nsa-cross-origin-embedder-policy,cross-origin-embedder-policy>> element, https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cross-Origin-Embedder-Policy[Cross-Origin-Embedder-Policy] is a mechanism that prevents a document from loading any cross-origin resources that don't explicitly grant the document permission.
** `Cross-Origin-Resource-Policy` - Can be set using the <<nsa-cross-origin-resource-policy,cross-origin-resource-policy>> element, https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cross-Origin-Resource-Policy[Cross-Origin-Resource-Policy] is a mechanism that conveys a desire that the browser blocks no-cors cross-origin/cross-site requests to the given resource.

[[nsa-headers-attributes]]
=== <headers> Attributes
The attributes on the `<headers>` element control the headers element.


[[nsa-headers-defaults-disabled]]
* **defaults-disabled**
Optional attribute that specifies to disable the default Spring Security's HTTP response headers.
The default is false (the default headers are included).

[[nsa-headers-disabled]]
* **disabled**
Optional attribute that specifies to disable Spring Security's HTTP response headers.
The default is false (the headers are enabled).


[[nsa-headers-parents]]
=== Parent Elements of <headers>

* <<nsa-http,http>>



[[nsa-headers-children]]
=== Child Elements of <headers>


* <<nsa-cache-control,cache-control>>
* <<nsa-content-security-policy,content-security-policy>>
* <<nsa-content-type-options,content-type-options>>
* <<nsa-cross-origin-embedder-policy,cross-origin-embedder-policy>>
* <<nsa-cross-origin-opener-policy,cross-origin-opener-policy>>
* <<nsa-cross-origin-resource-policy,cross-origin-resource-policy>>
* <<nsa-feature-policy,feature-policy>>
* <<nsa-frame-options,frame-options>>
* <<nsa-header,header>>
* <<nsa-hpkp,hpkp>>
* <<nsa-hsts,hsts>>
* <<nsa-permissions-policy,permission-policy>>
* <<nsa-referrer-policy,referrer-policy>>
* <<nsa-xss-protection,xss-protection>>



[[nsa-cache-control]]
== <cache-control>
Adds `Cache-Control`, `Pragma`, and `Expires` headers to ensure that the browser does not cache your secured pages.


[[nsa-cache-control-attributes]]
=== <cache-control> Attributes

[[nsa-cache-control-disabled]]
* **disabled**
Specifies if Cache Control should be disabled.
Default false.


[[nsa-cache-control-parents]]
=== Parent Elements of <cache-control>


* <<nsa-headers,headers>>



[[nsa-hsts]]
== <hsts>
When enabled adds the https://tools.ietf.org/html/rfc6797[Strict-Transport-Security] header to the response for any secure request.
This allows the server to instruct browsers to automatically use HTTPS for future requests.


[[nsa-hsts-attributes]]
=== <hsts> Attributes

[[nsa-hsts-disabled]]
* **disabled**
Specifies if Strict-Transport-Security should be disabled.
Default false.

[[nsa-hsts-include-subdomains]]
* **include-sub-domains**
Specifies if subdomains should be included.
Default true.


[[nsa-hsts-max-age-seconds]]
* **max-age-seconds**
Specifies the maximum amount of time the host should be considered a Known HSTS Host.
Default one year.


[[nsa-hsts-request-matcher-ref]]
* **request-matcher-ref**
The RequestMatcher instance to be used to determine if the header should be set.
Default is if HttpServletRequest.isSecure() is true.

[[nsa-hsts-preload]]
* **preload**
Specifies if preload should be included.
Default false.

[[nsa-hsts-parents]]
=== Parent Elements of <hsts>

* <<nsa-headers,headers>>



[[nsa-hpkp]]
== <hpkp>
When enabled adds the https://tools.ietf.org/html/rfc7469[Public Key Pinning Extension for HTTP] header to the response for any secure request.
This allows HTTPS websites to resist impersonation by attackers using mis-issued or otherwise fraudulent certificates.


[[nsa-hpkp-attributes]]
=== <hpkp> Attributes

[[nsa-hpkp-disabled]]
* **disabled**
Specifies if HTTP Public Key Pinning (HPKP) should be disabled.
Default true.

[[nsa-hpkp-include-subdomains]]
* **include-sub-domains**
Specifies if subdomains should be included.
Default false.


[[nsa-hpkp-max-age-seconds]]
* **max-age-seconds**
Sets the value for the max-age directive of the Public-Key-Pins header.
Default 60 days.


[[nsa-hpkp-report-only]]
* **report-only**
Specifies if the browser should only report pin validation failures.
Default true.


[[nsa-hpkp-report-uri]]
* **report-uri**
Specifies the URI to which the browser should report pin validation failures.


[[nsa-hpkp-parents]]
=== Parent Elements of <hpkp>

* <<nsa-headers,headers>>


[[nsa-pins]]
== <pins>
The list of pins


[[nsa-pins-children]]
=== Child Elements of <pins>

* <<nsa-pin,pin>>


[[nsa-pin]]
== <pin>
A pin is specified using the base64-encoded SPKI fingerprint as value and the cryptographic hash algorithm as attribute

[[nsa-pin-attributes]]
=== <pin> Attributes

[[nsa-pin-algorithm]]
* **algorithm**
The cryptographic hash algorithm.
Default is SHA256.


[[nsa-pin-parents]]
=== Parent Elements of <pin>

* <<nsa-pins,pins>>



[[nsa-content-security-policy]]
== <content-security-policy>
When enabled adds the https://www.w3.org/TR/CSP2/[Content Security Policy (CSP)] header to the response.
CSP is a mechanism that web applications can leverage to mitigate content injection vulnerabilities, such as cross-site scripting (XSS).

[[nsa-content-security-policy-attributes]]
=== <content-security-policy> Attributes

[[nsa-content-security-policy-policy-directives]]
* **policy-directives**
The security policy directive(s) for the Content-Security-Policy header or if report-only is set to true, then the Content-Security-Policy-Report-Only header is used.

[[nsa-content-security-policy-report-only]]
* **report-only**
Set to true, to enable the Content-Security-Policy-Report-Only header for reporting policy violations only.
Defaults to false.

[[nsa-content-security-policy-parents]]
=== Parent Elements of <content-security-policy>

* <<nsa-headers,headers>>



[[nsa-referrer-policy]]
== <referrer-policy>
When enabled adds the https://www.w3.org/TR/referrer-policy/[Referrer Policy] header to the response.

[[nsa-referrer-policy-attributes]]
=== <referrer-policy> Attributes

[[nsa-referrer-policy-policy]]
* **policy**
The policy for the Referrer-Policy header.
Default "no-referrer".

[[nsa-referrer-policy-parents]]
=== Parent Elements of <referrer-policy>

* <<nsa-headers,headers>>



[[nsa-feature-policy]]
== <feature-policy>
When enabled adds the https://wicg.github.io/feature-policy/[Feature Policy] header to the response.

[[nsa-feature-policy-attributes]]
=== <feature-policy> Attributes

[[nsa-feature-policy-policy-directives]]
* **policy-directives**
The security policy directive(s) for the Feature-Policy header.

[[nsa-feature-policy-parents]]
=== Parent Elements of <feature-policy>

* <<nsa-headers,headers>>



[[nsa-frame-options]]
== <frame-options>
When enabled adds the https://tools.ietf.org/html/draft-ietf-websec-x-frame-options[X-Frame-Options header] to the response, this allows newer browsers to do some security checks and prevent https://en.wikipedia.org/wiki/Clickjacking[clickjacking] attacks.


[[nsa-frame-options-attributes]]
=== <frame-options> Attributes

[[nsa-frame-options-disabled]]
* **disabled**
If disabled, the X-Frame-Options header will not be included.
Default false.

[[nsa-frame-options-policy]]
* **policy**
** `DENY` The page cannot be displayed in a frame, regardless of the site attempting to do so.
This is the default when frame-options-policy is specified.
** `SAMEORIGIN` The page can only be displayed in a frame on the same origin as the page itself

+

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.



[[nsa-frame-options-parents]]
=== Parent Elements of <frame-options>

* <<nsa-headers,headers>>

[[nsa-permissions-policy]]
== <permissions-policy>
Adds the https://w3c.github.io/webappsec-permissions-policy/[Permissions-Policy header] to the response.

[[nsa-permissions-policy-attributes]]
=== <permissions-policy> Attributes

[[nsa-permissions-policy-policy]]
* **policy**
The policy value to write for the `Permissions-Policy` header

[[nsa-permissions-policy-parents]]
=== Parent Elements of <permissions-policy>

* <<nsa-headers,headers>>

[[nsa-xss-protection]]
== <xss-protection>
Adds the https://blogs.msdn.com/b/ie/archive/2008/07/02/ie8-security-part-iv-the-xss-filter.aspx[X-XSS-Protection header] to the response to assist in protecting against https://en.wikipedia.org/wiki/Cross-site_scripting#Non-Persistent[reflected / Type-1 Cross-Site Scripting (XSS)] attacks.
This is in no-way a full protection to XSS attacks!


[[nsa-xss-protection-attributes]]
=== <xss-protection> Attributes


[[nsa-xss-protection-disabled]]
* **xss-protection-disabled**
Do not include the header for https://en.wikipedia.org/wiki/Cross-site_scripting#Non-Persistent[reflected / Type-1 Cross-Site Scripting (XSS)] protection.


[[nsa-xss-protection-header-value]]
* **xss-protection-header-value**
Explicitly set the value for https://en.wikipedia.org/wiki/Cross-site_scripting#Non-Persistent[reflected / Type-1 Cross-Site Scripting (XSS)] header.
One of: "0", "1", "1; mode=block". Defaults to "0".


[[nsa-xss-protection-parents]]
=== Parent Elements of <xss-protection>

* <<nsa-headers,headers>>



[[nsa-content-type-options]]
== <content-type-options>
Add the X-Content-Type-Options header with the value of nosniff to the response.
This https://blogs.msdn.com/b/ie/archive/2008/09/02/ie8-security-part-vi-beta-2-update.aspx[disables MIME-sniffing] for IE8+ and Chrome extensions.


[[nsa-content-type-options-attributes]]
=== <content-type-options> Attributes

[[nsa-content-type-options-disabled]]
* **disabled**
Specifies if Content Type Options should be disabled.
Default false.

[[nsa-content-type-options-parents]]
=== Parent Elements of <content-type-options>


* <<nsa-headers,headers>>



[[nsa-cross-origin-embedder-policy]]
==== <cross-origin-embedder-policy>
When enabled adds the https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cross-Origin-Embedder-Policy[Cross-Origin-Embedder-Policy] header to the response.


[[nsa-cross-origin-embedder-policy-attributes]]
===== <cross-origin-embedder-policy> Attributes

[[nsa-cross-origin-embedder-policy-policy]]
* **policy**
The policy for the `Cross-Origin-Embedder-Policy` header.

[[nsa-cross-origin-embedder-policy-parents]]
===== Parent Elements of <cross-origin-embedder-policy>


* <<nsa-headers,headers>>



[[nsa-cross-origin-opener-policy]]
==== <cross-origin-opener-policy>
When enabled adds the https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cross-Origin-Opener-Policy[Cross-Origin-Opener-Policy] header to the response.


[[nsa-cross-origin-opener-policy-attributes]]
===== <cross-origin-opener-policy> Attributes

[[nsa-cross-origin-opener-policy-policy]]
* **policy**
The policy for the `Cross-Origin-Opener-Policy` header.

[[nsa-cross-origin-opener-policy-parents]]
===== Parent Elements of <cross-origin-opener-policy>


* <<nsa-headers,headers>>



[[nsa-cross-origin-resource-policy]]
==== <cross-origin-resource-policy>
When enabled adds the https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cross-Origin-Resource-Policy[Cross-Origin-Resource-Policy] header to the response.


[[nsa-cross-origin-resource-policy-attributes]]
===== <cross-origin-resource-policy> Attributes

[[nsa-cross-origin-resource-policy-policy]]
* **policy**
The policy for the `Cross-Origin-Resource-Policy` header.

[[nsa-cross-origin-resource-policy-parents]]
===== Parent Elements of <cross-origin-resource-policy>


* <<nsa-headers,headers>>



[[nsa-header]]
== <header>
Add additional headers to the response, both the name and value need to be specified.


[[nsa-header-attributes]]
=== <header-attributes> Attributes


[[nsa-header-name]]
* **header-name**
The `name` of the header.


[[nsa-header-value]]
* **value**
The `value` of the header to add.


[[nsa-header-ref]]
* **ref**
Reference to a custom implementation of the `HeaderWriter` interface.


[[nsa-header-parents]]
=== Parent Elements of <header>


* <<nsa-headers,headers>>



[[nsa-anonymous]]
== <anonymous>
Adds an `AnonymousAuthenticationFilter` to the stack and an `AnonymousAuthenticationProvider`.
Required if you are using the `IS_AUTHENTICATED_ANONYMOUSLY` attribute.


[[nsa-anonymous-parents]]
=== Parent Elements of <anonymous>


* <<nsa-http,http>>



[[nsa-anonymous-attributes]]
=== <anonymous> Attributes


[[nsa-anonymous-enabled]]
* **enabled**
With the default namespace setup, the anonymous "authentication" facility is automatically enabled.
You can disable it using this property.


[[nsa-anonymous-granted-authority]]
* **granted-authority**
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`.


[[nsa-anonymous-key]]
* **key**
The key shared between the provider and filter.
This generally does not need to be set.
If unset, it will default to a secure randomly generated value.
This means setting this value can improve startup time when using the anonymous functionality since secure random values can take a while to be generated.


[[nsa-anonymous-username]]
* **username**
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`.


[[nsa-csrf]]
== <csrf>
This element will add https://en.wikipedia.org/wiki/Cross-site_request_forgery[Cross Site Request Forger (CSRF)] protection to the application.
It also updates the default RequestCache to only replay "GET" requests upon successful authentication.
Additional information can be found in the xref:features/exploits/csrf.adoc#csrf[Cross Site Request Forgery (CSRF)] section of the reference.


[[nsa-csrf-parents]]
=== Parent Elements of <csrf>


* <<nsa-http,http>>



[[nsa-csrf-attributes]]
=== <csrf> Attributes

[[nsa-csrf-disabled]]
* **disabled**
Optional attribute that specifies to disable Spring Security's CSRF protection.
The default is false (CSRF protection is enabled).
It is highly recommended to leave CSRF protection enabled.

[[nsa-csrf-token-repository-ref]]
* **token-repository-ref**
The CsrfTokenRepository to use.
The default is `HttpSessionCsrfTokenRepository`.

[[nsa-csrf-request-handler-ref]]
* **request-handler-ref**
The optional `CsrfTokenRequestHandler` to use. The default is `CsrfTokenRequestAttributeHandler`.

[[nsa-csrf-request-matcher-ref]]
* **request-matcher-ref**
The RequestMatcher instance to be used to determine if CSRF should be applied.
Default is any HTTP method except "GET", "TRACE", "HEAD", "OPTIONS".


[[nsa-custom-filter]]
== <custom-filter>
This element is used to add a filter to the filter chain.
It doesn't create any additional beans but is used to select a bean of type `jakarta.servlet.Filter` which is already defined in the application context and add that at a particular position in the filter chain maintained by Spring Security.
Full details can be found in the xref:servlet/configuration/xml-namespace.adoc#ns-custom-filters[ namespace chapter].


[[nsa-custom-filter-parents]]
=== Parent Elements of <custom-filter>


* <<nsa-http,http>>



[[nsa-custom-filter-attributes]]
=== <custom-filter> Attributes


[[nsa-custom-filter-after]]
* **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.


[[nsa-custom-filter-before]]
* **before**
The filter immediately before which the custom-filter should be placed in the chain


[[nsa-custom-filter-position]]
* **position**
The explicit position at which the custom-filter should be placed in the chain.
Use if you are replacing a standard filter.


[[nsa-custom-filter-ref]]
* **ref**
Defines a reference to a Spring bean that implements `Filter`.


[[nsa-expression-handler]]
== <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.


[[nsa-expression-handler-parents]]
=== Parent Elements of <expression-handler>


* xref:servlet/appendix/namespace/method-security.adoc#nsa-global-method-security[global-method-security]
* <<nsa-http,http>>
* xref:servlet/appendix/namespace/method-security.adoc#nsa-method-security[method-security]
* xref:servlet/appendix/namespace/websocket.adoc#nsa-websocket-message-broker[websocket-message-broker]



[[nsa-expression-handler-attributes]]
=== <expression-handler> Attributes


[[nsa-expression-handler-ref]]
* **ref**
Defines a reference to a Spring bean that implements `SecurityExpressionHandler`.


[[nsa-form-login]]
== <form-login>
Used to add an `UsernamePasswordAuthenticationFilter` to the filter stack and an `LoginUrlAuthenticationEntryPoint` to the application context to provide authentication on demand.
This will always take precedence over other namespace-created entry points.
If no attributes are supplied, a login page will be generated automatically at the URL "/login" footnote:[
This feature is really just provided for convenience and is not intended for production (where a view technology will have been chosen and can be used to render a customized login page).
The class `DefaultLoginPageGeneratingFilter` is responsible for rendering the login page and will provide login forms for both normal form login and/or OIDC if required.
] The behaviour can be customized using the <<nsa-form-login-attributes, `<form-login>` Attributes>>.


[[nsa-form-login-parents]]
=== Parent Elements of <form-login>


* <<nsa-http,http>>



[[nsa-form-login-attributes]]
=== <form-login> Attributes


[[nsa-form-login-always-use-default-target]]
* **always-use-default-target**
If set to `true`, the user will always start at the value given by <<nsa-form-login-default-target-url,default-target-url>>, regardless of how they arrived at the login page.
Maps to the `alwaysUseDefaultTargetUrl` property of `UsernamePasswordAuthenticationFilter`.
Default value is `false`.


[[nsa-form-login-authentication-details-source-ref]]
* **authentication-details-source-ref**
Reference to an `AuthenticationDetailsSource` which will be used by the authentication filter


[[nsa-form-login-authentication-failure-handler-ref]]
* **authentication-failure-handler-ref**
Can be used as an alternative to <<nsa-form-login-authentication-failure-url,authentication-failure-url>>, giving you full control over the navigation flow after an authentication failure.
The value should be the name of an `AuthenticationFailureHandler` bean in the application context.


[[nsa-form-login-authentication-failure-url]]
* **authentication-failure-url**
Maps to the `authenticationFailureUrl` property of `UsernamePasswordAuthenticationFilter`.
Defines the URL the browser will be redirected to on login failure.
Defaults to `/login?error`, which will be automatically handled by the automatic login page generator, re-rendering the login page with an error message.


[[nsa-form-login-authentication-success-handler-ref]]
* **authentication-success-handler-ref**
This can be used as an alternative to <<nsa-form-login-default-target-url,default-target-url>> and <<nsa-form-login-always-use-default-target,always-use-default-target>>, giving you full control over the navigation flow after a successful authentication.
The value should be the name of an `AuthenticationSuccessHandler` bean in the application context.
By default, an implementation of `SavedRequestAwareAuthenticationSuccessHandler` is used and injected with the <<nsa-form-login-default-target-url,default-target-url >>.


[[nsa-form-login-default-target-url]]
* **default-target-url**
Maps to the `defaultTargetUrl` property of `UsernamePasswordAuthenticationFilter`.
If not set, the default value is "/" (the application root).
A user will be taken to this URL after logging in, provided they were not asked to login while attempting to access a secured resource, when they will be taken to the originally requested URL.


[[nsa-form-login-login-page]]
* **login-page**
The URL that should be used to render the login page.
Maps to the `loginFormUrl` property of the `LoginUrlAuthenticationEntryPoint`.
Defaults to "/login".


[[nsa-form-login-login-processing-url]]
* **login-processing-url**
Maps to the `filterProcessesUrl` property of `UsernamePasswordAuthenticationFilter`.
The default value is "/login".


[[nsa-form-login-password-parameter]]
* **password-parameter**
The name of the request parameter which contains the password.
Defaults to "password".


[[nsa-form-login-username-parameter]]
* **username-parameter**
The name of the request parameter which contains the username.
Defaults to "username".

[[nsa-form-login-authentication-success-forward-url]]
* **authentication-success-forward-url**
Maps a `ForwardAuthenticationSuccessHandler` to `authenticationSuccessHandler` property of `UsernamePasswordAuthenticationFilter`.


[[nsa-form-login-authentication-failure-forward-url]]
* **authentication-failure-forward-url**
Maps a `ForwardAuthenticationFailureHandler` to `authenticationFailureHandler` property of `UsernamePasswordAuthenticationFilter`.


[[nsa-oauth2-login]]
== <oauth2-login>
The xref:servlet/oauth2/login/index.adoc#oauth2login[OAuth 2.0 Login] feature configures authentication support using an OAuth 2.0 and/or OpenID Connect 1.0 Provider.


[[nsa-oauth2-login-parents]]
=== Parent Elements of <oauth2-login>

* <<nsa-http,http>>

[[nsa-oauth2-login-attributes]]
=== <oauth2-login> Attributes


[[nsa-oauth2-login-client-registration-repository-ref]]
* **client-registration-repository-ref**
Reference to the `ClientRegistrationRepository`.


[[nsa-oauth2-login-authorized-client-repository-ref]]
* **authorized-client-repository-ref**
Reference to the `OAuth2AuthorizedClientRepository`.


[[nsa-oauth2-login-authorized-client-service-ref]]
* **authorized-client-service-ref**
Reference to the `OAuth2AuthorizedClientService`.


[[nsa-oauth2-login-authorization-request-repository-ref]]
* **authorization-request-repository-ref**
Reference to the `AuthorizationRequestRepository`.


[[nsa-oauth2-login-authorization-request-resolver-ref]]
* **authorization-request-resolver-ref**
Reference to the `OAuth2AuthorizationRequestResolver`.


[[nsa-oauth2-login-authorization-redirect-strategy-ref]]
* **authorization-redirect-strategy-ref**
Reference to the authorization `RedirectStrategy`.


[[nsa-oauth2-login-access-token-response-client-ref]]
* **access-token-response-client-ref**
Reference to the `OAuth2AccessTokenResponseClient`.


[[nsa-oauth2-login-user-authorities-mapper-ref]]
* **user-authorities-mapper-ref**
Reference to the `GrantedAuthoritiesMapper`.


[[nsa-oauth2-login-user-service-ref]]
* **user-service-ref**
Reference to the `OAuth2UserService`.


[[nsa-oauth2-login-oidc-user-service-ref]]
* **oidc-user-service-ref**
Reference to the OpenID Connect `OAuth2UserService`.


[[nsa-oauth2-login-login-processing-url]]
* **login-processing-url**
The URI where the filter processes authentication requests.


[[nsa-oauth2-login-login-page]]
* **login-page**
The URI to send users to login.


[[nsa-oauth2-login-authentication-success-handler-ref]]
* **authentication-success-handler-ref**
Reference to the `AuthenticationSuccessHandler`.


[[nsa-oauth2-login-authentication-failure-handler-ref]]
* **authentication-failure-handler-ref**
Reference to the `AuthenticationFailureHandler`.


[[nsa-oauth2-login-jwt-decoder-factory-ref]]
* **jwt-decoder-factory-ref**
Reference to the `JwtDecoderFactory` used by `OidcAuthorizationCodeAuthenticationProvider`.


[[nsa-oauth2-client]]
== <oauth2-client>
Configures xref:servlet/oauth2/client/index.adoc#oauth2client[OAuth 2.0 Client] support.


[[nsa-oauth2-client-parents]]
=== Parent Elements of <oauth2-client>

* <<nsa-http,http>>

[[nsa-oauth2-client-attributes]]
=== <oauth2-client> Attributes


[[nsa-oauth2-client-client-registration-repository-ref]]
* **client-registration-repository-ref**
Reference to the `ClientRegistrationRepository`.


[[nsa-oauth2-client-authorized-client-repository-ref]]
* **authorized-client-repository-ref**
Reference to the `OAuth2AuthorizedClientRepository`.


[[nsa-oauth2-client-authorized-client-service-ref]]
* **authorized-client-service-ref**
Reference to the `OAuth2AuthorizedClientService`.


[[nsa-oauth2-client-children]]
=== Child Elements of <oauth2-client>

* <<nsa-authorization-code-grant,authorization-code-grant>>


[[nsa-authorization-code-grant]]
== <authorization-code-grant>
Configures xref:servlet/oauth2/client/authorization-grants.adoc#oauth2Client-auth-grant-support[OAuth 2.0 Authorization Code Grant].


[[nsa-authorization-code-grant-parents]]
=== Parent Elements of <authorization-code-grant>

* <<nsa-oauth2-client,oauth2-client>>


[[nsa-authorization-code-grant-attributes]]
=== <authorization-code-grant> Attributes


[[nsa-authorization-code-grant-authorization-request-repository-ref]]
* **authorization-request-repository-ref**
Reference to the `AuthorizationRequestRepository`.


[[nsa-authorization-code-grant-authorization-redirect-strategy-ref]]
* **authorization-redirect-strategy-ref**
Reference to the authorization `RedirectStrategy`.


[[nsa-authorization-code-grant-authorization-request-resolver-ref]]
* **authorization-request-resolver-ref**
Reference to the `OAuth2AuthorizationRequestResolver`.


[[nsa-authorization-code-grant-access-token-response-client-ref]]
* **access-token-response-client-ref**
Reference to the `OAuth2AccessTokenResponseClient`.


[[nsa-client-registrations]]
== <client-registrations>
A container element for client(s) registered (xref:servlet/oauth2/client/index.adoc#oauth2Client-client-registration[ClientRegistration]) with an OAuth 2.0 or OpenID Connect 1.0 Provider.


[[nsa-client-registrations-children]]
=== Child Elements of <client-registrations>

* <<nsa-client-registration,client-registration>>
* <<nsa-provider,provider>>


[[nsa-client-registration]]
== <client-registration>
Represents a client registered with an OAuth 2.0 or OpenID Connect 1.0 Provider.


[[nsa-client-registration-parents]]
=== Parent Elements of <client-registration>

* <<nsa-client-registrations,client-registrations>>


[[nsa-client-registration-attributes]]
=== <client-registration> Attributes


[[nsa-client-registration-registration-id]]
* **registration-id**
The ID that uniquely identifies the `ClientRegistration`.


[[nsa-client-registration-client-id]]
* **client-id**
The client identifier.


[[nsa-client-registration-client-secret]]
* **client-secret**
The client secret.


[[nsa-client-registration-client-authentication-method]]
* **client-authentication-method**
The method used to authenticate the Client with the Provider.
The supported values are *client_secret_basic*, *client_secret_post*, *private_key_jwt*, *client_secret_jwt* and *none* https://tools.ietf.org/html/rfc6749#section-2.1[(public clients)].


[[nsa-client-registration-authorization-grant-type]]
* **authorization-grant-type**
The OAuth 2.0 Authorization Framework defines four https://tools.ietf.org/html/rfc6749#section-1.3[Authorization Grant] types.
The supported values are `authorization_code`, `client_credentials`, `password`, as well as, extension grant type `urn:ietf:params:oauth:grant-type:jwt-bearer`.


[[nsa-client-registration-redirect-uri]]
* **redirect-uri**
The client's registered redirect URI that the _Authorization Server_ redirects the end-user's user-agent to after the end-user has authenticated and authorized access to the client.


[[nsa-client-registration-scope]]
* **scope**
The scope(s) requested by the client during the Authorization Request flow, such as openid, email, or profile.


[[nsa-client-registration-client-name]]
* **client-name**
A descriptive name used for the client.
The name may be used in certain scenarios, such as when displaying the name of the client in the auto-generated login page.

[[nsa-client-registration-provider-id]]
* **provider-id**
A reference to the associated provider. May reference a `<provider>` element or use one of the common providers (google, github, facebook, okta).


[[nsa-provider]]
== <provider>
The configuration information for an OAuth 2.0 or OpenID Connect 1.0 Provider.


[[nsa-provider-parents]]
=== Parent Elements of <provider>

* <<nsa-client-registrations,client-registrations>>


[[nsa-provider-attributes]]
=== <provider> Attributes


[[nsa-provider-provider-id]]
* **provider-id**
The ID that uniquely identifies the provider.


[[nsa-provider-authorization-uri]]
* **authorization-uri**
The Authorization Endpoint URI for the Authorization Server.


[[nsa-provider-token-uri]]
* **token-uri**
The Token Endpoint URI for the Authorization Server.


[[nsa-provider-user-info-uri]]
* **user-info-uri**
The UserInfo Endpoint URI used to access the claims/attributes of the authenticated end-user.


[[nsa-provider-user-info-authentication-method]]
* **user-info-authentication-method**
The authentication method used when sending the access token to the UserInfo Endpoint.
The supported values are *header*, *form* and *query*.


[[nsa-provider-user-info-user-name-attribute]]
* **user-info-user-name-attribute**
The name of the attribute returned in the UserInfo Response that references the Name or Identifier of the end-user.


[[nsa-provider-jwk-set-uri]]
* **jwk-set-uri**
The URI used to retrieve the https://tools.ietf.org/html/rfc7517[JSON Web Key (JWK)] Set from the Authorization Server, which contains the cryptographic key(s) used to verify the https://tools.ietf.org/html/rfc7515[JSON Web Signature (JWS)] of the ID Token and optionally the UserInfo Response.


[[nsa-provider-issuer-uri]]
* **issuer-uri**
The URI used to initially configure a `ClientRegistration` using discovery of an OpenID Connect Provider's https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderConfig[Configuration endpoint] or an Authorization Server's https://tools.ietf.org/html/rfc8414#section-3[Metadata endpoint].

[[nsa-oauth2-resource-server]]
== <oauth2-resource-server>
Adds a `BearerTokenAuthenticationFilter`, `BearerTokenAuthenticationEntryPoint`, and `BearerTokenAccessDeniedHandler` to the configuration.
In addition, either `<jwt>` or `<opaque-token>` must be specified.

[[nsa-oauth2-resource-server-parents]]
=== Parents Elements of <oauth2-resource-server>

* <<nsa-http,http>>

[[nsa-oauth2-resource-server-children]]
=== Child Elements of <oauth2-resource-server>

* <<nsa-jwt,jwt>>
* <<nsa-opaque-token,opaque-token>>

[[nsa-oauth2-resource-server-attributes]]
=== <oauth2-resource-server> Attributes

[[nsa-oauth2-resource-server-authentication-manager-resolver-ref]]
* **authentication-manager-resolver-ref**
Reference to an `AuthenticationManagerResolver` which will resolve the `AuthenticationManager` at request time

[[nsa-oauth2-resource-server-bearer-token-resolver-ref]]
* **bearer-token-resolver-ref**
Reference to a `BearerTokenResolver` which will retrieve the bearer token from the request.
This cannot be used in conjunction with `authentication-converter-ref`

[[nsa-oauth2-resource-server-entry-point-ref]]
* **entry-point-ref**
Reference to a `AuthenticationEntryPoint` which will handle unauthorized requests

[[nsa-oauth2-resource-server-authentication-converter-ref]]
* **authentication-converter-ref**
Reference to a `AuthenticationConverter` which convert request to authentication.
This cannot be used in conjunction with `bearer-token-resolver-ref`

[[nsa-jwt]]
== <jwt>
Represents an OAuth 2.0 Resource Server that will authorize JWTs


[[nsa-jwt-parents]]
=== Parent Elements of <jwt>

* <<nsa-oauth2-resource-server,oauth2-resource-server>>


[[nsa-jwt-attributes]]
=== <jwt> Attributes

[[nsa-jwt-jwt-authentication-converter-ref]]
* **jwt-authentication-converter-ref**
Reference to a `Converter<Jwt, AbstractAuthenticationToken>`

[[nsa-jwt-decoder-ref]]
* **jwt-decoder-ref**
Reference to a `JwtDecoder`. This is a larger component that overrides `jwk-set-uri`

[[nsa-jwt-jwk-set-uri]]
* **jwk-set-uri**
The JWK Set Uri used to load signing verification keys from an OAuth 2.0 Authorization Server

[[nsa-opaque-token]]
== <opaque-token>
Represents an OAuth 2.0 Resource Server that will authorize opaque tokens

[[nsa-opaque-token-parents]]
=== Parent Elements of <opaque-token>

* <<nsa-oauth2-resource-server,oauth2-resource-server>>

[[nsa-opaque-token-attributes]]
=== <opaque-token> Attributes

[[nsa-opaque-token-introspector-ref]]
* **introspector-ref**
Reference to an `OpaqueTokenIntrospector`. This is a larger component that overrides `introspection-uri`, `client-id`, and `client-secret`.

[[nsa-opaque-token-introspection-uri]]
* **introspection-uri**
The Introspection Uri used to introspect the details of an opaque token. Should be accompanied with a `client-id` and `client-secret`.

[[nsa-opaque-token-client-id]]
* **client-id**
The Client Id to use for client authentication against the provided `introspection-uri`.

[[nsa-opaque-token-client-secret]]
* **client-secret**
The Client Secret to use for client authentication against the provided `introspection-uri`.

[[nsa-opaque-token-authentication-converter-ref]]
* **authentication-converter-ref**
Reference to an `OpaqueTokenAuthenticationConverter`. Responsible for converting successful introspection result into an `Authentication` instance.


[[nsa-relying-party-registrations]]
== <relying-party-registrations>
The container element for relying party(ies) registered (xref:servlet/saml2/login/overview.adoc#servlet-saml2login-relyingpartyregistration[ClientRegistration]) with a SAML 2.0 Identity Provider.

[[nsa-relying-party-registrations-attributes]]
=== <relying-party-registrations> Attributes

[[nsa-relying-party-registrations-id]]
* **id**
The ID that uniquely identifies the `RelyingPartyRegistrationRepository`.

[[nsa-relying-party-registrations-children]]
=== Child Elements of <relying-party-registrations>

* <<nsa-asserting-party,asserting-party>>
* <<nsa-relying-party-registration,relying-party-registration>>


[[nsa-relying-party-registration]]
== <relying-party-registration>
Represents a relying party registered with a SAML 2.0 Identity Provider


[[nsa-relying-party-registration-parents]]
=== Parent Elements of <relying-party-registration>

* <<nsa-relying-party-registrations,relying-party-registrations>>


[[nsa-relying-party-registration-attributes]]
=== <relying-party-registration> Attributes


[[nsa-relying-party-registration-registration-id]]
* **registration-id**
The ID that uniquely identifies the `RelyingPartyRegistration`.

[[nsa-relying-party-registration-metadata-location]]
* **metadata-location**
The asserting party metadata location.

[[nsa-relying-party-registration-entity-id]]
* **client-id**
The relying party's https://www.oasis-open.org/committees/download.php/51890/SAML%20MD%20simplified%20overview.pdf#2.9%20EntityDescriptor[EntityID].


[[nsa-relying-party-registration-assertion-consumer-service-location]]
* **assertion-consumer-service-location**
The AssertionConsumerService Location. Equivalent to the value found in `&lt;AssertionConsumerService Location="..."/&gt;` in the relying party's `&lt;SPSSODescriptor&gt;`.


[[nsa-relying-party-registration-assertion-consumer-service-binding]]
* **assertion-consumer-service-binding**
the AssertionConsumerService Binding. Equivalent to the value found in `&lt;AssertionConsumerService Binding="..."/&gt;` in the relying party's `&lt;SPSSODescriptor&gt;`.
The supported values are *POST* and *REDIRECT*.

[[nsa-relying-party-registration-single-logout-service-location]]
* **single-logout-service-location**
The SingleLogoutService Location. Equivalent to the value found in &lt;SingleLogoutService Location="..."/&gt; in the relying party's &lt;SPSSODescriptor&gt;.

[[nsa-relying-party-registration-single-logout-service-response-location]]
* **single-logout-service-response-location**
The SingleLogoutService ResponseLocation. Equivalent to the value found in &lt;SingleLogoutService ResponseLocation="..."/&gt; in the relying party's &lt;SPSSODescriptor&gt;.

[[nsa-relying-party-registration-single-logout-service-binding]]
* **single-logout-service-binding**
The SingleLogoutService Binding. Equivalent to the value found in &lt;SingleLogoutService Binding="..."/&gt; in the relying party's &lt;SPSSODescriptor&gt;.
The supported values are *POST* and *REDIRECT*.

[[nsa-relying-party-registration-asserting-party-id]]
* **asserting-party-id**
A reference to the associated asserting party. Must reference an `<asserting-party>` element.

[[nsa-relying-party-registration-children]]
=== Child Elements of <relying-party-registration>

* <<nsa-decryption-credential,decryption-credential>>
* <<nsa-signing-credential,signing-credential>>


[[nsa-decryption-credential]]
== <decryption-credential>
The decryption credentials associated with the relying party.


[[nsa-decryption-credential-parents]]
=== Parent Elements of <decryption-credential>

* <<nsa-relying-party-registration,relying-party-registration>>


[[nsa-decryption-credential-attributes]]
=== <decryption-credential> Attributes


[[nsa-decryption-credential-certificate-location]]
* **certificate-location**
The location to get the certificate

[[nsa-decryption-credential-private-key-location]]
* **private-key-location**
The location to get the Relying Party's private key


[[nsa-signing-credential]]
== <signing-credential>
The signing credentials associated with the relying party.


[[nsa-signing-credential-parents]]
=== Parent Elements of <verification-credential>

* <<nsa-relying-party-registration,relying-party-registration>>


[[nsa-signing-credential-attributes]]
=== <verification-credential> Attributes


[[nsa-signing-credential-certificate-location]]
* **certificate-location**
The location to get this certificate

[[nsa-signing-credential-private-key-location]]
* **private-key-location**
The location to get the Relying Party's private key



[[nsa-asserting-party]]
== <asserting-party>
The configuration information for a SAML 2.0 Asserting Party.


[[nsa-asserting-party-parents]]
=== Parent Elements of <asserting-party>

* <<nsa-relying-party-registrations,relying-party-registrations>>


[[nsa-asserting-party-attributes]]
=== <asserting-party> Attributes


[[nsa-asserting-party-asserting-party-id]]
* **asserting-party-id**
The ID that uniquely identifies the asserting party.


[[nsa-asserting-party-entity-id]]
* **entity-id**
The EntityID of the Asserting Party


[[nsa-asserting-party-want-authn-requests-signed]]
* **want-authn-requests-signed**
The `WantAuthnRequestsSigned` setting, indicating the asserting party's preference that relying parties should sign the `AuthnRequest` before sending.


[[nsa-asserting-party-single-sign-on-service-location]]
* **single-sign-on-service-location**
The https://www.oasis-open.org/committees/download.php/51890/SAML%20MD%20simplified%20overview.pdf#2.5%20Endpoint[SingleSignOnService] Location.


[[nsa-asserting-party-single-sign-on-service-binding]]
* **single-sign-on-service-binding**
The https://www.oasis-open.org/committees/download.php/51890/SAML%20MD%20simplified%20overview.pdf#2.5%20Endpoint[SingleSignOnService] Binding.
The supported values are *POST* and *REDIRECT*.


[[nsa-asserting-party-signing-algorithms]]
* **signing-algorithms**
The list of `org.opensaml.saml.ext.saml2alg.SigningMethod` Algorithms for this asserting party, in preference order.


[[nsa-asserting-party-single-logout-service-location]]
* **single-logout-service-location**
The SingleLogoutService Location. Equivalent to the value found in &lt;SingleLogoutService Location="..."/&gt; in the asserting party's &lt;IDPSSODescriptor&gt;.


[[nsa-asserting-party-single-logout-service-response-location]]
* **single-logout-service-response-location**
The SingleLogoutService ResponseLocation. Equivalent to the value found in &lt;SingleLogoutService ResponseLocation="..."/&gt; in the asserting party's &lt;IDPSSODescriptor&gt;.


[[nsa-asserting-party-single-logout-service-binding]]
* **single-logout-service-binding**
The SingleLogoutService Binding. Equivalent to the value found in &lt;SingleLogoutService Binding="..."/&gt; in the asserting party's &lt;IDPSSODescriptor&gt;.
The supported values are *POST* and *REDIRECT*.


[[nsa-asserting-party-children]]
=== Child Elements of <asserting-party>

* <<nsa-encryption-credential,encryption-credential>>
* <<nsa-verification-credential,verification-credential>>


[[nsa-encryption-credential]]
== <encryption-credential>
The encryption credentials associated with the asserting party.


[[nsa-encryption-credential-parents]]
=== Parent Elements of <encryption-credential>

* <<nsa-asserting-party,asserting-party>>


[[nsa-encryption-credential-attributes]]
=== <encryption-credential> Attributes


[[nsa-encryption-credential-certificate-location]]
* **certificate-location**
The location to get the certificate

[[nsa-encryption-credential-private-key-location]]
* **private-key-location**
The location to get the Relying Party's private key


[[nsa-verification-credential]]
== <verification-credential>
The verification credentials associated with the asserting party.


[[nsa-verification-credential-parents]]
=== Parent Elements of <verification-credential>

* <<nsa-asserting-party,asserting-party>>


[[nsa-verification-credential-attributes]]
=== <verification-credential> Attributes


[[nsa-verification-credential-certificate-location]]
* **certificate-location**
The location to get this certificate

[[nsa-verification-credential-private-key-location]]
* **private-key-location**
The location to get the Relying Party's private key



[[nsa-http-basic]]
== <http-basic>
Adds a `BasicAuthenticationFilter` and `BasicAuthenticationEntryPoint` to the configuration.
The latter will only be used as the configuration entry point if form-based login is not enabled.


[[nsa-http-basic-parents]]
=== Parent Elements of <http-basic>


* <<nsa-http,http>>



[[nsa-http-basic-attributes]]
=== <http-basic> Attributes


[[nsa-http-basic-authentication-details-source-ref]]
* **authentication-details-source-ref**
Reference to an `AuthenticationDetailsSource` which will be used by the authentication filter


[[nsa-http-basic-entry-point-ref]]
* **entry-point-ref**
Sets the `AuthenticationEntryPoint` which is used by the `BasicAuthenticationFilter`.


[[nsa-http-firewall]]
== <http-firewall> Element
This is a top-level element which can be used to inject a custom implementation of `HttpFirewall` into the `FilterChainProxy` created by the namespace.
The default implementation should be suitable for most applications.


[[nsa-http-firewall-attributes]]
=== <http-firewall> Attributes


[[nsa-http-firewall-ref]]
* **ref**
Defines a reference to a Spring bean that implements `HttpFirewall`.


[[nsa-intercept-url]]
== <intercept-url>
This element is used to define the set of URL patterns that the application is interested in and to configure how they should be handled.
It is used to construct the `FilterInvocationSecurityMetadataSource` used by the `FilterSecurityInterceptor`.
It is also responsible for configuring a `ChannelProcessingFilter` if particular URLs need to be accessed by HTTPS, for example.
When matching the specified patterns against an incoming request, the matching is done in the order in which the elements are declared.
So the most specific patterns should come first and the most general should come last.


[[nsa-intercept-url-parents]]
=== Parent Elements of <intercept-url>


* <<nsa-filter-security-metadata-source,filter-security-metadata-source>>
* <<nsa-http,http>>



[[nsa-intercept-url-attributes]]
=== <intercept-url> Attributes


[[nsa-intercept-url-access]]
* **access**
Lists the access attributes which will be stored in the `FilterInvocationSecurityMetadataSource` for the defined URL pattern/method combination.
This should be a comma-separated list of the security configuration attributes (such as role names).


[[nsa-intercept-url-method]]
* **method**
The HTTP Method which will be used in combination with the pattern and servlet path (optional) to match an incoming request.
If omitted, any method will match.
If an identical pattern is specified with and without a method, the method-specific match will take precedence.


[[nsa-intercept-url-pattern]]
* **pattern**
The pattern which defines the URL path.
The content will depend on the `request-matcher` attribute from the containing http element, so will default to MVC matcher if Spring MVC is in the classpath.


[[nsa-intercept-url-request-matcher-ref]]
* **request-matcher-ref**
A reference to a `RequestMatcher` that will be used to determine if this `<intercept-url>` is used.


[[nsa-intercept-url-requires-channel]]
* **requires-channel**
Can be "http" or "https" depending on whether a particular URL pattern should be accessed over HTTP or HTTPS respectively.
Alternatively the value "any" can be used when there is no preference.
If this attribute is present on any `<intercept-url>` element, then a `ChannelProcessingFilter` will be added to the filter stack and its additional dependencies added to the application context.

If a `<port-mappings>` configuration is added, this will be used to by the `SecureChannelProcessor` and `InsecureChannelProcessor` beans to determine the ports used for redirecting to HTTP/HTTPS.

NOTE: This property is invalid for <<nsa-filter-security-metadata-source,filter-security-metadata-source>>

[[nsa-intercept-url-servlet-path]]
* **servlet-path**
The servlet path which will be used in combination with the pattern and HTTP method to match an incoming request.
This attribute is only applicable when <<nsa-http-request-matcher,request-matcher>> is 'mvc'.
In addition, the value is only required in the following 2 use cases: 1) There are 2 or more `HttpServlet` 's registered in the `ServletContext` that have mappings starting with `'/'` and are different; 2) The pattern starts with the same value of a registered `HttpServlet` path, excluding the default (root) `HttpServlet` `'/'`.

NOTE: This property is invalid for <<nsa-filter-security-metadata-source,filter-security-metadata-source>>


[[nsa-jee]]
== <jee>
Adds a J2eePreAuthenticatedProcessingFilter to the filter chain to provide integration with container authentication.


[[nsa-jee-parents]]
=== Parent Elements of <jee>


* <<nsa-http,http>>



[[nsa-jee-attributes]]
=== <jee> Attributes


[[nsa-jee-mappable-roles]]
* **mappable-roles**
A comma-separate list of roles to look for in the incoming HttpServletRequest.


[[nsa-jee-user-service-ref]]
* **user-service-ref**
A reference to a user-service (or UserDetailsService bean) Id


[[nsa-logout]]
== <logout>
Adds a `LogoutFilter` to the filter stack.
This is configured with a `SecurityContextLogoutHandler`.


[[nsa-logout-parents]]
=== Parent Elements of <logout>


* <<nsa-http,http>>



[[nsa-logout-attributes]]
=== <logout> Attributes


[[nsa-logout-delete-cookies]]
* **delete-cookies**
A comma-separated list of the names of cookies which should be deleted when the user logs out.


[[nsa-logout-invalidate-session]]
* **invalidate-session**
Maps to the `invalidateHttpSession` of the `SecurityContextLogoutHandler`.
Defaults to "true", so the session will be invalidated on logout.


[[nsa-logout-logout-success-url]]
* **logout-success-url**
The destination URL which the user will be taken to after logging out.
Defaults to <form-login-login-page>/?logout (i.e. /login?logout)

+

Setting this attribute will inject the `SessionManagementFilter` with a `SimpleRedirectInvalidSessionStrategy` configured with the attribute value.
When an invalid session ID is submitted, the strategy will be invoked, redirecting to the configured URL.


[[nsa-logout-logout-url]]
* **logout-url**
The URL which will cause a logout (i.e. which will be processed by the filter).
Defaults to "/logout".


[[nsa-logout-success-handler-ref]]
* **success-handler-ref**
May be used to supply an instance of `LogoutSuccessHandler` which will be invoked to control the navigation after logging out.


[[nsa-saml2-login]]
== <saml2-login>
The xref:servlet/saml2/login/index.adoc#servlet-saml2login[SAML 2.0 Login] feature configures authentication support using an SAML 2.0 Service Provider.


[[nsa-saml2-login-parents]]
=== Parent Elements of <saml2-login>

* <<nsa-http,http>>

[[nsa-saml2-login-attributes]]
=== <saml2-login> Attributes


[[nsa-saml2-login-relying-party-registration-repository-ref]]
* **relying-party-registration-repository-ref**
Reference to the `RelyingPartyRegistrationRepository`.


[[nsa-saml2-login-authentication-request-repository-ref]]
* **authentication-request-repository-ref**
Reference to the `Saml2AuthenticationRequestRepository`.


[[nsa-saml2-login-authentication-request-resolver-ref]]
* **authentication-request-context-resolver-ref**
Reference to the `Saml2AuthenticationRequestResolver`.


[[nsa-saml2-login-authentication-converter-ref]]
* **authentication-converter-ref**
Reference to the `AuthenticationConverter`.


[[nsa-saml2-login-login-processing-url]]
* **login-processing-url**
The URI where the filter processes authentication requests.


[[nsa-saml2-login-login-page]]
* **login-page**
The URI to send users to login.


[[nsa-saml2-login-authentication-success-handler-ref]]
* **authentication-success-handler-ref**
Reference to the `AuthenticationSuccessHandler`.


[[nsa-saml2-login-authentication-failure-handler-ref]]
* **authentication-failure-handler-ref**
Reference to the `AuthenticationFailureHandler`.


[[nsa-saml2-login-authentication-manager-ref]]
* **authentication-manager-ref**
Reference to the `AuthenticationManager`.


[[nsa-saml2-logout]]
== <saml2-logout>
The xref:servlet/saml2/logout.adoc#servlet-saml2login-logout[SAML 2.0 Single Logout] feature configures support for RP- and AP-initiated SAML 2.0 Single Logout.


[[nsa-saml2-logout-parents]]
=== Parent Elements of <saml2-logout>

* <<nsa-http,http>>

[[nsa-saml2-logout-attributes]]
=== <saml2-logout> Attributes


[[nsa-saml2-logout-logout-url]]
* **logout-url**
The URL by which the relying or asserting party can trigger logout.


[[nsa-saml2-logout-logout-request-url]]
* **logout-request-url**
The URL by which the asserting party can send a SAML 2.0 Logout Request.


[[nsa-saml2-logout-logout-response-url]]
* **logout-response-url**
The URL by which the asserting party can send a SAML 2.0 Logout Response.


[[nsa-saml2-logout-relying-party-registration-repository-ref]]
* **relying-party-registration-repository-ref**
Reference to the `RelyingPartyRegistrationRepository`.


[[nsa-saml2-logout-logout-request-validator-ref]]
* **logout-request-validator-ref**
Reference to the `Saml2LogoutRequestValidator`.


[[nsa-saml2-logout-logout-request-resolver-ref]]
* **logout-request-resolver-ref**
Reference to the `Saml2LogoutRequestResolver`.


[[nsa-saml2-logout-logout-request-repository-ref]]
* **logout-request-repository-ref**
Reference to the `Saml2LogoutRequestRepository`.


[[nsa-saml2-logout-logout-response-validator-ref]]
* **logout-response-validator-ref**
Reference to the `Saml2LogoutResponseValidator`.


[[nsa-saml2-logout-logout-response-resolver-ref]]
* **logout-response-resolver-ref**
Reference to the `Saml2LogoutResponseResolver`.



[[nsa-password-management]]
== <password-management>
This element configures password management.

[[nsa-password-management-parents]]
=== Parent Elements of <password-management>

* <<nsa-http,http>>

[[nsa-password-management-attributes]]
=== <password-management> Attributes

[[nsa-password-management-change-password-page]]
* **change-password-page**
The change password page. Defaults to "/change-password".

[[nsa-port-mappings]]
== <port-mappings>
By default, an instance of `PortMapperImpl` will be added to the configuration for use in redirecting to secure and insecure URLs.
This element can optionally be used to override the default mappings which that class defines.
Each child `<port-mapping>` element defines a pair of HTTP:HTTPS ports.
The default mappings are 80:443 and 8080:8443.
An example of overriding these can be found in xref:servlet/exploits/http.adoc#servlet-http-redirect[Redirect to HTTPS].


[[nsa-port-mappings-parents]]
=== Parent Elements of <port-mappings>


* <<nsa-http,http>>



[[nsa-port-mappings-children]]
=== Child Elements of <port-mappings>


* <<nsa-port-mapping,port-mapping>>



[[nsa-port-mapping]]
== <port-mapping>
Provides a method to map http ports to https ports when forcing a redirect.


[[nsa-port-mapping-parents]]
=== Parent Elements of <port-mapping>


* <<nsa-port-mappings,port-mappings>>



[[nsa-port-mapping-attributes]]
=== <port-mapping> Attributes


[[nsa-port-mapping-http]]
* **http**
The http port to use.


[[nsa-port-mapping-https]]
* **https**
The https port to use.


[[nsa-remember-me]]
== <remember-me>
Adds the `RememberMeAuthenticationFilter` to the stack.
This in turn will be configured with either a `TokenBasedRememberMeServices`, a `PersistentTokenBasedRememberMeServices` or a user-specified bean implementing `RememberMeServices` depending on the attribute settings.


[[nsa-remember-me-parents]]
=== Parent Elements of <remember-me>


* <<nsa-http,http>>



[[nsa-remember-me-attributes]]
=== <remember-me> Attributes


[[nsa-remember-me-authentication-success-handler-ref]]
* **authentication-success-handler-ref**
Sets the `authenticationSuccessHandler` property on the `RememberMeAuthenticationFilter` if custom navigation is required.
The value should be the name of a `AuthenticationSuccessHandler` bean in the application context.


[[nsa-remember-me-data-source-ref]]
* **data-source-ref**
A reference to a `DataSource` bean.
If this is set, `PersistentTokenBasedRememberMeServices` will be used and configured with a `JdbcTokenRepositoryImpl` instance.


[[nsa-remember-me-remember-me-parameter]]
* **remember-me-parameter**
The name of the request parameter which toggles remember-me authentication.
Defaults to "remember-me".
Maps to the "parameter" property of `AbstractRememberMeServices`.


[[nsa-remember-me-remember-me-cookie]]
* **remember-me-cookie**
The name of cookie which store the token for remember-me authentication.
Defaults to "remember-me".
Maps to the "cookieName" property of `AbstractRememberMeServices`.


[[nsa-remember-me-key]]
* **key**
Maps to the "key" property of `AbstractRememberMeServices`.
Should be set to a unique value to ensure that remember-me cookies are only valid within the one application footnote:[
This doesn't affect the use of `PersistentTokenBasedRememberMeServices`, where the tokens are stored on the server side.
].
If this is not set a secure random value will be generated.
Since generating secure random values can take a while, setting this value explicitly can help improve startup times when using the remember-me functionality.


[[nsa-remember-me-services-alias]]
* **services-alias**
Exports the internally defined `RememberMeServices` as a bean alias, allowing it to be used by other beans in the application context.


[[nsa-remember-me-services-ref]]
* **services-ref**
Allows complete control of the `RememberMeServices` implementation that will be used by the filter.
The value should be the `id` of a bean in the application context which implements this interface.
Should also implement `LogoutHandler` if a logout filter is in use.


[[nsa-remember-me-token-repository-ref]]
* **token-repository-ref**
Configures a `PersistentTokenBasedRememberMeServices` but allows the use of a custom `PersistentTokenRepository` bean.


[[nsa-remember-me-token-validity-seconds]]
* **token-validity-seconds**
Maps to the `tokenValiditySeconds` property of `AbstractRememberMeServices`.
Specifies the period in seconds for which the remember-me cookie should be valid.
By default it will be valid for 14 days.


[[nsa-remember-me-use-secure-cookie]]
* **use-secure-cookie**
It is recommended that remember-me cookies are only submitted over HTTPS and thus should be flagged as "secure".
By default, a secure cookie will be used if the connection over which the login request is made is secure (as it should be).
If you set this property to `false`, secure cookies will not be used.
Setting it to `true` will always set the secure flag on the cookie.
This attribute maps to the `useSecureCookie` property of `AbstractRememberMeServices`.


[[nsa-remember-me-user-service-ref]]
* **user-service-ref**
The remember-me services implementations require access to a `UserDetailsService`, so there has to be one defined in the application context.
If there is only one, it will be selected and used automatically by the namespace configuration.
If there are multiple instances, you can specify a bean `id` explicitly using this attribute.


[[nsa-request-cache]]
== <request-cache> Element
Sets the `RequestCache` instance which will be used by the `ExceptionTranslationFilter` to store request information before invoking an `AuthenticationEntryPoint`.


[[nsa-request-cache-parents]]
=== Parent Elements of <request-cache>

* <<nsa-http,http>>

[[nsa-request-cache-attributes]]
=== <request-cache> Attributes


[[nsa-request-cache-ref]]
* **ref**
Defines a reference to a Spring bean that is a `RequestCache`.


[[nsa-session-management]]
== <session-management>
Session-management related functionality is implemented by the addition of a `SessionManagementFilter` to the filter stack.


[[nsa-session-management-parents]]
=== Parent Elements of <session-management>


* <<nsa-http,http>>



[[nsa-session-management-attributes]]
=== <session-management> Attributes


[[nsa-session-management-authentication-strategy-explicit-invocation]]
* **authentication-strategy-explicit-invocation**
Setting this attribute to true will mean that `SessionManagementFilter` will not be injected and explicit invocation of SessionAuthenticationStrategy is required.

[[nsa-session-management-invalid-session-url]]
* **invalid-session-url**
Setting this attribute will inject the `SessionManagementFilter` with a `SimpleRedirectInvalidSessionStrategy` configured with the attribute value.
When an invalid session ID is submitted, the strategy will be invoked, redirecting to the configured URL.

[[nsa-session-management-invalid-session-strategy-ref]]
* **invalid-session-url**
Allows injection of the InvalidSessionStrategy instance used by the SessionManagementFilter.
Use either this or the `invalid-session-url` attribute but not both.

[[nsa-session-management-session-authentication-error-url]]
* **session-authentication-error-url**
Defines the URL of the error page which should be shown when the SessionAuthenticationStrategy raises an exception.
If not set, an unauthorized (401) 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.


[[nsa-session-management-session-authentication-strategy-ref]]
* **session-authentication-strategy-ref**
Allows injection of the SessionAuthenticationStrategy instance used by the SessionManagementFilter


[[nsa-session-management-session-fixation-protection]]
* **session-fixation-protection**
Indicates how session fixation protection will be applied when a user authenticates.
If set to "none", no protection will be applied.
"newSession" will create a new empty session, with only Spring Security-related attributes migrated.
"migrateSession" will create a new session and copy all session attributes to the new session.
In Servlet 3.1 (Java EE 7) and newer containers, specifying "changeSessionId" will keep the existing session and use the container-supplied session fixation protection (HttpServletRequest#changeSessionId()).
Defaults to "changeSessionId" in Servlet 3.1 and newer containers, "migrateSession" in older containers.
Throws an exception if "changeSessionId" is used in older containers.

+

If session fixation protection is enabled, the `SessionManagementFilter` is injected with an appropriately configured `DefaultSessionAuthenticationStrategy`.
See the Javadoc for this class for more details.


[[nsa-session-management-children]]
=== Child Elements of <session-management>


* <<nsa-concurrency-control,concurrency-control>>



[[nsa-concurrency-control]]
== <concurrency-control>
Adds support for concurrent session control, allowing limits to be placed on the number of active sessions a user can have.
A `ConcurrentSessionFilter` will be created, and a `ConcurrentSessionControlAuthenticationStrategy` will be used with the `SessionManagementFilter`.
If a `form-login` element has been declared, the strategy object will also be injected into the created authentication filter.
An instance of `SessionRegistry` (a `SessionRegistryImpl` instance unless the user wishes to use a custom bean) will be created for use by the strategy.


[[nsa-concurrency-control-parents]]
=== Parent Elements of <concurrency-control>


* <<nsa-session-management,session-management>>



[[nsa-concurrency-control-attributes]]
=== <concurrency-control> Attributes


[[nsa-concurrency-control-error-if-maximum-exceeded]]
* **error-if-maximum-exceeded**
If set to "true" a `SessionAuthenticationException` will be raised when a user attempts to exceed the maximum allowed number of sessions.
The default behaviour is to expire the original session.


[[nsa-concurrency-control-expired-url]]
* **expired-url**
The URL a user will be redirected to if they attempt to use a session which has been "expired" by the concurrent session controller because the user has exceeded the number of allowed sessions and has logged in again elsewhere.
Should be set unless `exception-if-maximum-exceeded` is set.
If no value is supplied, an expiry message will just be written directly back to the response.

[[nsa-concurrency-control-expired-session-strategy-ref]]
* **expired-url**
Allows injection of the ExpiredSessionStrategy instance used by the ConcurrentSessionFilter

[[nsa-concurrency-control-max-sessions]]
* **max-sessions**
Maps to the `maximumSessions` property of `ConcurrentSessionControlAuthenticationStrategy`.
Specify `-1` as the value to support unlimited sessions.

[[nsa-concurrency-control-max-sessions-ref]]
* **max-sessions-ref**
Allows injection of the SessionLimit instance used by the ConcurrentSessionControlAuthenticationStrategy

[[nsa-concurrency-control-session-registry-alias]]
* **session-registry-alias**
It can also be useful to have a reference to the internal session registry for use in your own beans or an admin interface.
You can expose the internal bean using the `session-registry-alias` attribute, giving it a name that you can use elsewhere in your configuration.


[[nsa-concurrency-control-session-registry-ref]]
* **session-registry-ref**
The user can supply their own `SessionRegistry` implementation using the `session-registry-ref` attribute.
The other concurrent session control beans will be wired up to use it.


[[nsa-x509]]
== <x509>
Adds support for X.509 authentication.
An `X509AuthenticationFilter` will be added to the stack and an `Http403ForbiddenEntryPoint` bean will be created.
The latter will only be used if no other authentication mechanisms are in use (its only functionality is to return an HTTP 403 error code).
A `PreAuthenticatedAuthenticationProvider` will also be created which delegates the loading of user authorities to a `UserDetailsService`.


[[nsa-x509-parents]]
=== Parent Elements of <x509>


* <<nsa-http,http>>



[[nsa-x509-attributes]]
=== <x509> Attributes


[[nsa-x509-authentication-details-source-ref]]
* **authentication-details-source-ref**
A reference to an `AuthenticationDetailsSource`

[[nsa-x509-principal-extractor-ref]]
* **principal-extractor-ref**
Reference to an `X509PrincipalExtractor` which will be used by the authentication filter.


[[nsa-x509-subject-principal-regex]]
* **subject-principal-regex**
Defines a regular expression which will be used to extract the username from the certificate (for use with the `UserDetailsService`).


[[nsa-x509-user-service-ref]]
* **user-service-ref**
Allows a specific `UserDetailsService` to be used with X.509 in the case where multiple instances are configured.
If not set, an attempt will be made to locate a suitable instance automatically and use that.


[[nsa-filter-chain-map]]
== <filter-chain-map>
Used to explicitly configure a FilterChainProxy instance with a FilterChainMap


[[nsa-filter-chain-map-attributes]]
=== <filter-chain-map> Attributes


[[nsa-filter-chain-map-request-matcher]]
* **request-matcher**
Defines the strategy to 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.


[[nsa-filter-chain-map-children]]
=== Child Elements of <filter-chain-map>


* <<nsa-filter-chain,filter-chain>>



[[nsa-filter-chain]]
== <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.


[[nsa-filter-chain-parents]]
=== Parent Elements of <filter-chain>


* <<nsa-filter-chain-map,filter-chain-map>>



[[nsa-filter-chain-attributes]]
=== <filter-chain> Attributes


[[nsa-filter-chain-filters]]
* **filters**
A comma separated list of references to Spring beans that implement `Filter`.
The value "none" means that no `Filter` should be used for this `FilterChain`.


[[nsa-filter-chain-pattern]]
* **pattern**
A pattern that creates RequestMatcher in combination with the <<nsa-filter-chain-map-request-matcher,request-matcher>>


[[nsa-filter-chain-request-matcher-ref]]
* **request-matcher-ref**
A reference to a `RequestMatcher` that will be used to determine if any `Filter` from the `filters` attribute should be invoked.


[[nsa-filter-security-metadata-source]]
== <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<http> element.
The intercept-url elements used should only contain pattern, method and access attributes.
Any others will result in a configuration error.


[[nsa-filter-security-metadata-source-attributes]]
=== <filter-security-metadata-source> Attributes


[[nsa-filter-security-metadata-source-id]]
* **id**
A bean identifier, used for referring to the bean elsewhere in the context.


[[nsa-filter-security-metadata-source-request-matcher]]
* **request-matcher**
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.


[[nsa-filter-security-metadata-source-use-expressions]]
* **use-expressions**
Enables the use of expressions in the 'access' attributes in <intercept-url> elements rather than the traditional list of configuration attributes.
Defaults to 'true'.
If enabled, each attribute should contain a single Boolean expression.
If the expression evaluates to 'true', access will be granted.


[[nsa-filter-security-metadata-source-children]]
=== Child Elements of <filter-security-metadata-source>


* <<nsa-intercept-url,intercept-url>>
