2018-03-05 16:10:47 -06:00
[[nsa-web]]
2021-11-01 14:50:25 -06:00
= Web Application Security
2018-03-05 16:10:47 -06:00
2021-04-21 16:01:26 -05:00
This section deals with the XML namespace elements and attributes that deal with the security of web applications.
2018-03-05 16:10:47 -06:00
[[nsa-debug]]
2021-11-01 14:50:25 -06:00
== <debug>
2018-03-05 16:10:47 -06:00
Enables Spring Security debugging infrastructure.
2021-04-21 16:01:26 -05:00
This element provides human-readable (multi-line) debugging information to monitor requests that come to the security filters.
This may include sensitive information (such as request parameters or headers) and should only be used in a development environment.
2018-03-05 16:10:47 -06:00
[[nsa-http]]
2021-11-01 14:50:25 -06:00
== <http>
2021-12-13 16:57:36 -06:00
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`.
2021-04-21 16:01:26 -05:00
As of Spring Security 3.1, you can use additional `http` elements to add extra filter chains. See the <<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 are added to the stack depending on the attributes and child elements that are present.
2018-03-05 16:10:47 -06:00
The positions of the standard filters are fixed (see
2021-09-21 14:56:09 -05:00
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
2018-03-05 16:10:47 -06:00
`FilterChainProxy` bean.
2021-04-21 16:01:26 -05:00
You can still controle the order of the filters if you need full control of the configuration.
2018-03-05 16:10:47 -06:00
2021-12-13 16:57:36 -06:00
All filters that which require a reference to the xref:servlet/authentication/architecture.adoc#servlet-authentication-authenticationmanager[`AuthenticationManager`] are automatically injected with the internal instance created by the namespace configuration.
2018-03-05 16:10:47 -06:00
2021-04-21 16:01:26 -05:00
Each `<http>` namespace block always creates an `SecurityContextPersistenceFilter`, an `ExceptionTranslationFilter`, and a `FilterSecurityInterceptor`.
2018-03-05 16:10:47 -06:00
These are fixed and cannot be replaced with alternatives.
[[nsa-http-attributes]]
2021-11-01 14:50:25 -06:00
=== <http> Attributes
2018-03-05 16:10:47 -06:00
The attributes on the `<http>` element control some of the properties on the core filters.
[[nsa-http-access-decision-manager-ref]]
2021-04-21 16:01:26 -05:00
`access-decision-manager-ref`::
Optional attribute specifying the ID of the `AccessDecisionManager` implementation that should be used for authorizing HTTP requests.
By default, an `AffirmativeBased` implementation is used for with a `RoleVoter` and an `AuthenticatedVoter`.
2018-03-05 16:10:47 -06:00
[[nsa-http-authentication-manager-ref]]
2021-04-21 16:01:26 -05:00
`authentication-manager-ref`::
2018-03-05 16:10:47 -06:00
A reference to the `AuthenticationManager` used for the `FilterChain` created by this http element.
[[nsa-http-auto-config]]
2021-04-21 16:01:26 -05:00
`auto-config`::
Automatically registers a login form, BASIC authentication, and logout services.
If set to `true`, all of these capabilities are added. (You can still customize the configuration of each by providing the respective element).
If unspecified, it defaults to `false`.
2018-03-05 16:10:47 -06:00
Use of this attribute is not recommended.
2021-04-21 16:01:26 -05:00
Instead, you should use explicit configuration elements to avoid confusion.
2018-03-05 16:10:47 -06:00
[[nsa-http-create-session]]
2021-04-21 16:01:26 -05:00
`create-session`::
2018-03-05 16:10:47 -06:00
Controls the eagerness with which an HTTP session is created by Spring Security classes.
Options include:
2021-04-21 16:01:26 -05:00
* `always`: Spring Security proactively creates a session if one does not exist.
* `ifRequired` (default): Spring Security creates a session only if one is required.
* `never`: Spring Security never creates a session, but it will make use of one if the application creates one.
* `stateless`: Spring Security does not create a session and ignores the session for obtaining a Spring `Authentication`.
2018-03-05 16:10:47 -06:00
[[nsa-http-disable-url-rewriting]]
2021-04-21 16:01:26 -05:00
`disable-url-rewriting`::
2018-03-05 16:10:47 -06:00
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]]
2021-04-21 16:01:26 -05:00
`entry-point-ref`::
Normally, which `AuthenticationEntryPoint` is used depends on which authentication mechanisms have been configured.
This attribute lets this behavior be overridden by defining a customized `AuthenticationEntryPoint` bean, which starts the authentication process.
2018-03-05 16:10:47 -06:00
[[nsa-http-jaas-api-provision]]
2021-04-21 16:01:26 -05:00
`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.
2018-03-05 16:10:47 -06:00
Defaults to `false`.
[[nsa-http-name]]
2021-04-21 16:01:26 -05:00
`name`::
A bean identifier used for referring to the bean elsewhere in the context.
2018-03-05 16:10:47 -06:00
[[nsa-http-once-per-request]]
2021-04-21 16:01:26 -05:00
`once-per-request`::
2018-03-05 16:10:47 -06:00
Corresponds to the `observeOncePerRequest` property of `FilterSecurityInterceptor`.
Defaults to `true`.
[[nsa-http-pattern]]
2021-04-21 16:01:26 -05:00
`pattern`::
Defines a pattern for the <<nsa-http,http>> element controls the requests which are filtered through the list of filters that it defines.
2018-03-05 16:10:47 -06:00
The interpretation is dependent on the configured <<nsa-http-request-matcher,request-matcher>>.
2021-04-21 16:01:26 -05:00
If no pattern is defined, all requests are matched, so the most specific patterns should be declared first.
2018-03-05 16:10:47 -06:00
[[nsa-http-realm]]
2021-04-21 16:01:26 -05:00
`realm`::
2018-03-05 16:10:47 -06:00
Sets the realm name used for basic authentication (if enabled).
Corresponds to the `realmName` property on `BasicAuthenticationEntryPoint`.
[[nsa-http-request-matcher]]
2021-04-21 16:01:26 -05:00
`request-matcher`::
2018-03-05 16:10:47 -06:00
Defines the `RequestMatcher` strategy used in the `FilterChainProxy` and the beans created by the `intercept-url` to match incoming requests.
2021-04-21 16:01:26 -05:00
The current options are
* `mvc`: Spring MVC
* `ant` (default): Ant
* `regex`: Regular expression
* `ciRegex`: Case-insensitive regular-expression respectively.
A separate instance is created for each <<nsa-intercept-url,`intercept-url`>> element, by using its <<nsa-intercept-url-pattern,`pattern`>>, <<nsa-intercept-url-method,`method`>>, and <<nsa-intercept-url-servlet-path,`servlet-path`>> attributes.
Ant paths are matched by using an `AntPathRequestMatcher`. Regular expressions are matched by using a `RegexRequestMatcher`. For Spring MVC path matching, the `MvcRequestMatcher` is used.
2018-03-05 16:10:47 -06:00
See the Javadoc for these classes for more details on exactly how the matching is performed.
[[nsa-http-request-matcher-ref]]
2021-04-21 16:01:26 -05:00
`request-matcher-ref`::
A reference to a bean that implements `RequestMatcher`, which determines whenter this `FilterChain` should be used.
This is a more powerful alternative to <<nsa-http-pattern,`pattern`>>.
2018-03-05 16:10:47 -06:00
[[nsa-http-security]]
2021-04-21 16:01:26 -05:00
`security`::
A request pattern can be mapped to an empty filter chain by setting this attribute to `none`.
In that case, no security is applied and none of Spring Security's features are available.
2018-03-05 16:10:47 -06:00
[[nsa-http-security-context-repository-ref]]
2021-04-21 16:01:26 -05:00
`security-context-repository-ref`::
2018-03-05 16:10:47 -06:00
Allows injection of a custom `SecurityContextRepository` into the `SecurityContextPersistenceFilter`.
[[nsa-http-servlet-api-provision]]
2021-04-21 16:01:26 -05:00
`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.
Default: `true`.
2018-03-05 16:10:47 -06:00
[[nsa-http-use-expressions]]
2021-04-21 16:01:26 -05:00
`use-expressions`::
2021-07-30 16:56:54 -05:00
Enables EL-expressions in the `access` attribute, as described in the chapter on xref:servlet/authorization/expression-based.adoc#el-access-web[expression-based access-control].
2018-03-05 16:10:47 -06:00
The default value is true.
[[nsa-http-children]]
2021-11-01 14:50:25 -06:00
=== Child Elements of <http>
2021-04-21 16:01:26 -05:00
The `<http>` element has the following child elements, which we describe later in this appendix:
2018-03-05 16:10:47 -06:00
* <<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>>
2020-02-19 13:22:51 -05:00
* <<nsa-oauth2-client,oauth2-client>>
2019-12-11 19:46:10 -05:00
* <<nsa-oauth2-login,oauth2-login>>
2019-12-30 09:18:29 -07:00
* <<nsa-oauth2-resource-server,oauth2-resource-server>>
2018-03-05 16:10:47 -06:00
* <<nsa-openid-login,openid-login>>
2020-06-12 18:00:51 +03:00
* <<nsa-password-management,password-management>>
2018-03-05 16:10:47 -06:00
* <<nsa-port-mappings,port-mappings>>
* <<nsa-remember-me,remember-me>>
* <<nsa-request-cache,request-cache>>
* <<nsa-session-management,session-management>>
* <<nsa-x509,x509>>
[[nsa-access-denied-handler]]
2021-11-01 14:50:25 -06:00
== <access-denied-handler>
2021-04-21 16:01:26 -05:00
This element lets you set the `errorPage` property for the default `AccessDeniedHandler` used by the `ExceptionTranslationFilter` (by using the <<nsa-access-denied-handler-error-page,`error-page`>> attribute) or to supply your own implementation by using the<<nsa-access-denied-handler-ref,`ref`>> attribute.
2021-08-19 14:17:49 -05:00
This is discussed in more detail in the section on the xref:servlet/architecture.adoc#servlet-exceptiontranslationfilter[ExceptionTranslationFilter].
2018-03-05 16:10:47 -06:00
[[nsa-access-denied-handler-parents]]
2021-11-01 14:50:25 -06:00
=== Parent Elements of <access-denied-handler>
2018-03-05 16:10:47 -06:00
2021-04-21 16:01:26 -05:00
The parent element of the `<access-denied-handler>` element is <<nsa-http,`http`>>.
2018-03-05 16:10:47 -06:00
[[nsa-access-denied-handler-attributes]]
2021-11-01 14:50:25 -06:00
=== <access-denied-handler> Attributes
2018-03-05 16:10:47 -06:00
[[nsa-access-denied-handler-error-page]]
2021-04-21 16:01:26 -05:00
`error-page`::
The access denied page to which an authenticated user is redirected if they request a page to which they do not have access.
2018-03-05 16:10:47 -06:00
[[nsa-access-denied-handler-ref]]
2021-04-21 16:01:26 -05:00
`ref`::
2018-03-05 16:10:47 -06:00
Defines a reference to a Spring bean of type `AccessDeniedHandler`.
[[nsa-cors]]
2021-11-01 14:50:25 -06:00
== <cors>
2018-03-05 16:10:47 -06:00
This element allows for configuring a `CorsFilter`.
If no `CorsFilter` or `CorsConfigurationSource` is specified and Spring MVC is on the classpath, a `HandlerMappingIntrospector` is used as the `CorsConfigurationSource`.
[[nsa-cors-attributes]]
2021-11-01 14:50:25 -06:00
=== <cors> Attributes
2021-04-21 16:01:26 -05:00
The attributes on the `<cors>` element control the headers element are:
2018-03-05 16:10:47 -06:00
[[nsa-cors-ref]]
2021-04-21 16:01:26 -05:00
`ref`::
2018-03-05 16:10:47 -06:00
Optional attribute that specifies the bean name of a `CorsFilter`.
[[nsa-cors-configuration-source-ref]]
2021-04-21 16:01:26 -05:00
cors-configuration-source-ref::
2018-03-05 16:10:47 -06:00
Optional attribute that specifies the bean name of a `CorsConfigurationSource` to be injected into a `CorsFilter` created by the XML namespace.
[[nsa-cors-parents]]
2021-11-01 14:50:25 -06:00
=== Parent Elements of <cors>
2018-03-05 16:10:47 -06:00
2021-04-21 16:01:26 -05:00
The parent element of the `<cors>` element is <<nsa-http,`http`>>.
2018-03-05 16:10:47 -06:00
[[nsa-headers]]
2021-11-01 14:50:25 -06:00
== <headers>
2021-04-21 16:01:26 -05:00
This element allows for configuring additional (security) headers to be sent with the response.
It enables configuration for several headers and also allows for setting custom headers through the <<nsa-header,`header`>> element.
2021-12-13 16:57:36 -06:00
You can find additional information in the xref:features/exploits/headers.adoc#headers[Security Headers] section of the reference.
2018-03-05 16:10:47 -06:00
** `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.
2019-03-19 23:53:23 -05:00
The https://en.wikipedia.org/wiki/Clickjacking#X-Frame-Options[X-Frame-Options] header can be used to prevent clickjacking attacks.
2018-03-05 16:10:47 -06:00
** `X-XSS-Protection` - Can be set using the <<nsa-xss-protection,xss-protection>> element.
2019-03-19 23:53:23 -05:00
The https://en.wikipedia.org/wiki/Cross-site_scripting[X-XSS-Protection ] header can be used by browser to do basic control.
2018-03-05 16:10:47 -06:00
** `X-Content-Type-Options` - Can be set using the <<nsa-content-type-options,content-type-options>> element.
2019-03-19 23:53:23 -05:00
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.
2018-03-05 16:10:47 -06:00
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.
2018-08-15 22:05:10 +02:00
** `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.
2018-03-05 16:10:47 -06:00
[[nsa-headers-attributes]]
2021-11-01 14:50:25 -06:00
=== <headers> Attributes
2021-04-21 16:01:26 -05:00
The attributes on the `<headers>` element control the `<headers>` element in the HTML output.
2018-03-05 16:10:47 -06:00
[[nsa-headers-defaults-disabled]]
2021-04-21 16:01:26 -05:00
`defaults-disabled`::
Optional attribute that specifies whether to disable the default Spring Security's HTTP response headers.
The default is `false` (the default headers are included).
2018-03-05 16:10:47 -06:00
[[nsa-headers-disabled]]
2021-04-21 16:01:26 -05:00
`disabled`::
Optional attribute that specifies whether to disable Spring Security's HTTP response headers.
2018-03-05 16:10:47 -06:00
The default is false (the headers are enabled).
[[nsa-headers-parents]]
2021-11-01 14:50:25 -06:00
=== Parent Elements of <headers>
2018-03-05 16:10:47 -06:00
2021-05-28 12:03:16 -05:00
The parent element of the `<headers>` element is the <<nsa-http,http>> element.
2018-03-05 16:10:47 -06:00
[[nsa-headers-children]]
2021-11-01 14:50:25 -06:00
=== Child Elements of <headers>
2018-03-05 16:10:47 -06:00
2021-04-21 16:01:26 -05:00
The `<headers>` element has the following possible children:
2018-03-05 16:10:47 -06:00
* <<nsa-cache-control,cache-control>>
* <<nsa-content-security-policy,content-security-policy>>
* <<nsa-content-type-options,content-type-options>>
2018-08-15 22:05:10 +02:00
* <<nsa-feature-policy,feature-policy>>
2018-03-05 16:10:47 -06:00
* <<nsa-frame-options,frame-options>>
* <<nsa-header,header>>
* <<nsa-hpkp,hpkp>>
* <<nsa-hsts,hsts>>
2021-04-29 16:52:06 -06:00
* <<nsa-permissions-policy,permission-policy>>
2018-03-05 16:10:47 -06:00
* <<nsa-referrer-policy,referrer-policy>>
* <<nsa-xss-protection,xss-protection>>
[[nsa-cache-control]]
2021-11-01 14:50:25 -06:00
== <cache-control>
2021-04-21 16:01:26 -05:00
The `<cache-control>` element adds the `Cache-Control`, `Pragma`, and `Expires` headers to ensure that the browser does not cache your secured pages.
2018-03-05 16:10:47 -06:00
[[nsa-cache-control-attributes]]
2021-11-01 14:50:25 -06:00
=== <cache-control> Attributes
2018-03-05 16:10:47 -06:00
2021-04-21 16:01:26 -05:00
The `<cache-control>` element can have the following attribute:
2018-03-05 16:10:47 -06:00
[[nsa-cache-control-disabled]]
2021-04-21 16:01:26 -05:00
`disabled`::
Specifies whether cache control should be disabled.
Default: `false`.
2018-03-05 16:10:47 -06:00
[[nsa-cache-control-parents]]
2021-11-01 14:50:25 -06:00
=== Parent Elements of <cache-control>
2018-03-05 16:10:47 -06:00
2021-05-28 12:03:16 -05:00
The parent of the `<cache-control>` element is the <<nsa-headers,headers>> element.
2018-03-05 16:10:47 -06:00
[[nsa-hsts]]
2021-11-01 14:50:25 -06:00
== <hsts>
2021-04-21 16:01:26 -05:00
When enabled, the `<hsts>` element adds the https://tools.ietf.org/html/rfc6797[Strict-Transport-Security] header to the response for any secure request.
This lets the server instruct browsers to automatically use HTTPS for future requests.
2018-03-05 16:10:47 -06:00
[[nsa-hsts-attributes]]
2021-11-01 14:50:25 -06:00
=== <hsts> Attributes
2018-03-05 16:10:47 -06:00
2021-04-21 16:01:26 -05:00
The `<hsts>` element has the following available attributes:
2018-03-05 16:10:47 -06:00
[[nsa-hsts-disabled]]
2021-04-21 16:01:26 -05:00
`disabled`::
Specifies whether Strict-Transport-Security should be disabled.
Default: `false`.
2018-03-05 16:10:47 -06:00
[[nsa-hsts-include-subdomains]]
2021-04-21 16:01:26 -05:00
`include-sub-domains`::
Specifies whether subdomains should be included.
Default: true.
2018-03-05 16:10:47 -06:00
[[nsa-hsts-max-age-seconds]]
2021-04-21 16:01:26 -05:00
`max-age-seconds`::
2018-03-05 16:10:47 -06:00
Specifies the maximum amount of time the host should be considered a Known HSTS Host.
Default one year.
[[nsa-hsts-request-matcher-ref]]
2021-04-21 16:01:26 -05:00
`request-matcher-ref`::
The `RequestMatcher` instance to be used to determine if the header should be set.
The default is to see whether `HttpServletRequest.isSecure()` is `true`.
2018-03-05 16:10:47 -06:00
2018-12-21 21:59:54 +05:30
[[nsa-hsts-preload]]
2021-04-21 16:01:26 -05:00
preload::
Specifies whether preload should be included.
Default: `false`.
2018-03-05 16:10:47 -06:00
[[nsa-hsts-parents]]
2021-11-01 14:50:25 -06:00
=== Parent Elements of <hsts>
2018-03-05 16:10:47 -06:00
2021-05-28 12:03:16 -05:00
The parent element of the `<hsts>` element is the <<nsa-headers,headers>> element.
2018-03-05 16:10:47 -06:00
[[nsa-hpkp]]
2021-11-01 14:50:25 -06:00
== <hpkp>
2021-04-21 16:01:26 -05:00
When enabled, the `<hpkp>` element adds the https://tools.ietf.org/html/rfc7469[Public Key Pinning Extension for HTTP] header to the response for any secure request.
This lets HTTPS websites resist impersonation by attackers that use mis-issued or otherwise fraudulent certificates.
2018-03-05 16:10:47 -06:00
[[nsa-hpkp-attributes]]
2021-11-01 14:50:25 -06:00
=== <hpkp> Attributes
2018-03-05 16:10:47 -06:00
2021-04-21 16:01:26 -05:00
The `<hpkp>` element can have the following elements:
2018-03-05 16:10:47 -06:00
[[nsa-hpkp-disabled]]
2021-04-21 16:01:26 -05:00
`disabled`::
2018-03-05 16:10:47 -06:00
Specifies if HTTP Public Key Pinning (HPKP) should be disabled.
2021-04-21 16:01:26 -05:00
Default: `true`.
2018-03-05 16:10:47 -06:00
[[nsa-hpkp-include-subdomains]]
2021-04-21 16:01:26 -05:00
`include-sub-domains`::
Specifies whether subdomains should be included.
Default: `false`.
2018-03-05 16:10:47 -06:00
[[nsa-hpkp-max-age-seconds]]
2021-04-21 16:01:26 -05:00
max-age-seconds::
Sets the value for the `max-age` directive of the `Public-Key-Pins` header.
Default: 60 days (5,184,000 seconds)
2018-03-05 16:10:47 -06:00
[[nsa-hpkp-report-only]]
2021-04-21 16:01:26 -05:00
`report-only`::
Specifies whether the browser should report only pin validation failures.
Default: `true`.
2018-03-05 16:10:47 -06:00
[[nsa-hpkp-report-uri]]
2021-04-21 16:01:26 -05:00
`report-uri`:
2018-03-05 16:10:47 -06:00
Specifies the URI to which the browser should report pin validation failures.
[[nsa-hpkp-parents]]
2021-11-01 14:50:25 -06:00
=== Parent Elements of <hpkp>
2018-03-05 16:10:47 -06:00
2021-05-28 12:03:16 -05:00
The parent element of the <hpkp> element is the <<nsa-headers,headers>> element.
2018-03-05 16:10:47 -06:00
[[nsa-pins]]
2021-11-01 14:50:25 -06:00
== <pins>
2021-04-21 16:01:26 -05:00
This section describes the attributes and child elements of the `<pins>` element.
2018-03-05 16:10:47 -06:00
[[nsa-pins-children]]
2021-11-01 14:50:25 -06:00
=== Child Elements of <pins>
2018-03-05 16:10:47 -06:00
2021-05-28 12:03:16 -05:00
The <pins> element has a single child element: <<nsa-pin,pin>>. There can be multiple <pin> elements.
2018-03-05 16:10:47 -06:00
[[nsa-pin]]
2021-11-01 14:50:25 -06:00
== <pin>
2021-04-21 16:01:26 -05:00
A <pin> element is specified by using the base64-encoded SPKI fingerprint as the value and the cryptographic hash algorithm as the attribute.
2018-03-05 16:10:47 -06:00
[[nsa-pin-attributes]]
2021-11-01 14:50:25 -06:00
=== <pin> Attributes
2018-03-05 16:10:47 -06:00
[[nsa-pin-algorithm]]
2021-04-21 16:01:26 -05:00
`algorithm`::
2018-03-05 16:10:47 -06:00
The cryptographic hash algorithm.
2021-04-21 16:01:26 -05:00
Default: SHA256.
2018-03-05 16:10:47 -06:00
[[nsa-pin-parents]]
2021-11-01 14:50:25 -06:00
=== Parent Elements of <pin>
2018-03-05 16:10:47 -06:00
2021-05-28 12:03:16 -05:00
The parent element of the <pin> element is the <<nsa-pins,pins>> element.
2018-03-05 16:10:47 -06:00
[[nsa-content-security-policy]]
2021-11-01 14:50:25 -06:00
== <content-security-policy>
2021-04-21 16:01:26 -05:00
When enabled, the `<content-security-policy>` element adds the https://www.w3.org/TR/CSP2/[Content Security Policy (CSP)] header to the response.
CSP is a mechanism that web applications can use to mitigate content injection vulnerabilities, such as cross-site scripting (XSS).
2018-03-05 16:10:47 -06:00
[[nsa-content-security-policy-attributes]]
2021-11-01 14:50:25 -06:00
=== <content-security-policy> Attributes
2018-03-05 16:10:47 -06:00
2021-04-21 16:01:26 -05:00
The <content-security-policy> element has the following attributes:
2018-03-05 16:10:47 -06:00
[[nsa-content-security-policy-policy-directives]]
2021-04-21 16:01:26 -05:00
`policy-directives`::
The security policy directive(s) for the Content-Security-Policy header. If report-only is set to `true`, the Content-Security-Policy-Report-Only header is used.
2018-03-05 16:10:47 -06:00
[[nsa-content-security-policy-report-only]]
2021-04-21 16:01:26 -05:00
`report-only`::
Whether to enable the Content-Security-Policy-Report-Only header for reporting policy violations only.
Default: `false`.
2018-03-05 16:10:47 -06:00
[[nsa-content-security-policy-parents]]
2021-11-01 14:50:25 -06:00
=== Parent Elements of <content-security-policy>
2018-03-05 16:10:47 -06:00
2021-05-28 12:03:16 -05:00
The parent element of the <content-security-policy> element is <<nsa-headers,headers>>.
2018-03-05 16:10:47 -06:00
[[nsa-referrer-policy]]
2021-11-01 14:50:25 -06:00
== <referrer-policy>
2021-04-21 16:01:26 -05:00
When enabled, the `<referrer-policy>` element adds the https://www.w3.org/TR/referrer-policy/[Referrer Policy] header to the response.
2018-03-05 16:10:47 -06:00
[[nsa-referrer-policy-attributes]]
2021-11-01 14:50:25 -06:00
=== <referrer-policy> Attributes
2018-03-05 16:10:47 -06:00
2021-04-21 16:01:26 -05:00
The `<referrer-policy>` element has the following attribute:
2018-03-05 16:10:47 -06:00
[[nsa-referrer-policy-policy]]
2021-04-21 16:01:26 -05:00
policy::
The policy for the `Referrer-Policy` header.
Default: `no-referrer`.
2018-03-05 16:10:47 -06:00
[[nsa-referrer-policy-parents]]
2021-11-01 14:50:25 -06:00
=== Parent Elements of <referrer-policy>
2018-03-05 16:10:47 -06:00
2021-05-28 12:03:16 -05:00
The parent element of the `<referrer-policy>` element is the <<nsa-headers,headers>> element.
2018-03-05 16:10:47 -06:00
2018-08-15 22:05:10 +02:00
[[nsa-feature-policy]]
2021-11-01 14:50:25 -06:00
== <feature-policy>
2021-04-21 16:01:26 -05:00
When enabled, the `<feature-policy>` element adds the https://wicg.github.io/feature-policy/[Feature Policy] header to the response.
2018-08-15 22:05:10 +02:00
[[nsa-feature-policy-attributes]]
2021-11-01 14:50:25 -06:00
=== <feature-policy> Attributes
2018-08-15 22:05:10 +02:00
2021-04-21 16:01:26 -05:00
The `<feature-policy>` element has the following attribute:
2018-08-15 22:05:10 +02:00
[[nsa-feature-policy-policy-directives]]
2021-04-21 16:01:26 -05:00
`policy-directives`::
2018-08-15 22:05:10 +02:00
The security policy directive(s) for the Feature-Policy header.
[[nsa-feature-policy-parents]]
2021-11-01 14:50:25 -06:00
=== Parent Elements of <feature-policy>
2018-08-15 22:05:10 +02:00
2021-05-28 12:03:16 -05:00
The parent element of the <feature-policy> element is the <<nsa-headers,headers>> element.
2018-08-15 22:05:10 +02:00
2018-03-05 16:10:47 -06:00
[[nsa-frame-options]]
2021-11-01 14:50:25 -06:00
== <frame-options>
2021-04-21 16:01:26 -05:00
When enabled, the `<frame-options>` element adds the https://tools.ietf.org/html/draft-ietf-websec-x-frame-options[X-Frame-Options header] to the response. Doing so lets newer browsers do some security checks and prevent https://en.wikipedia.org/wiki/Clickjacking[clickjacking] attacks.
2018-03-05 16:10:47 -06:00
[[nsa-frame-options-attributes]]
2021-11-01 14:50:25 -06:00
=== <frame-options> Attributes
2018-03-05 16:10:47 -06:00
2021-04-21 16:01:26 -05:00
The `<frame-options>` element has the following attributes:
2018-03-05 16:10:47 -06:00
[[nsa-frame-options-disabled]]
2021-04-21 16:01:26 -05:00
`disabled`::
If disabled, the X-Frame-Options header is not included.
Default: `false`.
2018-03-05 16:10:47 -06:00
[[nsa-frame-options-policy]]
2021-04-21 16:01:26 -05:00
`policy`::
* `DENY` (default): The page cannot be displayed in a frame, regardless of the site attempting to do so.
2021-12-13 16:57:36 -06:00
* `SAMEORIGIN` The page can only be displayed in a frame on the same origin as the page itself
2018-03-05 16:10:47 -06:00
2021-04-21 16:01:26 -05:00
In other words, if you specify `DENY`, not only do attempts to load the page in a frame fail when loaded from other sites, attempts to do so 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 is the same site as the one serving the page.
2018-03-05 16:10:47 -06:00
[[nsa-frame-options-parents]]
2021-11-01 14:50:25 -06:00
=== Parent Elements of <frame-options>
2018-03-05 16:10:47 -06:00
2021-05-28 12:03:16 -05:00
The parent element of the `<frame-options>` element is the <<nsa-headers,headers>> element.
2018-03-05 16:10:47 -06:00
2021-04-29 16:52:06 -06:00
[[nsa-permissions-policy]]
2021-11-01 14:50:25 -06:00
== <permissions-policy>
2021-12-13 16:57:36 -06:00
The `<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.
[NOTE]
====
Full protection against XSS attacks is not possible.
====
2018-03-05 16:10:47 -06:00
2021-04-29 16:52:06 -06:00
[[nsa-permissions-policy-attributes]]
2021-11-01 14:50:25 -06:00
=== <permissions-policy> Attributes
2021-04-29 16:52:06 -06:00
[[nsa-permissions-policy-policy]]
* **policy**
The policy value to write for the `Permissions-Policy` header
[[nsa-permissions-policy-parents]]
2021-11-01 14:50:25 -06:00
=== Parent Elements of <permissions-policy>
2021-04-29 16:52:06 -06:00
* <<nsa-headers,headers>>
2018-03-05 16:10:47 -06:00
[[nsa-xss-protection]]
2021-11-01 14:50:25 -06:00
== <xss-protection>
2019-03-19 23:53:23 -05:00
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.
2018-03-05 16:10:47 -06:00
This is in no-way a full protection to XSS attacks!
[[nsa-xss-protection-attributes]]
2021-11-01 14:50:25 -06:00
=== <xss-protection> Attributes
2018-03-05 16:10:47 -06:00
2021-04-21 16:01:26 -05:00
The `<xss-protection>` element has the following attributes:
2018-03-05 16:10:47 -06:00
[[nsa-xss-protection-disabled]]
2021-04-21 16:01:26 -05:00
`xss-protection-disabled`::
If set to `true`, do not include the header for https://en.wikipedia.org/wiki/Cross-site_scripting#Non-Persistent[reflected / Type-1 Cross-Site Scripting (XSS)] protection.
2018-03-05 16:10:47 -06:00
[[nsa-xss-protection-enabled]]
2021-12-13 16:57:36 -06:00
`xss-protection-enabled`::
2021-04-21 16:01:26 -05:00
Whether to explicitly enable or disable https://en.wikipedia.org/wiki/Cross-site_scripting#Non-Persistent[reflected / Type-1 Cross-Site Scripting (XSS)] protection.
2018-03-05 16:10:47 -06:00
[[nsa-xss-protection-block]]
2021-12-13 16:57:36 -06:00
`xss-protection-block`::
2021-04-21 16:01:26 -05:00
When `true` and `xss-protection-enabled` is `true`, adds `mode=block` to the header.
2018-03-05 16:10:47 -06:00
This indicates to the browser that the page should not be loaded at all.
2021-04-21 16:01:26 -05:00
When `false` and `xss-protection-enabled` is `true`, the page is still rendered when a reflected attack is detected, but the response is modified to protect against the attack.
Note that there are sometimes ways of bypassing this mode, which can often times make blocking the page more desirable.
2018-03-05 16:10:47 -06:00
[[nsa-xss-protection-parents]]
2021-11-01 14:50:25 -06:00
=== Parent Elements of <xss-protection>
2018-03-05 16:10:47 -06:00
2021-05-28 12:03:16 -05:00
The parent element of the `<xss-protection>` is the <<nsa-headers,headers>> element.
2018-03-05 16:10:47 -06:00
[[nsa-content-type-options]]
2021-11-01 14:50:25 -06:00
== <content-type-options>
2021-04-21 16:01:26 -05:00
The `<content-type-options>` element adds the `X-Content-Type-Options` header with a value of `nosniff` to the response.
2019-03-19 23:53:23 -05:00
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.
2018-03-05 16:10:47 -06:00
[[nsa-content-type-options-attributes]]
2021-11-01 14:50:25 -06:00
=== <content-type-options> Attributes
2018-03-05 16:10:47 -06:00
2021-04-21 16:01:26 -05:00
The `<content-type-options>` element has the following attribute:
2018-03-05 16:10:47 -06:00
[[nsa-content-type-options-disabled]]
2021-04-21 16:01:26 -05:00
`disabled`::
Specifies whether Content Type Options should be disabled.
Default: `false`.
2018-03-05 16:10:47 -06:00
[[nsa-content-type-options-parents]]
2021-11-01 14:50:25 -06:00
=== Parent Elements of <content-type-options>
2018-03-05 16:10:47 -06:00
* <<nsa-headers,headers>>
2021-12-13 16:57:36 -06:00
The parent element of the `<content-type-options>` element is the <<nsa-headers,headers>> element.
2021-12-03 16:47:21 -03:00
2018-03-05 16:10:47 -06:00
[[nsa-header]]
2021-11-01 14:50:25 -06:00
== <header>
2021-04-21 16:01:26 -05:00
The `<header>` element adds additional headers to the response. Both the name and value of each added header need to be specified in a `<header-attributes>` element (a child of the `<header>` element). To add multiple headers, add multiple `<header-attributes>` elements.
2018-03-05 16:10:47 -06:00
[[nsa-header-attributes]]
2021-11-01 14:50:25 -06:00
=== <header-attributes> Attributes
2018-03-05 16:10:47 -06:00
2021-04-21 16:01:26 -05:00
The `<header-attributes>` element has the following attributes:
2018-03-05 16:10:47 -06:00
[[nsa-header-name]]
2021-04-21 16:01:26 -05:00
`header-name`::
The `name` of the header to add.
2018-03-05 16:10:47 -06:00
[[nsa-header-value]]
2021-04-21 16:01:26 -05:00
value::
2018-03-05 16:10:47 -06:00
The `value` of the header to add.
[[nsa-header-ref]]
2021-04-21 16:01:26 -05:00
`ref`::
2018-03-05 16:10:47 -06:00
Reference to a custom implementation of the `HeaderWriter` interface.
[[nsa-header-parents]]
2021-11-01 14:50:25 -06:00
=== Parent Elements of <header>
2018-03-05 16:10:47 -06:00
2021-05-28 12:03:16 -05:00
The parent element of the `<header>` is the <<nsa-headers,headers>> element.
2018-03-05 16:10:47 -06:00
[[nsa-anonymous]]
2021-11-01 14:50:25 -06:00
== <anonymous>
2021-04-21 16:01:26 -05:00
The `<anonymous>` element adds an `AnonymousAuthenticationFilter` to the stack and adds an `AnonymousAuthenticationProvider`.
This element is required if you use the `IS_AUTHENTICATED_ANONYMOUSLY` attribute.
2018-03-05 16:10:47 -06:00
[[nsa-anonymous-parents]]
2021-11-01 14:50:25 -06:00
=== Parent Elements of <anonymous>
2018-03-05 16:10:47 -06:00
2021-05-28 12:03:16 -05:00
The parent element of the `<anonymous>` element is the <<nsa-http,http>> element.
2018-03-05 16:10:47 -06:00
[[nsa-anonymous-attributes]]
2021-11-01 14:50:25 -06:00
=== <anonymous> Attributes
2018-03-05 16:10:47 -06:00
2021-04-21 16:01:26 -05:00
The `<anonymous>` element has the following attributes:
2018-03-05 16:10:47 -06:00
[[nsa-anonymous-enabled]]
2021-04-21 16:01:26 -05:00
`enabled`::
With the default namespace setup, the anonymous "`authentication`" facility is automatically enabled.
You can disable it by setting this property.
2018-03-05 16:10:47 -06:00
[[nsa-anonymous-granted-authority]]
2021-04-21 16:01:26 -05:00
`granted-authority`::
2018-03-05 16:10:47 -06:00
The granted authority that should be assigned to the anonymous request.
2021-04-21 16:01:26 -05:00
Commonly, this attribute is used to assign the anonymous request particular roles, which can subsequently be used in authorization decisions.
If unset, it defaults to `ROLE_ANONYMOUS`.
2018-03-05 16:10:47 -06:00
[[nsa-anonymous-key]]
2021-04-21 16:01:26 -05:00
`key`::
The key shared between the provider and the filter.
2018-03-05 16:10:47 -06:00
This generally does not need to be set.
2021-04-21 16:01:26 -05:00
If unset, it defaults to a secure randomly generated value.
This means that setting this value can improve startup time when using the anonymous functionality, since secure random values can take a while to be generated.
2018-03-05 16:10:47 -06:00
[[nsa-anonymous-username]]
2021-04-21 16:01:26 -05:00
username::
2018-03-05 16:10:47 -06:00
The username that should be assigned to the anonymous request.
2021-04-21 16:01:26 -05:00
This lets the principal be identified, which may be important for logging and auditing.
Defaults: `anonymousUser`
2018-03-05 16:10:47 -06:00
[[nsa-csrf]]
2021-11-01 14:50:25 -06:00
== <csrf>
2021-04-21 16:01:26 -05:00
The `<csrf` element adds 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 replay only `GET` requests upon successful authentication.
You can find additional information in the <<csrf,Cross Site Request Forgery (CSRF)>> section of the reference.
2018-03-05 16:10:47 -06:00
[[nsa-csrf-parents]]
2021-11-01 14:50:25 -06:00
=== Parent Elements of <csrf>
2018-03-05 16:10:47 -06:00
2021-04-21 16:01:26 -05:00
The parent element of the `<csrf>` element is the <<nsa-http,`http`>> element.
2018-03-05 16:10:47 -06:00
[[nsa-csrf-attributes]]
2021-11-01 14:50:25 -06:00
=== <csrf> Attributes
2018-03-05 16:10:47 -06:00
2021-04-21 16:01:26 -05:00
The `<csrf>` element has the following attributes:
2018-03-05 16:10:47 -06:00
[[nsa-csrf-disabled]]
2021-04-21 16:01:26 -05:00
`disabled`::
Optional attribute that specifies whether to disable Spring Security's CSRF protection.
Default: `false` (CSRF protection is enabled)
We highly recommended leaving CSRF protection enabled.
2018-03-05 16:10:47 -06:00
[[nsa-csrf-token-repository-ref]]
2021-04-21 16:01:26 -05:00
`token-repository-ref`::
The `CsrfTokenRepository` to use.
Default: `HttpSessionCsrfTokenRepository`
2018-03-05 16:10:47 -06:00
[[nsa-csrf-request-matcher-ref]]
2021-04-21 16:01:26 -05:00
request-matcher-ref::
The `RequestMatcher` instance to be used to determine whether CSRF should be applied.
The default is any HTTP method except `GET`, `TRACE`, `HEAD`, `OPTIONS`.
2018-03-05 16:10:47 -06:00
[[nsa-custom-filter]]
2021-11-01 14:50:25 -06:00
== <custom-filter>
2021-04-21 16:01:26 -05:00
The `<custom-filter>` element adds a filter to the filter chain.
It does not create any additional beans but is used to select a bean of type `javax.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.
2021-09-21 14:56:09 -05:00
Full details can be found in the xref:servlet/configuration/xml-namespace.adoc#ns-custom-filters[ namespace chapter].
2018-03-05 16:10:47 -06:00
[[nsa-custom-filter-parents]]
2021-11-01 14:50:25 -06:00
=== Parent Elements of <custom-filter>
2018-03-05 16:10:47 -06:00
2021-05-28 12:03:16 -05:00
The parent element of the `<custom-filter>` is the <<nsa-http,http>> element.
2018-03-05 16:10:47 -06:00
[[nsa-custom-filter-attributes]]
2021-11-01 14:50:25 -06:00
=== <custom-filter> Attributes
2018-03-05 16:10:47 -06:00
2021-04-21 16:01:26 -05:00
The `<custom-filter>` element has the following attributes:
2018-03-05 16:10:47 -06:00
[[nsa-custom-filter-after]]
2021-04-21 16:01:26 -05:00
`after`::
The filter immediately after which the custom filter should be placed in the chain.
This feature is needed only 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.
2018-03-05 16:10:47 -06:00
The filter names map to specific Spring Security implementation filters.
[[nsa-custom-filter-before]]
2021-04-21 16:01:26 -05:00
`position`::
The explicit position at which the custom filter should be placed in the chain.
Use this attribute to replace a standard filter.
2018-03-05 16:10:47 -06:00
[[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]]
2021-04-21 16:01:26 -05:00
ref::
2018-03-05 16:10:47 -06:00
Defines a reference to a Spring bean that implements `Filter`.
[[nsa-expression-handler]]
2021-11-01 14:50:25 -06:00
== <expression-handler>
2021-04-21 16:01:26 -05:00
Defines the `SecurityExpressionHandler` instance to be used if expression-based access control is enabled.
A default implementation (with no ACL support) is used if none is supplied.
2018-03-05 16:10:47 -06:00
[[nsa-expression-handler-parents]]
2021-11-01 14:50:25 -06:00
=== Parent Elements of <expression-handler>
2018-03-05 16:10:47 -06:00
2021-04-21 16:01:26 -05:00
The `<expression-handler>` has the following parent elements:
2018-03-05 16:10:47 -06:00
2021-11-01 14:50:25 -06:00
* xref:servlet/appendix/namespace/method-security.adoc#nsa-global-method-security[global-method-security]
2018-03-05 16:10:47 -06:00
* <<nsa-http,http>>
2021-11-01 14:50:25 -06:00
* 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]
2018-03-05 16:10:47 -06:00
[[nsa-expression-handler-attributes]]
2021-11-01 14:50:25 -06:00
=== <expression-handler> Attributes
2018-03-05 16:10:47 -06:00
[[nsa-expression-handler-ref]]
2021-04-21 16:01:26 -05:00
`ref`::
2018-03-05 16:10:47 -06:00
Defines a reference to a Spring bean that implements `SecurityExpressionHandler`.
[[nsa-form-login]]
2021-11-01 14:50:25 -06:00
== <form-login>
2021-04-21 16:01:26 -05:00
Used to add an `UsernamePasswordAuthenticationFilter` to the filter stack and a `LoginUrlAuthenticationEntryPoint` to the application context, to provide authentication on demand.
This always takes precedence over other namespace-created entry points.
If no attributes are supplied, a login page is generated automatically at the `/login` URL.
You can customize this behavior by setting the <<nsa-form-login-attributes, `<form-login>` Attributes>>.
2021-06-04 14:12:59 -05:00
[NOTE]
====
This feature is provided for convenience and is not intended for production (where a view technology should have been chosen and can be used to render a customized login page).
2021-04-21 16:01:26 -05:00
The class `DefaultLoginPageGeneratingFilter` class is responsible for rendering the login page and provide login forms for both normal form login and OpenID if required.
2021-06-04 14:12:59 -05:00
====
2018-03-05 16:10:47 -06:00
[[nsa-form-login-parents]]
2021-11-01 14:50:25 -06:00
=== Parent Elements of <form-login>
2018-03-05 16:10:47 -06:00
2021-05-28 12:03:16 -05:00
The parent element of the `<form-login>` element is the <<nsa-http,http>> element.
2018-03-05 16:10:47 -06:00
[[nsa-form-login-attributes]]
2021-11-01 14:50:25 -06:00
=== <form-login> Attributes
2021-04-21 16:01:26 -05:00
The `form-login` element has the following attributes:
2018-03-05 16:10:47 -06:00
[[nsa-form-login-always-use-default-target]]
2021-12-13 16:57:36 -06:00
`always-use-default-target`::
2021-04-21 16:01:26 -05:00
If set to `true`, the user always starts at the value given by <<nsa-form-login-default-target-url,`default-target-url`>>, regardless of how they arrived at the login page.
2018-03-05 16:10:47 -06:00
Maps to the `alwaysUseDefaultTargetUrl` property of `UsernamePasswordAuthenticationFilter`.
2021-04-21 16:01:26 -05:00
Default: `false`.
2018-03-05 16:10:47 -06:00
[[nsa-form-login-authentication-details-source-ref]]
2021-12-13 16:57:36 -06:00
`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.
2018-03-05 16:10:47 -06:00
[[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`.
2021-04-21 16:01:26 -05:00
Defines the URL to which the browser is redirected on login failure.
Defaults to `/login?error`, which is automatically handled by the automatic login page generator, re-rendering the login page with an error message.
2018-03-05 16:10:47 -06:00
[[nsa-form-login-authentication-success-handler-ref]]
2021-04-21 16:01:26 -05:00
`authentication-success-handler-ref`::
You an use this 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.
2018-03-05 16:10:47 -06:00
The value should be the name of an `AuthenticationSuccessHandler` bean in the application context.
2021-04-21 16:01:26 -05:00
By default, an implementation of `SavedRequestAwareAuthenticationSuccessHandler` is used and injected with the <<nsa-form-login-default-target-url,`default-target-url` >>.
2018-03-05 16:10:47 -06:00
[[nsa-form-login-default-target-url]]
2021-04-21 16:01:26 -05:00
default-target-url::
2018-03-05 16:10:47 -06:00
Maps to the `defaultTargetUrl` property of `UsernamePasswordAuthenticationFilter`.
2021-04-21 16:01:26 -05:00
If not set, the default value is `/` (the application root).
A user is 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.
2018-03-05 16:10:47 -06:00
[[nsa-form-login-login-page]]
2021-04-21 16:01:26 -05:00
`login-page`::
2018-03-05 16:10:47 -06:00
The URL that should be used to render the login page.
Maps to the `loginFormUrl` property of the `LoginUrlAuthenticationEntryPoint`.
2021-04-21 16:01:26 -05:00
Default: `/login`.
2018-03-05 16:10:47 -06:00
[[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**
2021-04-21 16:01:26 -05:00
The name of the request parameter that contains the password.
Default: `password`.
2018-03-05 16:10:47 -06:00
[[nsa-form-login-username-parameter]]
2021-04-21 16:01:26 -05:00
username-parameter::
The name of the request parameter that contains the username.
Default: `username`.
2018-03-05 16:10:47 -06:00
[[nsa-form-login-authentication-success-forward-url]]
2021-04-21 16:01:26 -05:00
`authentication-success-forward-url`::
Maps a `ForwardAuthenticationSuccessHandler` to the `authenticationSuccessHandler` property of `UsernamePasswordAuthenticationFilter`.
2018-03-05 16:10:47 -06:00
[[nsa-form-login-authentication-failure-forward-url]]
2021-04-21 16:01:26 -05:00
`authentication-failure-forward-url`::
Maps a `ForwardAuthenticationFailureHandler` to the `authenticationFailureHandler` property of `UsernamePasswordAuthenticationFilter`.
2018-03-05 16:10:47 -06:00
2019-12-11 19:46:10 -05:00
[[nsa-oauth2-login]]
2021-11-01 14:50:25 -06:00
== <oauth2-login>
2021-12-13 16:57:36 -06:00
The xref:servlet/oauth2/login/index.adoc#oauth2login[OAuth 2.0 Login] feature configures authentication support by using an OAuth 2.0 or OpenID Connect 1.0 Provider.
2019-12-11 19:46:10 -05:00
[[nsa-oauth2-login-parents]]
2021-11-01 14:50:25 -06:00
=== Parent Elements of <oauth2-login>
2019-12-11 19:46:10 -05:00
2021-05-28 12:03:16 -05:00
The parent element of the `<oauth2-login>` element is the <<nsa-http,http>> element.
2019-12-11 19:46:10 -05:00
2019-12-24 22:10:46 +08:00
[[nsa-oauth2-login-attributes]]
2021-11-01 14:50:25 -06:00
=== <oauth2-login> Attributes
2019-12-24 22:10:46 +08:00
2021-04-21 16:01:26 -05:00
The `<oauth2-login>` has the following attributes:
2019-12-24 22:10:46 +08:00
[[nsa-oauth2-login-client-registration-repository-ref]]
2021-04-21 16:01:26 -05:00
`client-registration-repository-ref`::
2020-02-11 04:20:59 -05:00
Reference to the `ClientRegistrationRepository`.
2019-12-24 22:10:46 +08:00
[[nsa-oauth2-login-authorized-client-repository-ref]]
2021-04-21 16:01:26 -05:00
`authorized-client-repository-ref`::
2020-02-11 04:20:59 -05:00
Reference to the `OAuth2AuthorizedClientRepository`.
2019-12-24 22:10:46 +08:00
[[nsa-oauth2-login-authorized-client-service-ref]]
2021-04-21 16:01:26 -05:00
`authorized-client-service-ref`::
2020-02-11 04:20:59 -05:00
Reference to the `OAuth2AuthorizedClientService`.
2019-12-24 22:10:46 +08:00
[[nsa-oauth2-login-authorization-request-repository-ref]]
2021-04-21 16:01:26 -05:00
`authorization-request-repository-ref`::
2020-02-11 04:20:59 -05:00
Reference to the `AuthorizationRequestRepository`.
2019-12-24 22:10:46 +08:00
[[nsa-oauth2-login-authorization-request-resolver-ref]]
2021-04-21 16:01:26 -05:00
`authorization-request-resolver-ref`::
2020-02-11 04:20:59 -05:00
Reference to the `OAuth2AuthorizationRequestResolver`.
2019-12-24 22:10:46 +08:00
[[nsa-oauth2-login-access-token-response-client-ref]]
2021-04-21 16:01:26 -05:00
`access-token-response-client-ref`::
2020-02-11 04:20:59 -05:00
Reference to the `OAuth2AccessTokenResponseClient`.
2019-12-24 22:10:46 +08:00
[[nsa-oauth2-login-user-authorities-mapper-ref]]
2021-04-21 16:01:26 -05:00
`user-authorities-mapper-ref`::
2020-02-11 04:20:59 -05:00
Reference to the `GrantedAuthoritiesMapper`.
2019-12-24 22:10:46 +08:00
[[nsa-oauth2-login-user-service-ref]]
2021-04-21 16:01:26 -05:00
`user-service-ref`::
2020-02-11 04:20:59 -05:00
Reference to the `OAuth2UserService`.
2019-12-24 22:10:46 +08:00
[[nsa-oauth2-login-oidc-user-service-ref]]
2021-04-21 16:01:26 -05:00
`oidc-user-service-ref`::
2020-02-11 04:20:59 -05:00
Reference to the OpenID Connect `OAuth2UserService`.
2019-12-24 22:10:46 +08:00
[[nsa-oauth2-login-login-processing-url]]
2021-04-21 16:01:26 -05:00
`login-processing-url`::
2020-02-11 04:20:59 -05:00
The URI where the filter processes authentication requests.
2019-12-24 22:10:46 +08:00
[[nsa-oauth2-login-login-page]]
2021-04-21 16:01:26 -05:00
`login-page`::
The URI to which to send users to login.
2019-12-24 22:10:46 +08:00
[[nsa-oauth2-login-authentication-success-handler-ref]]
2021-04-21 16:01:26 -05:00
`authentication-success-handler-ref`::
2020-02-11 04:20:59 -05:00
Reference to the `AuthenticationSuccessHandler`.
2019-12-24 22:10:46 +08:00
[[nsa-oauth2-login-authentication-failure-handler-ref]]
2021-04-21 16:01:26 -05:00
`authentication-failure-handler-ref`::
2020-02-11 04:20:59 -05:00
Reference to the `AuthenticationFailureHandler`.
2019-12-24 22:10:46 +08:00
[[nsa-oauth2-login-jwt-decoder-factory-ref]]
2021-04-21 16:01:26 -05:00
`jwt-decoder-factory-ref`::
2020-02-11 04:20:59 -05:00
Reference to the `JwtDecoderFactory` used by `OidcAuthorizationCodeAuthenticationProvider`.
2019-12-24 22:10:46 +08:00
2019-12-11 19:46:10 -05:00
2020-02-19 13:22:51 -05:00
[[nsa-oauth2-client]]
2021-11-01 14:50:25 -06:00
== <oauth2-client>
2021-11-04 11:31:27 -06:00
Configures xref:servlet/oauth2/client/index.adoc#oauth2client[OAuth 2.0 Client] support.
2020-02-19 13:22:51 -05:00
[[nsa-oauth2-client-parents]]
2021-11-01 14:50:25 -06:00
=== Parent Elements of <oauth2-client>
2020-02-19 13:22:51 -05:00
2021-05-28 12:03:16 -05:00
The parent of the `<oauth2-client>` is the <<nsa-http,http>> element.
2020-02-19 13:22:51 -05:00
[[nsa-oauth2-client-attributes]]
2021-11-01 14:50:25 -06:00
=== <oauth2-client> Attributes
2020-02-19 13:22:51 -05:00
2021-04-21 16:01:26 -05:00
The `<oauth2-client>` element has the following attributes:
2020-02-19 13:22:51 -05:00
[[nsa-oauth2-client-client-registration-repository-ref]]
2021-04-21 16:01:26 -05:00
`client-registration-repository-ref`::
2020-02-19 13:22:51 -05:00
Reference to the `ClientRegistrationRepository`.
[[nsa-oauth2-client-authorized-client-repository-ref]]
2021-04-21 16:01:26 -05:00
`authorized-client-repository-ref`::
2020-02-19 13:22:51 -05:00
Reference to the `OAuth2AuthorizedClientRepository`.
[[nsa-oauth2-client-authorized-client-service-ref]]
2021-04-21 16:01:26 -05:00
`authorized-client-service-ref`::
2020-02-19 13:22:51 -05:00
Reference to the `OAuth2AuthorizedClientService`.
[[nsa-oauth2-client-children]]
2021-11-01 14:50:25 -06:00
=== Child Elements of <oauth2-client>
2020-02-19 13:22:51 -05:00
2021-05-28 12:03:16 -05:00
The `<oauth2-client>` has one child element: <<nsa-authorization-code-grant,authorization-code-grant>>.
2020-02-19 13:22:51 -05:00
[[nsa-authorization-code-grant]]
2021-11-01 14:50:25 -06:00
== <authorization-code-grant>
2021-11-04 11:31:27 -06:00
Configures xref:servlet/oauth2/client/authorization-grants.adoc#oauth2Client-auth-grant-support[OAuth 2.0 Authorization Code Grant].
2020-02-19 13:22:51 -05:00
[[nsa-authorization-code-grant-parents]]
2021-11-01 14:50:25 -06:00
=== Parent Elements of <authorization-code-grant>
2020-02-19 13:22:51 -05:00
2021-04-21 16:01:26 -05:00
The parent element of the `<authorization-code-grant>` element is the <<nsa-oauth2-client,`oauth2-client`>> element.
2020-02-19 13:22:51 -05:00
[[nsa-authorization-code-grant-attributes]]
2021-11-01 14:50:25 -06:00
=== <authorization-code-grant> Attributes
2020-02-19 13:22:51 -05:00
2021-04-21 16:01:26 -05:00
The `<authorization-code-grant>` element has the following attributes:
2020-02-19 13:22:51 -05:00
[[nsa-authorization-code-grant-authorization-request-repository-ref]]
2021-04-21 16:01:26 -05:00
`authorization-request-repository-ref`::
2020-02-19 13:22:51 -05:00
Reference to the `AuthorizationRequestRepository`.
[[nsa-authorization-code-grant-authorization-request-resolver-ref]]
2021-04-21 16:01:26 -05:00
`authorization-request-resolver-ref`::
2020-02-19 13:22:51 -05:00
Reference to the `OAuth2AuthorizationRequestResolver`.
[[nsa-authorization-code-grant-access-token-response-client-ref]]
2021-04-21 16:01:26 -05:00
`access-token-response-client-ref`::
2020-02-19 13:22:51 -05:00
Reference to the `OAuth2AccessTokenResponseClient`.
2019-12-11 19:46:10 -05:00
[[nsa-client-registrations]]
2021-11-01 14:50:25 -06:00
== <client-registrations>
2021-12-13 16:57:36 -06:00
The `<client-registrations>` is 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.
2019-12-11 19:46:10 -05:00
[[nsa-client-registrations-children]]
2021-11-01 14:50:25 -06:00
=== Child Elements of <client-registrations>
2019-12-11 19:46:10 -05:00
2021-12-13 16:57:36 -06:00
The `<client-registration>` represents a client registered with an OAuth 2.0 or OpenID Connect 1.0 Provider. You can have multiple `<client-registration>` elements.
2021-04-21 16:01:26 -05:00
2019-12-11 19:46:10 -05:00
* <<nsa-client-registration,client-registration>>
* <<nsa-provider,provider>>
[[nsa-client-registration]]
2021-11-01 14:50:25 -06:00
== <client-registration>
2020-02-19 20:58:20 -05:00
Represents a client registered with an OAuth 2.0 or OpenID Connect 1.0 Provider.
2019-12-11 19:46:10 -05:00
[[nsa-client-registration-parents]]
2021-11-01 14:50:25 -06:00
=== Parent Elements of <client-registration>
2019-12-11 19:46:10 -05:00
2021-04-21 16:01:26 -05:00
The parent element of the `<client-registration>` is the <<nsa-client-registrations,client-registrations>>.
2019-12-11 19:46:10 -05:00
[[nsa-client-registration-attributes]]
2021-11-01 14:50:25 -06:00
=== <client-registration> Attributes
2019-12-11 19:46:10 -05:00
[[nsa-client-registration-registration-id]]
2021-04-21 16:01:26 -05:00
registration-`id`::
2019-12-11 19:46:10 -05:00
The ID that uniquely identifies the `ClientRegistration`.
[[nsa-client-registration-client-id]]
2021-04-21 16:01:26 -05:00
`client-id`::
2019-12-11 19:46:10 -05:00
The client identifier.
[[nsa-client-registration-client-secret]]
2021-04-21 16:01:26 -05:00
`client-secret`::
2019-12-11 19:46:10 -05:00
The client secret.
[[nsa-client-registration-client-authentication-method]]
2021-12-13 16:57:36 -06:00
`client-authentication-method`::
2019-12-11 19:46:10 -05:00
The method used to authenticate the Client with the Provider.
2021-05-14 22:04:28 -04:00
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)].
2019-12-11 19:46:10 -05:00
[[nsa-client-registration-authorization-grant-type]]
2021-04-21 16:01:26 -05:00
`authorization-grant-type`::
2019-12-11 19:46:10 -05:00
The OAuth 2.0 Authorization Framework defines four https://tools.ietf.org/html/rfc6749#section-1.3[Authorization Grant] types.
2021-05-14 10:17:20 -04:00
The supported values are `authorization_code`, `client_credentials`, `password`, as well as, extension grant type `urn:ietf:params:oauth:grant-type:jwt-bearer`.
2019-12-11 19:46:10 -05:00
[[nsa-client-registration-redirect-uri]]
2021-04-21 16:01:26 -05:00
`redirect-uri`::
The client's registered redirect URI to which the _Authorization Server_ redirects the end-user's user-agent after the end-user has authenticated and authorized access to the client.
2019-12-11 19:46:10 -05:00
[[nsa-client-registration-scope]]
2021-04-21 16:01:26 -05:00
`scope`::
The scope(s) requested by the client during the Authorization Request flow, such as `openid`, `email`, or `profile`.
2019-12-11 19:46:10 -05:00
[[nsa-client-registration-client-name]]
2021-04-21 16:01:26 -05:00
`client-name`::
2019-12-11 19:46:10 -05:00
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]]
2021-12-13 16:57:36 -06:00
`provider-id`::
2021-04-21 16:01:26 -05:00
A reference to the associated provider. May reference a `<provider>` element or use one of the common providers (Google, Github, Facebook, Okta, and others).
2019-12-11 19:46:10 -05:00
[[nsa-provider]]
2021-11-01 14:50:25 -06:00
== <provider>
2021-04-21 16:01:26 -05:00
The `<provider>` element contains the configuration information for an OAuth 2.0 or OpenID Connect 1.0 Provider.
2019-12-11 19:46:10 -05:00
[[nsa-provider-parents]]
2021-11-01 14:50:25 -06:00
=== Parent Elements of <provider>
2019-12-11 19:46:10 -05:00
2021-05-28 12:03:16 -05:00
The parent element of the `<provider>` element is the <<nsa-client-registrations,client-registrations>> element.
2019-12-11 19:46:10 -05:00
[[nsa-provider-attributes]]
2021-11-01 14:50:25 -06:00
=== <provider> Attributes
2019-12-11 19:46:10 -05:00
2021-04-21 16:01:26 -05:00
The `<provider>` element has the following attributes:
2019-12-11 19:46:10 -05:00
[[nsa-provider-provider-id]]
2021-04-21 16:01:26 -05:00
`provider-id`::
2019-12-11 19:46:10 -05:00
The ID that uniquely identifies the provider.
[[nsa-provider-authorization-uri]]
2021-04-21 16:01:26 -05:00
`authorization-uri`::
The authorization endpoint URI for the authorization server.
2019-12-11 19:46:10 -05:00
[[nsa-provider-token-uri]]
2021-04-21 16:01:26 -05:00
`token-uri`::
The token endpoint URI for the authorization server.
2019-12-11 19:46:10 -05:00
2020-03-02 14:13:59 -05:00
[[nsa-provider-user-info-uri]]
2021-04-21 16:01:26 -05:00
`user-info-uri`::
The UserInfo endpoint URI used to access the claims and attributes of the authenticated end user.
2019-12-11 19:46:10 -05:00
2020-03-02 14:13:59 -05:00
[[nsa-provider-user-info-authentication-method]]
2021-04-21 16:01:26 -05:00
`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`.
2019-12-11 19:46:10 -05:00
2020-03-02 14:13:59 -05:00
[[nsa-provider-user-info-user-name-attribute]]
* **user-info-user-name-attribute**
2021-04-21 16:01:26 -05:00
`user-info-user-name-attribute`::
The name of the attribute returned in the UserInfo response that references the name or edentifier of the end-user.
2019-12-11 19:46:10 -05:00
2020-03-02 14:13:59 -05:00
[[nsa-provider-jwk-set-uri]]
2021-04-21 16:01:26 -05:00
`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.
2019-12-11 19:46:10 -05:00
[[nsa-provider-issuer-uri]]
2021-04-21 16:01:26 -05:00
issuer-uri::
The URI used to initially configure a `ClientRegistration` by 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].
2019-12-11 19:46:10 -05:00
2019-12-30 09:18:29 -07:00
[[nsa-oauth2-resource-server]]
2021-11-01 14:50:25 -06:00
== <oauth2-resource-server>
2021-04-21 16:01:26 -05:00
Adds a `BearerTokenAuthenticationFilter`, a `BearerTokenAuthenticationEntryPoint`, and a `BearerTokenAccessDeniedHandler` to the configuration.
2019-12-30 09:18:29 -07:00
In addition, either `<jwt>` or `<opaque-token>` must be specified.
[[nsa-oauth2-resource-server-parents]]
2021-11-01 14:50:25 -06:00
=== Parents Elements of <oauth2-resource-server>
2019-12-30 09:18:29 -07:00
2021-05-28 12:03:16 -05:00
The parent element of the `<oauth2-resource-server>` is the <<nsa-http,http>> element.
2019-12-30 09:18:29 -07:00
[[nsa-oauth2-resource-server-children]]
2021-11-01 14:50:25 -06:00
=== Child Elements of <oauth2-resource-server>
2019-12-30 09:18:29 -07:00
2021-12-13 16:57:36 -06:00
The `<oauth2-resource-server>` element has the following attributes:
2021-04-21 16:01:26 -05:00
2019-12-30 09:18:29 -07:00
* <<nsa-jwt,jwt>>
* <<nsa-opaque-token,opaque-token>>
[[nsa-oauth2-resource-server-attributes]]
2021-11-01 14:50:25 -06:00
=== <oauth2-resource-server> Attributes
2019-12-30 09:18:29 -07:00
[[nsa-oauth2-resource-server-authentication-manager-resolver-ref]]
2021-04-21 16:01:26 -05:00
`authentication-manager-resolver-ref`::
Reference to an `AuthenticationManagerResolver`, which resolves the `AuthenticationManager` at request time.
2019-12-30 09:18:29 -07:00
[[nsa-oauth2-resource-server-bearer-token-resolver-ref]]
2021-04-21 16:01:26 -05:00
`bearer-token-resolver-ref`::
Reference to a `BearerTokenResolver`, which retrieves the bearer token from the request.
2019-12-30 09:18:29 -07:00
[[nsa-oauth2-resource-server-entry-point-ref]]
2021-04-21 16:01:26 -05:00
`entry-point-ref`::
Reference to a `AuthenticationEntryPoint`, which handles unauthorized requests.
2019-12-30 09:18:29 -07:00
[[nsa-jwt]]
2021-11-01 14:50:25 -06:00
== <jwt>
2021-04-21 16:01:26 -05:00
The `<jwt>` element represents an OAuth 2.0 Resource Server that authorizes JWTs (JSON Web Tokens).
2019-12-30 09:18:29 -07:00
[[nsa-jwt-parents]]
2021-11-01 14:50:25 -06:00
=== Parent Elements of <jwt>
2019-12-30 09:18:29 -07:00
2021-05-28 12:03:16 -05:00
The parent element of the `<jwt>` element is the <<nsa-oauth2-resource-server,oauth2-resource-server>> element.
2019-12-30 09:18:29 -07:00
[[nsa-jwt-attributes]]
2021-11-01 14:50:25 -06:00
=== <jwt> Attributes
2019-12-30 09:18:29 -07:00
2021-04-21 16:01:26 -05:00
The `<jwt>` element has the following attributes:
2019-12-30 09:18:29 -07:00
[[nsa-jwt-jwt-authentication-converter-ref]]
2021-04-21 16:01:26 -05:00
`jwt-authentication-converter-ref`::
Reference to a `Converter<Jwt, AbstractAuthenticationToken>`.
2019-12-30 09:18:29 -07:00
[[nsa-jwt-decoder-ref]]
2021-04-21 16:01:26 -05:00
`jwt-decoder-ref`::
Reference to a `JwtDecoder`. This is a larger component that overrides `jwk-set-uri`.
2019-12-30 09:18:29 -07:00
[[nsa-jwt-jwk-set-uri]]
2021-04-21 16:01:26 -05:00
`jwk-set-uri`::
The JWK Set URI used to load signing verification keys from an OAuth 2.0 Authorization Server.
2019-12-30 09:18:29 -07:00
[[nsa-opaque-token]]
2021-11-01 14:50:25 -06:00
== <opaque-token>
2021-04-21 16:01:26 -05:00
Represents an OAuth 2.0 Resource Server that authorizes opaque tokens.
2019-12-30 09:18:29 -07:00
[[nsa-opaque-token-parents]]
2021-11-01 14:50:25 -06:00
=== Parent Elements of <opaque-token>
2019-12-30 09:18:29 -07:00
2021-04-21 16:01:26 -05:00
The parent element of the `<opaque-token` element is the <<nsa-oauth2-resource-server,`oauth2-resource-server`>> element.
2019-12-30 09:18:29 -07:00
[[nsa-opaque-token-attributes]]
2021-11-01 14:50:25 -06:00
=== <opaque-token> Attributes
2019-12-30 09:18:29 -07:00
[[nsa-opaque-token-introspector-ref]]
2021-04-21 16:01:26 -05:00
`introspector-ref`::
2019-12-30 09:18:29 -07:00
Reference to an `OpaqueTokenIntrospector`. This is a larger component that overrides `introspection-uri`, `client-id`, and `client-secret`.
[[nsa-opaque-token-introspection-uri]]
2021-04-21 16:01:26 -05:00
`introspection-uri`::
The Introspection URI used to introspect the details of an opaque token. It should be accompanied by a `client-id` and `client-secret`.
2019-12-30 09:18:29 -07:00
[[nsa-opaque-token-client-id]]
2021-04-21 16:01:26 -05:00
`client-id`::
The client ID to use for client authentication against the provided `introspection-uri`.
2019-12-30 09:18:29 -07:00
[[nsa-opaque-token-client-secret]]
2021-04-21 16:01:26 -05:00
`client-secret`::
The client secret to use for client authentication against the provided `introspection-uri`.
2019-12-11 19:46:10 -05:00
2018-03-05 16:10:47 -06:00
[[nsa-http-basic]]
2021-11-01 14:50:25 -06:00
== <http-basic>
2021-04-21 16:01:26 -05:00
The <http-basic element> adds a `BasicAuthenticationFilter` and `BasicAuthenticationEntryPoint` to the configuration.
The latter is used as the configuration entry point only if form-based login is not enabled.
2018-03-05 16:10:47 -06:00
[[nsa-http-basic-parents]]
2021-11-01 14:50:25 -06:00
=== Parent Elements of <http-basic>
2018-03-05 16:10:47 -06:00
2021-05-28 12:03:16 -05:00
The parent element of the `<http-basic>` element is the <<nsa-http,http>> element.
2018-03-05 16:10:47 -06:00
[[nsa-http-basic-attributes]]
2021-11-01 14:50:25 -06:00
=== <http-basic> Attributes
2018-03-05 16:10:47 -06:00
2021-04-21 16:01:26 -05:00
The `<http-basic>` element has the following attributes:
2018-03-05 16:10:47 -06:00
[[nsa-http-basic-authentication-details-source-ref]]
2021-04-21 16:01:26 -05:00
`authentication-details-source-ref`::
Reference to an `AuthenticationDetailsSource`, which is used by the authentication filter.
2018-03-05 16:10:47 -06:00
[[nsa-http-basic-entry-point-ref]]
2021-04-21 16:01:26 -05:00
`entry-point-ref`::
Sets the `AuthenticationEntryPoint`, which is used by the `BasicAuthenticationFilter`.
2018-03-05 16:10:47 -06:00
[[nsa-http-firewall]]
2021-11-01 14:50:25 -06:00
== <http-firewall> Element
2021-04-21 16:01:26 -05:00
`<http-firewall>` is a top-level element that you can use to inject a custom implementation of `HttpFirewall` into the `FilterChainProxy` created by the namespace.
2018-03-05 16:10:47 -06:00
[[nsa-http-firewall-attributes]]
2021-11-01 14:50:25 -06:00
=== <http-firewall> Attributes
2018-03-05 16:10:47 -06:00
2021-04-21 16:01:26 -05:00
`<http-firewall>` has a single attribute:
2018-03-05 16:10:47 -06:00
[[nsa-http-firewall-ref]]
2021-04-21 16:01:26 -05:00
`ref`::
2018-03-05 16:10:47 -06:00
Defines a reference to a Spring bean that implements `HttpFirewall`.
[[nsa-intercept-url]]
2021-11-01 14:50:25 -06:00
== <intercept-url>
2021-04-21 16:01:26 -05:00
`<intercept-url>` element defines the set of URL patterns that the application is interested in and configures how they should be handled.
It constructs 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).
2018-03-05 16:10:47 -06:00
When matching the specified patterns against an incoming request, the matching is done in the order in which the elements are declared.
2021-04-21 16:01:26 -05:00
So, the most specific patterns should come first and the most general should come last.
2018-03-05 16:10:47 -06:00
[[nsa-intercept-url-parents]]
2021-11-01 14:50:25 -06:00
=== Parent Elements of <intercept-url>
2018-03-05 16:10:47 -06:00
2021-04-21 16:01:26 -05:00
The parent elements of the `<intercept-url>` element are:
2018-03-05 16:10:47 -06:00
* <<nsa-filter-security-metadata-source,filter-security-metadata-source>>
* <<nsa-http,http>>
[[nsa-intercept-url-attributes]]
2021-11-01 14:50:25 -06:00
=== <intercept-url> Attributes
2018-03-05 16:10:47 -06:00
2021-04-21 16:01:26 -05:00
The `<intercept-url>` element has the following parameters:
2018-03-05 16:10:47 -06:00
[[nsa-intercept-url-access]]
2021-04-21 16:01:26 -05:00
`access`::
Lists the access attributes, which are stored in the `FilterInvocationSecurityMetadataSource` for the defined URL pattern and method combination.
2018-03-05 16:10:47 -06:00
This should be a comma-separated list of the security configuration attributes (such as role names).
[[nsa-intercept-url-method]]
2021-04-21 16:01:26 -05:00
`method`::
The HTTP Method that is used in combination with the pattern and servlet path (optional) to match an incoming request.
If omitted, any method matchs.
If an identical pattern is specified with and without a method, the method-specific match takes precedence.
2018-03-05 16:10:47 -06:00
[[nsa-intercept-url-pattern]]
2021-04-21 16:01:26 -05:00
`pattern`::
The pattern that defines the URL path.
The content depends on the `request-matcher` attribute from the containing `<http>` element, so it defaults to Ant path syntax.
2018-03-05 16:10:47 -06:00
[[nsa-intercept-url-request-matcher-ref]]
2021-04-21 16:01:26 -05:00
`request-matcher-ref`::
A reference to a `RequestMatcher` that is used to determine if this `<intercept-url>` is used.
2018-03-05 16:10:47 -06:00
[[nsa-intercept-url-requires-channel]]
2021-04-21 16:01:26 -05:00
`requires-channel`::
Can be `http` or `https`, depending on whether a particular URL pattern should be accessed over HTTP or HTTPS, respectively.
Alternatively, you can use a value of `any` when you have no preference.
If this attribute is present on any `<intercept-url>` element, a `ChannelProcessingFilter` is added to the filter stack and its additional dependencies are added to the application context.
2018-03-05 16:10:47 -06:00
2021-04-21 16:01:26 -05:00
If a `<port-mappings>` configuration is added, it is used by the `SecureChannelProcessor` and `InsecureChannelProcessor` beans to determine the ports used for redirecting to HTTP and HTTPS.
2018-03-05 16:10:47 -06:00
2021-06-04 14:12:59 -05:00
[NOTE]
====
This property is invalid for <<nsa-filter-security-metadata-source,`filter-security-metadata-source`>>
====
2018-03-05 16:10:47 -06:00
[[nsa-intercept-url-servlet-path]]
2021-04-21 16:01:26 -05:00
`servlet-path`::
The servlet path to 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 two use cases:
* Two or more `HttpServlet` instances that have mappings starting with `/` and are different are registered in the `ServletContext`.
* The pattern starts with the same value of a registered `HttpServlet` path, excluding the default (root) `HttpServlet` `/`.
2018-03-05 16:10:47 -06:00
2021-06-04 14:12:59 -05:00
[NOTE]
====
This property is invalid for <<nsa-filter-security-metadata-source,`filter-security-metadata-source`>>
====
2018-03-05 16:10:47 -06:00
[[nsa-jee]]
2021-11-01 14:50:25 -06:00
== <jee>
2021-12-13 16:57:36 -06:00
The `<jee>` element adds a `J2eePreAuthenticatedProcessingFilter` to the filter chain to provide integration with container authentication.
2018-03-05 16:10:47 -06:00
[[nsa-jee-parents]]
2021-11-01 14:50:25 -06:00
=== Parent Elements of <jee>
2018-03-05 16:10:47 -06:00
2021-05-28 12:03:16 -05:00
The parent element of the `<jee>` element is the <<nsa-http,http>> element.
2018-03-05 16:10:47 -06:00
[[nsa-jee-attributes]]
2021-11-01 14:50:25 -06:00
=== <jee> Attributes
2018-03-05 16:10:47 -06:00
2021-04-21 16:01:26 -05:00
The `<jee>` element has the following attributes:
2018-03-05 16:10:47 -06:00
[[nsa-jee-mappable-roles]]
2021-04-21 16:01:26 -05:00
`mappable-roles`::
A comma-separated list of roles to look for in the incoming `HttpServletRequest`.
2018-03-05 16:10:47 -06:00
[[nsa-jee-user-service-ref]]
2021-04-21 16:01:26 -05:00
`user-service-ref`::
A reference to a user-service (or `UserDetailsService` bean) ID.
2018-03-05 16:10:47 -06:00
[[nsa-logout]]
2021-11-01 14:50:25 -06:00
== <logout>
2021-04-21 16:01:26 -05:00
The `<logout>` element adds a `LogoutFilter` to the filter stack.
It is configured by a `SecurityContextLogoutHandler`.
2018-03-05 16:10:47 -06:00
[[nsa-logout-parents]]
2021-11-01 14:50:25 -06:00
=== Parent Elements of <logout>
2018-03-05 16:10:47 -06:00
2021-05-28 12:03:16 -05:00
The parent element of the `<logout>` element is the <<nsa-http,http>> element.
2018-03-05 16:10:47 -06:00
[[nsa-logout-attributes]]
2021-11-01 14:50:25 -06:00
=== <logout> Attributes
2018-03-05 16:10:47 -06:00
2021-04-21 16:01:26 -05:00
The `<logout>` element has the following attributes:
2018-03-05 16:10:47 -06:00
[[nsa-logout-delete-cookies]]
2021-04-21 16:01:26 -05:00
`delete-cookies`::
A comma-separated list of the names of cookies that should be deleted when the user logs out.
2018-03-05 16:10:47 -06:00
[[nsa-logout-invalidate-session]]
2021-04-21 16:01:26 -05:00
`invalidate-session`::
2018-03-05 16:10:47 -06:00
Maps to the `invalidateHttpSession` of the `SecurityContextLogoutHandler`.
2021-04-21 16:01:26 -05:00
Default: `true` (the session is invalidated on logout)
2018-03-05 16:10:47 -06:00
[[nsa-logout-logout-success-url]]
2021-04-21 16:01:26 -05:00
`logout-success-url`::
The destination URL to which the user is taken after logging out.
2018-03-05 16:10:47 -06:00
+
2021-04-21 16:01:26 -05:00
Setting this attribute injects the `SessionManagementFilter` with a `SimpleRedirectInvalidSessionStrategy` configured with the attribute value.
When an invalid session ID is submitted, the strategy is invoked, redirecting to the configured URL.
2018-03-05 16:10:47 -06:00
[[nsa-logout-logout-url]]
2021-04-21 16:01:26 -05:00
`logout-url`::
The URL that causes a logout (which is processed by the filter).
Default: `/logout`
2018-03-05 16:10:47 -06:00
[[nsa-logout-success-handler-ref]]
2021-04-21 16:01:26 -05:00
`success-handler-ref`::
Can be used to supply an instance of `LogoutSuccessHandler` that is invoked to control the navigation after logging out.
2018-03-05 16:10:47 -06:00
[[nsa-openid-login]]
2021-11-01 14:50:25 -06:00
== <openid-login>
2021-04-21 16:01:26 -05:00
The `<openid-login>` element is similar to the `<form-login>` element and has the same attributes.
The default value for `login-processing-url` is `/login/openid`.
An `OpenIDAuthenticationFilter` and a `OpenIDAuthenticationProvider` are registered.
2018-03-05 16:10:47 -06:00
The latter requires a reference to a `UserDetailsService`.
2021-04-21 16:01:26 -05:00
You can specify this reference by `id`, by using the `user-service-ref` attribute, or you can let it be automatically located in the application context.
2018-03-05 16:10:47 -06:00
[[nsa-openid-login-parents]]
2021-11-01 14:50:25 -06:00
=== Parent Elements of <openid-login>
2018-03-05 16:10:47 -06:00
2021-05-28 12:03:16 -05:00
The parent element of the `<openid-login>` element is the <<nsa-http,http>> element.
2018-03-05 16:10:47 -06:00
[[nsa-openid-login-attributes]]
2021-11-01 14:50:25 -06:00
=== <openid-login> Attributes
2018-03-05 16:10:47 -06:00
2021-04-21 16:01:26 -05:00
The `<openid-login>` element has the following attributes:
2018-03-05 16:10:47 -06:00
[[nsa-openid-login-always-use-default-target]]
2021-04-21 16:01:26 -05:00
`always-use-default-target`::
Whether the user should always be redirected to the `default-target-url` after login.
2018-03-05 16:10:47 -06:00
[[nsa-openid-login-authentication-details-source-ref]]
2021-04-21 16:01:26 -05:00
`authentication-details-source-ref`::
Reference to an `AuthenticationDetailsSource` that is used by the authentication filter.
2018-03-05 16:10:47 -06:00
[[nsa-openid-login-authentication-failure-handler-ref]]
2021-04-21 16:01:26 -05:00
`authentication-failure-handler-ref`::
Reference to an `AuthenticationFailureHandler` bean that should be used to handle a failed authentication request.
It should not be used in combination with `authentication-failure-url`, as the implementation should always deal with navigation to the subsequent destination.
2018-03-05 16:10:47 -06:00
[[nsa-openid-login-authentication-failure-url]]
2021-04-21 16:01:26 -05:00
authentication-failure-url::
2018-03-05 16:10:47 -06:00
The URL for the login failure page.
2021-04-21 16:01:26 -05:00
If no login failure URL is specified, Spring Security automatically creates a failure login URL at `/login?login_error` and a corresponding filter to render that login failure URL when requested.
2018-03-05 16:10:47 -06:00
[[nsa-openid-login-authentication-success-forward-url]]
2021-04-21 16:01:26 -05:00
authentication-success-forward-url::
2018-03-05 16:10:47 -06:00
Maps a `ForwardAuthenticationSuccessHandler` to `authenticationSuccessHandler` property of `UsernamePasswordAuthenticationFilter`.
[[nsa-openid-login-authentication-failure-forward-url]]
2021-04-21 16:01:26 -05:00
`authentication-failure-forward-url`::
2018-03-05 16:10:47 -06:00
Maps a `ForwardAuthenticationFailureHandler` to `authenticationFailureHandler` property of `UsernamePasswordAuthenticationFilter`.
[[nsa-openid-login-authentication-success-handler-ref]]
2021-04-21 16:01:26 -05:00
`authentication-success-handler-ref`::
Reference to an `AuthenticationSuccessHandler` bean that should be used to handle a successful authentication request.
Should not be used in combination with <<nsa-openid-login-default-target-url,default-target-url>> (or <<nsa-openid-login-always-use-default-target,`always-use-default-target`>>) as the implementation should always deal with navigation to the subsequent destination
2018-03-05 16:10:47 -06:00
[[nsa-openid-login-default-target-url]]
2021-04-21 16:01:26 -05:00
`default-target-url`::
The URL to which to redirect after successful authentication, if the user's previous action could not be resumed.
2018-03-05 16:10:47 -06:00
This generally happens if the user visits a login page without having first requested a secured operation that triggers authentication.
2021-04-21 16:01:26 -05:00
If unspecified, it defaults to the root of the application.
2018-03-05 16:10:47 -06:00
[[nsa-openid-login-login-page]]
2021-04-21 16:01:26 -05:00
`login-page`::
2018-03-05 16:10:47 -06:00
The URL for the login page.
2021-04-21 16:01:26 -05:00
If no login URL is specified, Spring Security automatically creates a login URL at `/login` and a corresponding filter to render that login URL when requested.
2018-03-05 16:10:47 -06:00
[[nsa-openid-login-login-processing-url]]
2021-04-21 16:01:26 -05:00
`login-processing-url`::
The URL to which the login form is posted.
If unspecified, it defaults to `/login`.
2018-03-05 16:10:47 -06:00
[[nsa-openid-login-password-parameter]]
2021-04-21 16:01:26 -05:00
`password-parameter`::
The name of the request parameter that contains the password.
Default: `password`
2018-03-05 16:10:47 -06:00
[[nsa-openid-login-user-service-ref]]
2021-04-21 16:01:26 -05:00
`user-service-ref`::
A reference to a user-service (or `UserDetailsService` bean) ID
2018-03-05 16:10:47 -06:00
[[nsa-openid-login-username-parameter]]
2021-04-21 16:01:26 -05:00
`username-parameter`::
The name of the request parameter that contains the username.
Default: `username`
2018-03-05 16:10:47 -06:00
[[nsa-openid-login-children]]
2021-11-01 14:50:25 -06:00
=== Child Elements of <openid-login>
2021-05-28 12:03:16 -05:00
The `<openid-login>` element has only one child attribute: <<nsa-attribute-exchange,attribute-exchange>>.
2018-03-05 16:10:47 -06:00
[[nsa-attribute-exchange]]
2021-11-01 14:50:25 -06:00
== <attribute-exchange>
2021-04-21 16:01:26 -05:00
The `<attribute-exchange>` element defines the list of attributes to request from the identity provider.
2021-12-13 16:57:36 -06:00
You can find an example in the xref:servlet/authentication/openid.adoc#servlet-openid[OpenID Support] section of the namespace configuration chapter.
2021-04-21 16:01:26 -05:00
You can use more than one. In that case, each must have an `identifier-match` attribute that contains a regular expression, which is matched against the supplied OpenID identifier.
This lets different attribute lists be fetched from different providers (Google, Yahoo, and others).
2018-03-05 16:10:47 -06:00
[[nsa-attribute-exchange-parents]]
2021-11-01 14:50:25 -06:00
=== Parent Elements of <attribute-exchange>
2018-03-05 16:10:47 -06:00
2021-05-28 12:03:16 -05:00
The parent element of the `<attribute-exchange>` element is the <<nsa-openid-login,openid-login>> element.
2018-03-05 16:10:47 -06:00
[[nsa-attribute-exchange-attributes]]
2021-11-01 14:50:25 -06:00
=== <attribute-exchange> Attributes
2018-03-05 16:10:47 -06:00
2021-04-21 16:01:26 -05:00
The `<attribute-exchange>` element has a single attribute:
2018-03-05 16:10:47 -06:00
[[nsa-attribute-exchange-identifier-match]]
2021-04-21 16:01:26 -05:00
`identifier-match`::
A regular expression that is compared against the claimed identity when deciding which `attribute-exchange` configuration to use during authentication.
2018-03-05 16:10:47 -06:00
[[nsa-attribute-exchange-children]]
2021-11-01 14:50:25 -06:00
=== Child Elements of <attribute-exchange>
2018-03-05 16:10:47 -06:00
2021-05-28 12:03:16 -05:00
The `<attribute-exchange>` element has a single child attribute: <<nsa-openid-attribute,openid-attribute>>.
2018-03-05 16:10:47 -06:00
[[nsa-openid-attribute]]
2021-11-01 14:50:25 -06:00
== <openid-attribute>
2021-04-21 16:01:26 -05:00
The `<openid-attribute>` element defines the attributes to use when making an OpenID AX https://openid.net/specs/openid-attribute-exchange-1_0.html#fetch_request[ Fetch Request].
2018-03-05 16:10:47 -06:00
[[nsa-openid-attribute-parents]]
2021-11-01 14:50:25 -06:00
=== Parent Elements of <openid-attribute>
2018-03-05 16:10:47 -06:00
2021-04-21 16:01:26 -05:00
The parent element of the `<openid-attribute>` element is the <<nsa-attribute-exchange,`attribute-exchange`>> element.
2018-03-05 16:10:47 -06:00
[[nsa-openid-attribute-attributes]]
2021-11-01 14:50:25 -06:00
=== <openid-attribute> Attributes
2018-03-05 16:10:47 -06:00
2021-04-21 16:01:26 -05:00
The `<openid-attribute>` element has the following attributes:
2018-03-05 16:10:47 -06:00
[[nsa-openid-attribute-count]]
2021-04-21 16:01:26 -05:00
`count`::
Specifies the number of attributes that you wish to get back -- for example, return three emails.
Default: 1
2018-03-05 16:10:47 -06:00
[[nsa-openid-attribute-name]]
2021-04-21 16:01:26 -05:00
`name`::
Specifies the name of the attribute that you wish to get back -- for example, `email`.
2018-03-05 16:10:47 -06:00
[[nsa-openid-attribute-required]]
2021-04-21 16:01:26 -05:00
`required`::
Specifies whether this attribute is required to the OP but does not error out if the OP does not return the attribute.
Default: `false`
2018-03-05 16:10:47 -06:00
[[nsa-openid-attribute-type]]
2021-04-21 16:01:26 -05:00
`type`::
Specifies the attribute type -- for example, `https://axschema.org/contact/email`.
2018-03-05 16:10:47 -06:00
See your OP's documentation for valid attribute types.
2020-06-12 18:00:51 +03:00
[[nsa-password-management]]
2021-11-01 14:50:25 -06:00
== <password-management>
2020-06-12 18:00:51 +03:00
This element configures password management.
[[nsa-password-management-parents]]
2021-11-01 14:50:25 -06:00
=== Parent Elements of <password-management>
2020-06-12 18:00:51 +03:00
* <<nsa-http,http>>
[[nsa-password-management-attributes]]
2021-11-01 14:50:25 -06:00
=== <password-management> Attributes
2020-06-12 18:00:51 +03:00
[[nsa-password-management-change-password-page]]
2021-12-13 16:57:36 -06:00
`hange-password-page`::
2020-06-12 18:00:51 +03:00
The change password page. Defaults to "/change-password".
2018-03-05 16:10:47 -06:00
[[nsa-port-mappings]]
2021-11-01 14:50:25 -06:00
== <port-mappings>
2021-04-21 16:01:26 -05:00
By default, an instance of `PortMapperImpl` is added to the configuration for use in redirecting to secure and insecure URLs.
You can optionally use the `<port-mappings>` element to override the default mappings that `PortMapperImpl` defines.
2018-03-05 16:10:47 -06:00
Each child `<port-mapping>` element defines a pair of HTTP:HTTPS ports.
2021-04-21 16:01:26 -05:00
The default mappings are `80:443` and `8080:8443`.
2021-12-13 16:57:36 -06:00
You can find an example of overriding these values in << xref:servlet/exploits/http.adoc#servlet-http-redirect[Redirect to HTTPS].
2018-03-05 16:10:47 -06:00
[[nsa-port-mappings-parents]]
2021-11-01 14:50:25 -06:00
=== Parent Elements of <port-mappings>
2018-03-05 16:10:47 -06:00
2021-05-28 12:03:16 -05:00
The parent element of the `<port-mappings>` element is the <<nsa-http,http>> element.
2018-03-05 16:10:47 -06:00
[[nsa-port-mappings-children]]
2021-11-01 14:50:25 -06:00
=== Child Elements of <port-mappings>
2018-03-05 16:10:47 -06:00
2021-04-21 16:01:26 -05:00
The `<port-mappings>` element has a single child element: <<nsa-port-mapping,`port-mapping`>>.
2018-03-05 16:10:47 -06:00
[[nsa-port-mapping]]
2021-11-01 14:50:25 -06:00
== <port-mapping>
2018-03-05 16:10:47 -06:00
Provides a method to map http ports to https ports when forcing a redirect.
[[nsa-port-mapping-parents]]
2021-11-01 14:50:25 -06:00
=== Parent Elements of <port-mapping>
2018-03-05 16:10:47 -06:00
2021-05-28 12:03:16 -05:00
The parent element of the `<port-mapping>` element is the <<nsa-port-mappings,port-mappings>> element.
2018-03-05 16:10:47 -06:00
[[nsa-port-mapping-attributes]]
2021-11-01 14:50:25 -06:00
=== <port-mapping> Attributes
2018-03-05 16:10:47 -06:00
2021-04-21 16:01:26 -05:00
The `<port-mapping>` element has the following attributes:
2018-03-05 16:10:47 -06:00
[[nsa-port-mapping-http]]
2021-04-21 16:01:26 -05:00
`http`::
The HTTP port to use.
2018-03-05 16:10:47 -06:00
[[nsa-port-mapping-https]]
2021-04-21 16:01:26 -05:00
`https`::
The HTTPS port to use.
2018-03-05 16:10:47 -06:00
[[nsa-remember-me]]
2021-11-01 14:50:25 -06:00
== <remember-me>
2021-04-21 16:01:26 -05:00
The `<remember-me>` element adds the `RememberMeAuthenticationFilter` to the stack.
This filter is, in turn, configured with either a `TokenBasedRememberMeServices`, a `PersistentTokenBasedRememberMeServices`, or a user-specified bean that implements `RememberMeServices`, depending on the attribute settings.
2018-03-05 16:10:47 -06:00
[[nsa-remember-me-parents]]
2021-11-01 14:50:25 -06:00
=== Parent Elements of <remember-me>
2018-03-05 16:10:47 -06:00
2021-05-28 12:03:16 -05:00
The parent element of the `<remember-me>` element is the <<nsa-http,http>> element.
2018-03-05 16:10:47 -06:00
[[nsa-remember-me-attributes]]
2021-11-01 14:50:25 -06:00
=== <remember-me> Attributes
2018-03-05 16:10:47 -06:00
2021-04-21 16:01:26 -05:00
The `<remember-me>` element has the following attributes:
2018-03-05 16:10:47 -06:00
[[nsa-remember-me-authentication-success-handler-ref]]
2021-04-21 16:01:26 -05:00
`authentication-success-handler-ref`::
Sets the `authenticationSuccessHandler` property on the `RememberMeAuthenticationFilter` when custom navigation is required.
2018-03-05 16:10:47 -06:00
The value should be the name of a `AuthenticationSuccessHandler` bean in the application context.
[[nsa-remember-me-data-source-ref]]
2021-04-21 16:01:26 -05:00
`data-source-ref`::
2018-03-05 16:10:47 -06:00
A reference to a `DataSource` bean.
2021-04-21 16:01:26 -05:00
If this attribute is set, `PersistentTokenBasedRememberMeServices` is used and configured with a `JdbcTokenRepositoryImpl` instance.
2018-03-05 16:10:47 -06:00
[[nsa-remember-me-remember-me-parameter]]
2021-04-21 16:01:26 -05:00
`remember-me-parameter`::
The name of the request parameter that toggles remember-me authentication.
Defaults: `remember-me`
Maps to the `parameter` property of `AbstractRememberMeServices`.
2018-03-05 16:10:47 -06:00
[[nsa-remember-me-remember-me-cookie]]
2021-04-21 16:01:26 -05:00
`remember-me-cookie`::
The name of the cookie that stores the token for remember-me authentication.
Defaults: `remember-me`
This attribute maps to the `cookieName` property of `AbstractRememberMeServices`.
2018-03-05 16:10:47 -06:00
[[nsa-remember-me-key]]
2021-04-21 16:01:26 -05:00
`key`::
Maps to the `key` property of `AbstractRememberMeServices`.
Should be set to a unique value to ensure that remember-me cookies are valid only within one application
This key does not affect the use of `PersistentTokenBasedRememberMeServices`, where the tokens are stored on the server side.
If this key is not set, a secure random value is generated.
Since generating secure random values can take a while, explicitly setting this value can help improve startup times when you use the remember-me functionality.
2018-03-05 16:10:47 -06:00
[[nsa-remember-me-services-alias]]
2021-04-21 16:01:26 -05:00
`services-alias`::
Exports the internally defined `RememberMeServices` as a bean alias, letting it be used by other beans in the application context.
2018-03-05 16:10:47 -06:00
[[nsa-remember-me-services-ref]]
2021-04-21 16:01:26 -05:00
`services-ref`::
Allows complete control of the `RememberMeServices` implementation that is used by the filter.
The value should be the `id` of a bean in the application context that implements this interface.
It should also implement `LogoutHandler` if a logout filter is in use.
2018-03-05 16:10:47 -06:00
[[nsa-remember-me-token-repository-ref]]
2021-04-21 16:01:26 -05:00
`token-repository-ref`::
2018-03-05 16:10:47 -06:00
Configures a `PersistentTokenBasedRememberMeServices` but allows the use of a custom `PersistentTokenRepository` bean.
[[nsa-remember-me-token-validity-seconds]]
2021-04-21 16:01:26 -05:00
`token-validity-seconds`::
2018-03-05 16:10:47 -06:00
Maps to the `tokenValiditySeconds` property of `AbstractRememberMeServices`.
Specifies the period in seconds for which the remember-me cookie should be valid.
2021-04-21 16:01:26 -05:00
By default, it is valid for 14 days.
2018-03-05 16:10:47 -06:00
[[nsa-remember-me-use-secure-cookie]]
2021-04-21 16:01:26 -05:00
`use-secure-cookie`::
We recommend that you submit remember-me cookies over HTTPS and that you flag as "`secure`".
By default, a secure cookie is used if the connection for the login request is secure (as it should be).
If you set this property to `false`, secure cookies are not used.
Setting it to `true` always sets the secure flag on the cookie.
2018-03-05 16:10:47 -06:00
This attribute maps to the `useSecureCookie` property of `AbstractRememberMeServices`.
[[nsa-remember-me-user-service-ref]]
2021-04-21 16:01:26 -05:00
`user-service-ref`::
2018-03-05 16:10:47 -06:00
The remember-me services implementations require access to a `UserDetailsService`, so there has to be one defined in the application context.
2021-04-21 16:01:26 -05:00
If there is only one, it is selected and automatically used by the namespace configuration.
If there are multiple instances, you can specify a bean `id` explicitly by setting this attribute.
2018-03-05 16:10:47 -06:00
[[nsa-request-cache]]
2021-11-01 14:50:25 -06:00
== <request-cache> Element
2021-04-21 16:01:26 -05:00
Sets the `RequestCache` instance, which is used by the `ExceptionTranslationFilter` to store request information before invoking an `AuthenticationEntryPoint`.
2018-03-05 16:10:47 -06:00
[[nsa-request-cache-parents]]
2021-11-01 14:50:25 -06:00
=== Parent Elements of <request-cache>
2018-03-05 16:10:47 -06:00
2021-05-28 12:03:16 -05:00
The parent element of the `<request-cache>` element is the <<nsa-http,http>> element.
2018-03-05 16:10:47 -06:00
[[nsa-request-cache-attributes]]
2021-11-01 14:50:25 -06:00
=== <request-cache> Attributes
2018-03-05 16:10:47 -06:00
2021-04-21 16:01:26 -05:00
The `<request-cache>` element has only one attribute:
2018-03-05 16:10:47 -06:00
[[nsa-request-cache-ref]]
2021-04-21 16:01:26 -05:00
`ref`::
2018-03-05 16:10:47 -06:00
Defines a reference to a Spring bean that is a `RequestCache`.
[[nsa-session-management]]
2021-11-01 14:50:25 -06:00
== <session-management>
2021-04-21 16:01:26 -05:00
Session-management functionality is implemented by the addition of a `SessionManagementFilter` to the filter stack. This element adds that filter.
2018-03-05 16:10:47 -06:00
[[nsa-session-management-parents]]
2021-11-01 14:50:25 -06:00
=== Parent Elements of <session-management>
2018-03-05 16:10:47 -06:00
2021-05-28 12:03:16 -05:00
The parent element of the `<session-management>` element is the <<nsa-http,http>> element.
2018-03-05 16:10:47 -06:00
[[nsa-session-management-attributes]]
2021-11-01 14:50:25 -06:00
=== <session-management> Attributes
2018-03-05 16:10:47 -06:00
2021-04-21 16:01:26 -05:00
The `<session-management>` has the following attributes:
2018-03-05 16:10:47 -06:00
[[nsa-session-management-invalid-session-url]]
2021-04-21 16:01:26 -05:00
`invalid-session-url`::
Setting this attribute injects a `SessionManagementFilter` with a `SimpleRedirectInvalidSessionStrategy` that is configured with the attribute value.
When an invalid session ID is submitted, the strategy is invoked, redirecting to the configured URL.
2018-03-05 16:10:47 -06:00
[[nsa-session-management-invalid-session-strategy-ref]]
2021-04-21 16:01:26 -05:00
`invalid-session-url`::
Allows injection of the `InvalidSessionStrategy` instance, which is used by the `SessionManagementFilter`.
Use either this attribute or the `invalid-session-url` attribute but not both.
2018-03-05 16:10:47 -06:00
[[nsa-session-management-session-authentication-error-url]]
2021-04-21 16:01:26 -05:00
`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 is returned to the client.
Note that this attribute does not apply if the error occurs during a form-based login, where the URL for authentication failure takes precedence.
2018-03-05 16:10:47 -06:00
[[nsa-session-management-session-authentication-strategy-ref]]
2021-04-21 16:01:26 -05:00
`session-authentication-strategy-ref`::
Allows injection of a `SessionAuthenticationStrategy` instance, which is used by the `SessionManagementFilter`.
2018-03-05 16:10:47 -06:00
[[nsa-session-management-session-fixation-protection]]
* **session-fixation-protection**
2021-04-21 16:01:26 -05:00
session-fixation-protection::
Indicates how session fixation protection is applied when a user authenticates.
If set to `none`, no protection is applied.
`newSession` creates a new empty session, with only Spring Security-related attributes migrated.
`migrateSession` creates a new session and copies all session attributes to the new session.
In Servlet 3.1 (Java EE 7) and newer containers, specifying `changeSessionId` keeps the existing session and uses the container-supplied session fixation protection (`HttpServletRequest#changeSessionId()`).
It defaults to `changeSessionId` in Servlet 3.1 and newer containers, `migrateSession` in older containers.
It throws an exception if `changeSessionId` is used in older containers.
2018-03-05 16:10:47 -06:00
If session fixation protection is enabled, the `SessionManagementFilter` is injected with an appropriately configured `DefaultSessionAuthenticationStrategy`.
2021-04-21 16:01:26 -05:00
See the {security-api-url}org/springframework/security/web/session/SessionManagementFilter.html[Javadoc for `SessionManagementFilter`] for more details.
2018-03-05 16:10:47 -06:00
[[nsa-session-management-children]]
2021-11-01 14:50:25 -06:00
=== Child Elements of <session-management>
2018-03-05 16:10:47 -06:00
2021-05-28 12:03:16 -05:00
The `<session-management>` element has only one child element: <<nsa-concurrency-control,concurrency-control>>
2018-03-05 16:10:47 -06:00
[[nsa-concurrency-control]]
2021-11-01 14:50:25 -06:00
== <concurrency-control>
2021-04-21 16:01:26 -05:00
The `<concurrency-control>` adds support for concurrent session control, letting limits be placed on the number of active sessions a user can have.
A `ConcurrentSessionFilter` is created, and a `ConcurrentSessionControlAuthenticationStrategy` is used with the `SessionManagementFilter`.
If a `form-login` element has been declared, the strategy object is also injected into the created authentication filter.
An instance of `SessionRegistry` (a `SessionRegistryImpl` instance unless the user wishes to use a custom bean) is created for use by the strategy.
2018-03-05 16:10:47 -06:00
[[nsa-concurrency-control-parents]]
2021-11-01 14:50:25 -06:00
=== Parent Elements of <concurrency-control>
2018-03-05 16:10:47 -06:00
2021-05-28 12:03:16 -05:00
The parent element of the `<concurrency-control>` element is the <<nsa-session-management,session-management>> element.
2018-03-05 16:10:47 -06:00
[[nsa-concurrency-control-attributes]]
2021-11-01 14:50:25 -06:00
=== <concurrency-control> Attributes
2018-03-05 16:10:47 -06:00
2021-04-21 16:01:26 -05:00
The `<concurrency-control>` element has the following attributes:
2018-03-05 16:10:47 -06:00
[[nsa-concurrency-control-error-if-maximum-exceeded]]
2021-04-21 16:01:26 -05:00
`error-if-maximum-exceeded`::
If set to `true`, a `SessionAuthenticationException` is raised when a user attempts to exceed the maximum allowed number of sessions.
The default behavior is to expire the original session.
2018-03-05 16:10:47 -06:00
[[nsa-concurrency-control-expired-url]]
2021-04-21 16:01:26 -05:00
`expired-url`::
The URL to which a user is redirected 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.
This attribute should be set unless `exception-if-maximum-exceeded` is set.
If no value is supplied, an expiry message is written directly back to the response.
2018-03-05 16:10:47 -06:00
[[nsa-concurrency-control-expired-session-strategy-ref]]
2021-12-13 16:57:36 -06:00
`expired-session-strategy-ref`::
2021-04-21 16:01:26 -05:00
Allows injection of an `ExpiredSessionStrategy` instance, which is used by the `ConcurrentSessionFilter`.
2018-03-05 16:10:47 -06:00
[[nsa-concurrency-control-max-sessions]]
2021-04-21 16:01:26 -05:00
`max-sessions`::
2018-03-05 16:10:47 -06:00
Maps to the `maximumSessions` property of `ConcurrentSessionControlAuthenticationStrategy`.
Specify `-1` as the value to support unlimited sessions.
[[nsa-concurrency-control-session-registry-alias]]
2021-04-21 16:01:26 -05:00
`session-registry-alias`::
2018-03-05 16:10:47 -06:00
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]]
2021-04-21 16:01:26 -05:00
`session-registry-ref`::
Specifies a `SessionRegistry` implementation to use.
The other concurrent session control beans are wired up to use it.
2018-03-05 16:10:47 -06:00
[[nsa-x509]]
2021-11-01 14:50:25 -06:00
== <x509>
2021-04-21 16:01:26 -05:00
The `<x509>` element adds support for X.509 authentication.
An `X509AuthenticationFilter` is added to the stack, and an `Http403ForbiddenEntryPoint` bean is created.
The latter is used only if no other authentication mechanisms are in use. (Its only functionality is to return an HTTP 403 error code.)
A `PreAuthenticatedAuthenticationProvider` is also created. It delegates the loading of user authorities to a `UserDetailsService`.
2018-03-05 16:10:47 -06:00
[[nsa-x509-parents]]
2021-11-01 14:50:25 -06:00
=== Parent Elements of <x509>
2018-03-05 16:10:47 -06:00
2021-05-28 12:03:16 -05:00
The parent element of the `<x509>` element is the <<nsa-http,http>> element.
2018-03-05 16:10:47 -06:00
[[nsa-x509-attributes]]
2021-11-01 14:50:25 -06:00
=== <x509> Attributes
2018-03-05 16:10:47 -06:00
2021-04-21 16:01:26 -05:00
The `<x509>` element has the following attributes:
2018-03-05 16:10:47 -06:00
[[nsa-x509-authentication-details-source-ref]]
2021-04-21 16:01:26 -05:00
`authentication-details-source-ref`::
A reference to an `AuthenticationDetailsSource`.
2018-03-05 16:10:47 -06:00
[[nsa-x509-subject-principal-regex]]
2021-04-21 16:01:26 -05:00
`subject-principal-regex`::
Defines a regular expression, which is used to extract the username from the certificate (for use with the `UserDetailsService`).
2018-03-05 16:10:47 -06:00
[[nsa-x509-user-service-ref]]
2021-04-21 16:01:26 -05:00
`user-service-ref`::
Lets a specific `UserDetailsService` be used with X.509 when where multiple instances are configured.
If not set, an attempt is made to locate a suitable instance automatically and use that.
2018-03-05 16:10:47 -06:00
[[nsa-filter-chain-map]]
2021-11-01 14:50:25 -06:00
== <filter-chain-map>
2021-04-21 16:01:26 -05:00
The `<filter-chain-map>` explicitly configures a `FilterChainProxy` instance with a `FilterChainMap`.
2018-03-05 16:10:47 -06:00
[[nsa-filter-chain-map-attributes]]
2021-11-01 14:50:25 -06:00
=== <filter-chain-map> Attributes
2018-03-05 16:10:47 -06:00
2021-04-21 16:01:26 -05:00
The `<filter-chain-map>` element has one attribute:
2018-03-05 16:10:47 -06:00
[[nsa-filter-chain-map-request-matcher]]
2021-04-21 16:01:26 -05:00
`request-matcher`::
2018-03-05 16:10:47 -06:00
Defines the strategy to use for matching incoming requests.
2021-04-21 16:01:26 -05:00
Currently, the options are `ant` (for Ant path patterns), `regex` (for regular expressions), and `ciRegex` (for case-insensitive regular expressions).
2018-03-05 16:10:47 -06:00
[[nsa-filter-chain-map-children]]
2021-11-01 14:50:25 -06:00
=== Child Elements of <filter-chain-map>
2018-03-05 16:10:47 -06:00
2021-05-28 12:03:16 -05:00
The `<filter-chain-map>` element has one child element: <<nsa-filter-chain,filter-chain>>.
2018-03-05 16:10:47 -06:00
[[nsa-filter-chain]]
2021-11-01 14:50:25 -06:00
== <filter-chain>
2021-04-21 16:01:26 -05:00
The `<filter-chain>` element is used within a `<filter-chain-map>` to define a specific URL pattern and the list of filters that apply to the URLs that match that pattern.
When multiple `<filter-chain>` elements are assembled in a list, to configure a `FilterChainProxy`, the most specific patterns must be placed at the top of the list, with the most general ones at the bottom.
2018-03-05 16:10:47 -06:00
[[nsa-filter-chain-parents]]
2021-11-01 14:50:25 -06:00
=== Parent Elements of <filter-chain>
2018-03-05 16:10:47 -06:00
2021-05-28 12:03:16 -05:00
The parent element of the `<filter-chain>` element is the <<nsa-filter-chain-map,filter-chain-map>> element.
2018-03-05 16:10:47 -06:00
[[nsa-filter-chain-attributes]]
2021-11-01 14:50:25 -06:00
=== <filter-chain> Attributes
2018-03-05 16:10:47 -06:00
2021-04-21 16:01:26 -05:00
The `<filter-chain>` element has the following attributes:
2018-03-05 16:10:47 -06:00
[[nsa-filter-chain-filters]]
2021-04-21 16:01:26 -05:00
`filters`::
A comma-separated list of references to Spring beans that implement `Filter`.
A value of `none` means that no `Filter` should be used for this `FilterChain`.
2018-03-05 16:10:47 -06:00
[[nsa-filter-chain-pattern]]
2021-04-21 16:01:26 -05:00
`pattern`::
2021-05-28 12:03:16 -05:00
A pattern that creates `RequestMatcher` in combination with the <<nsa-filter-chain-map-request-matcher,request-matcher>> element.
2018-03-05 16:10:47 -06:00
[[nsa-filter-chain-request-matcher-ref]]
2021-04-21 16:01:26 -05:00
`request-matcher-ref`::
A reference to a `RequestMatcher` that is used to determine if any `Filter` from the `filters` attribute should be invoked.
2018-03-05 16:10:47 -06:00
[[nsa-filter-security-metadata-source]]
2021-11-01 14:50:25 -06:00
== <filter-security-metadata-source>
2021-04-21 16:01:26 -05:00
The `<filter-security-metadata-source>` is used to explicitly configure a `FilterSecurityMetadataSource` bean for use with a `FilterSecurityInterceptor`.
The `<filter-security-metadata-source>` is usually only needed if you explicitly configure a `FilterChainProxy` rather than use the `<http>` element.
The `<intercept-url>` elements should contain only pattern, method, and access attributes.
Any others result in a configuration error.
2018-03-05 16:10:47 -06:00
[[nsa-filter-security-metadata-source-attributes]]
2021-11-01 14:50:25 -06:00
=== <filter-security-metadata-source> Attributes
2018-03-05 16:10:47 -06:00
2021-04-21 16:01:26 -05:00
The `<filter-security-metadata-source>` element has the following attributes:
2018-03-05 16:10:47 -06:00
[[nsa-filter-security-metadata-source-id]]
2021-04-21 16:01:26 -05:00
`id`::
A bean identifier, which is used for referring to the bean elsewhere in the context.
2018-03-05 16:10:47 -06:00
[[nsa-filter-security-metadata-source-request-matcher]]
2021-04-21 16:01:26 -05:00
`request-matcher`::
2018-03-05 16:10:47 -06:00
Defines the strategy use for matching incoming requests.
2021-04-21 16:01:26 -05:00
Currently the options are `ant` (for Ant path patterns), `regex` (for regular expressions), and `ciRegex` (for case-insensitive regular expressions).
2018-03-05 16:10:47 -06:00
[[nsa-filter-security-metadata-source-use-expressions]]
2021-04-21 16:01:26 -05:00
use-expressions::
Enables the use of expressions in the `access` attributes in `<intercept-url>` elements rather than the traditional list of configuration attributes.
Default: `true`
2018-03-05 16:10:47 -06:00
If enabled, each attribute should contain a single Boolean expression.
2021-04-21 16:01:26 -05:00
If the expression evaluates to `true`, access is granted.
2018-03-05 16:10:47 -06:00
[[nsa-filter-security-metadata-source-children]]
2021-11-01 14:50:25 -06:00
=== Child Elements of <filter-security-metadata-source>
2018-03-05 16:10:47 -06:00
2021-12-13 16:57:36 -06:00
The `<filter-security-metadata-source>` has a single child element: <<nsa-intercept-url,intercept-url>>.