This appendix provides a reference to the elements available in the security namespace and information on the underlying beans they create (a knowledge of the individual classes and how they work together is assumed - you can find more information in the project Javadoc and elsewhere in this document).
If you haven't used the namespace before, please read the xref:servlet/xml-namespace.adoc#ns-config[introductory chapter] on namespace configuration, as this is intended as a supplement to the information there.
Using a good quality XML editor while editing a configuration based on the schema is recommended as this will provide contextual information on which elements and attributes are available as well as comments explaining their purpose.
If you are familiar with this format, you may wish to examine the https://raw.githubusercontent.com/spring-projects/spring-security/main/config/src/main/resources/org/springframework/security/config/spring-security-4.1.rnc[schema file] directly.
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
As of Spring Security 3.1, additional `http` elements can be used to add extra filter chains footnote:[See the pass:specialcharacters,macros[xref:servlet/xml-namespace.adoc#ns-web-xml[introductory chapter]] for how to set up the mapping from your `web.xml` ].
Some core filters are always created in a filter chain and others will be added to the stack depending on the attributes and child elements which are present.
The positions of the standard filters are fixed (see
xref:servlet/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
All filters which require a reference to the xref:servlet/authentication/architecture/index.adoc#servlet-authentication-authenticationmanager[`AuthenticationManager`] will be automatically injected with the internal instance created by the namespace configuration.
The attributes on the `<http>` element control some of the properties on the core filters.
[[nsa-http-access-decision-manager-ref]]
* **access-decision-manager-ref**
Optional attribute specifying the ID of the `AccessDecisionManager` implementation which should be used for authorizing HTTP requests.
By default an `AffirmativeBased` implementation is used for with a `RoleVoter` and an `AuthenticatedVoter`.
[[nsa-http-authentication-manager-ref]]
* **authentication-manager-ref**
A reference to the `AuthenticationManager` used for the `FilterChain` created by this http element.
[[nsa-http-auto-config]]
* **auto-config**
Automatically registers a login form, BASIC authentication, logout services.
If set to "true", all of these capabilities are added (although you can still customize the configuration of each by providing the respective element).
If unspecified, defaults to "false".
Use of this attribute is not recommended.
Use explicit configuration elements instead to avoid confusion.
[[nsa-http-create-session]]
* **create-session**
Controls the eagerness with which an HTTP session is created by Spring Security classes.
Options include:
** `always` - Spring Security will proactively create a session if one does not exist.
** `ifRequired` - Spring Security will only create a session only if one is required (default value).
** `never` - Spring Security will never create a session, but will make use of one if the application does.
** `stateless` - Spring Security will not create a session and ignore the session for obtaining a Spring `Authentication`.
[[nsa-http-disable-url-rewriting]]
* **disable-url-rewriting**
Prevents session IDs from being appended to URLs in the application.
Clients must use cookies if this attribute is set to `true`.
The default is `true`.
[[nsa-http-entry-point-ref]]
* **entry-point-ref**
Normally the `AuthenticationEntryPoint` used will be set depending on which authentication mechanisms have been configured.
This attribute allows this behaviour to be overridden by defining a customized `AuthenticationEntryPoint` bean which will start the authentication process.
[[nsa-http-jaas-api-provision]]
* **jaas-api-provision**
If available, runs the request as the `Subject` acquired from the `JaasAuthenticationToken` which is implemented by adding a `JaasApiIntegrationFilter` bean to the stack.
Defaults to `false`.
[[nsa-http-name]]
* **name**
A bean identifier, used for referring to the bean elsewhere in the context.
[[nsa-http-once-per-request]]
* **once-per-request**
Corresponds to the `observeOncePerRequest` property of `FilterSecurityInterceptor`.
Defaults to `true`.
[[nsa-http-pattern]]
* **pattern**
Defining a pattern for the <<nsa-http,http>> element controls the requests which will be filtered through the list of filters which it defines.
The interpretation is dependent on the configured <<nsa-http-request-matcher,request-matcher>>.
If no pattern is defined, all requests will be matched, so the most specific patterns should be declared first.
[[nsa-http-realm]]
* **realm**
Sets the realm name used for basic authentication (if enabled).
Corresponds to the `realmName` property on `BasicAuthenticationEntryPoint`.
[[nsa-http-request-matcher]]
* **request-matcher**
Defines the `RequestMatcher` strategy used in the `FilterChainProxy` and the beans created by the `intercept-url` to match incoming requests.
Options are currently `mvc`, `ant`, `regex` and `ciRegex`, for Spring MVC, ant, regular-expression and case-insensitive regular-expression respectively.
A separate instance is created for each <<nsa-intercept-url,intercept-url>> element using its <<nsa-intercept-url-pattern,pattern>>, <<nsa-intercept-url-method,method>> and <<nsa-intercept-url-servlet-path,servlet-path>> attributes.
Ant paths are matched using an `AntPathRequestMatcher`, regular expressions are matched using a `RegexRequestMatcher` and for Spring MVC path matching the `MvcRequestMatcher` is used.
See the Javadoc for these classes for more details on exactly how the matching is performed.
Ant paths are the default strategy.
[[nsa-http-request-matcher-ref]]
* **request-matcher-ref**
A reference to a bean that implements `RequestMatcher` that will determine if this `FilterChain` should be used.
This is a more powerful alternative to <<nsa-http-pattern,pattern>>.
[[nsa-http-security]]
* **security**
A request pattern can be mapped to an empty filter chain, by setting this attribute to `none`.
No security will be applied and none of Spring Security's features will be available.
[[nsa-http-security-context-repository-ref]]
* **security-context-repository-ref**
Allows injection of a custom `SecurityContextRepository` into the `SecurityContextPersistenceFilter`.
[[nsa-http-servlet-api-provision]]
* **servlet-api-provision**
Provides versions of `HttpServletRequest` security methods such as `isUserInRole()` and `getPrincipal()` which are implemented by adding a `SecurityContextHolderAwareRequestFilter` bean to the stack.
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].
This element allows you to set the `errorPage` property for the default `AccessDeniedHandler` used by the `ExceptionTranslationFilter`, using the <<nsa-access-denied-handler-error-page,error-page>> attribute, or to supply your own implementation using the<<nsa-access-denied-handler-ref,ref>> attribute.
This 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`.
The https://blogs.msdn.com/b/ie/archive/2008/09/02/ie8-security-part-vi-beta-2-update.aspx[X-Content-Type-Options] header prevents Internet Explorer from MIME-sniffing a response away from the declared content-type.
This also applies to Google Chrome, when downloading extensions.
** `Public-Key-Pinning` or `Public-Key-Pinning-Report-Only` - Can be set using the <<nsa-hpkp,hpkp>> element.
This allows HTTPS websites to resist impersonation by attackers using mis-issued or otherwise fraudulent certificates.
** `Content-Security-Policy` or `Content-Security-Policy-Report-Only` - Can be set using the <<nsa-content-security-policy,content-security-policy>> element.
https://www.w3.org/TR/CSP2/[Content Security Policy (CSP)] is a mechanism that web applications can leverage to mitigate content injection vulnerabilities, such as cross-site scripting (XSS).
** `Referrer-Policy` - Can be set using the <<nsa-referrer-policy,referrer-policy>> element, https://www.w3.org/TR/referrer-policy/[Referrer-Policy] is a mechanism that web applications can leverage to manage the referrer field, which contains the last page the user was on.
** `Feature-Policy` - Can be set using the <<nsa-feature-policy,feature-policy>> element, https://wicg.github.io/feature-policy/[Feature-Policy] is a mechanism that allows web developers to selectively enable, disable, and modify the behavior of certain APIs and web features in the browser.
The security policy directive(s) for the Content-Security-Policy header or if report-only is set to true, then the Content-Security-Policy-Report-Only header is used.
[[nsa-content-security-policy-report-only]]
* **report-only**
Set to true, to enable the Content-Security-Policy-Report-Only header for reporting policy violations only.
When enabled adds the https://tools.ietf.org/html/draft-ietf-websec-x-frame-options[X-Frame-Options header] to the response, this allows newer browsers to do some security checks and prevent https://en.wikipedia.org/wiki/Clickjacking[clickjacking] attacks.
If disabled, the X-Frame-Options header will not be included.
Default false.
[[nsa-frame-options-policy]]
* **policy**
** `DENY` The page cannot be displayed in a frame, regardless of the site attempting to do so.
This is the default when frame-options-policy is specified.
** `SAMEORIGIN` The page can only be displayed in a frame on the same origin as the page itself
+
In other words, if you specify DENY, not only will attempts to load the page in a frame fail when loaded from other sites, attempts to do so will fail when loaded from the same site.
On the other hand, if you specify SAMEORIGIN, you can still use the page in a frame as long as the site including it in a frame it is the same as the one serving the page.
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.
Do not include the header for https://en.wikipedia.org/wiki/Cross-site_scripting#Non-Persistent[reflected / Type-1 Cross-Site Scripting (XSS)] protection.
When true and xss-protection-enabled is true, adds mode=block to the header.
This indicates to the browser that the page should not be loaded at all.
When false and xss-protection-enabled is true, the page will still be rendered when an reflected attack is detected but the response will be 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.
With the default namespace setup, the anonymous "authentication" facility is automatically enabled.
You can disable it using this property.
[[nsa-anonymous-granted-authority]]
* **granted-authority**
The granted authority that should be assigned to the anonymous request.
Commonly this is used to assign the anonymous request particular roles, which can subsequently be used in authorization decisions.
If unset, defaults to `ROLE_ANONYMOUS`.
[[nsa-anonymous-key]]
* **key**
The key shared between the provider and filter.
This generally does not need to be set.
If unset, it will default to a secure randomly generated value.
This means setting this value can improve startup time when using the anonymous functionality since secure random values can take a while to be generated.
[[nsa-anonymous-username]]
* **username**
The username that should be assigned to the anonymous request.
This allows the principal to be identified, which may be important for logging and auditing.
This element is used to add a filter to the filter chain.
It doesn't create any additional beans but is used to select a bean of type `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.
The filter immediately after which the custom-filter should be placed in the chain.
This feature will only be needed by advanced users who wish to mix their own filters into the security filter chain and have some knowledge of the standard Spring Security filters.
The filter names map to specific Spring Security implementation filters.
[[nsa-custom-filter-before]]
* **before**
The filter immediately before which the custom-filter should be placed in the chain
[[nsa-custom-filter-position]]
* **position**
The explicit position at which the custom-filter should be placed in the chain.
Use if you are replacing a standard filter.
[[nsa-custom-filter-ref]]
* **ref**
Defines a reference to a Spring bean that implements `Filter`.
Used to add an `UsernamePasswordAuthenticationFilter` to the filter stack and an `LoginUrlAuthenticationEntryPoint` to the application context to provide authentication on demand.
This will always take precedence over other namespace-created entry points.
If no attributes are supplied, a login page will be generated automatically at the URL "/login" footnote:[
This feature is really just provided for convenience and is not intended for production (where a view technology will have been chosen and can be used to render a customized login page).
The class `DefaultLoginPageGeneratingFilter` is responsible for rendering the login page and will provide login forms for both normal form login and/or OpenID if required.
] The behaviour can be customized using the <<nsa-form-login-attributes, `<form-login>` Attributes>>.
If set to `true`, the user will always start at the value given by <<nsa-form-login-default-target-url,default-target-url>>, regardless of how they arrived at the login page.
Maps to the `alwaysUseDefaultTargetUrl` property of `UsernamePasswordAuthenticationFilter`.
Can be used as an alternative to <<nsa-form-login-authentication-failure-url,authentication-failure-url>>, giving you full control over the navigation flow after an authentication failure.
The value should be the name of an `AuthenticationFailureHandler` bean in the application context.
[[nsa-form-login-authentication-failure-url]]
* **authentication-failure-url**
Maps to the `authenticationFailureUrl` property of `UsernamePasswordAuthenticationFilter`.
Defines the URL the browser will be redirected to on login failure.
Defaults to `/login?error`, which will be automatically handled by the automatic login page generator, re-rendering the login page with an error message.
This can be used as an alternative to <<nsa-form-login-default-target-url,default-target-url>> and <<nsa-form-login-always-use-default-target,always-use-default-target>>, giving you full control over the navigation flow after a successful authentication.
The value should be the name of an `AuthenticationSuccessHandler` bean in the application context.
By default, an implementation of `SavedRequestAwareAuthenticationSuccessHandler` is used and injected with the <<nsa-form-login-default-target-url,default-target-url >>.
[[nsa-form-login-default-target-url]]
* **default-target-url**
Maps to the `defaultTargetUrl` property of `UsernamePasswordAuthenticationFilter`.
If not set, the default value is "/" (the application root).
A user will be taken to this URL after logging in, provided they were not asked to login while attempting to access a secured resource, when they will be taken to the originally requested URL.
[[nsa-form-login-login-page]]
* **login-page**
The URL that should be used to render the login page.
Maps to the `loginFormUrl` property of the `LoginUrlAuthenticationEntryPoint`.
Defaults to "/login".
[[nsa-form-login-login-processing-url]]
* **login-processing-url**
Maps to the `filterProcessesUrl` property of `UsernamePasswordAuthenticationFilter`.
The default value is "/login".
[[nsa-form-login-password-parameter]]
* **password-parameter**
The name of the request parameter which contains the password.
Defaults to "password".
[[nsa-form-login-username-parameter]]
* **username-parameter**
The name of the request parameter which contains the username.
The xref:servlet/oauth2/oauth2-login.adoc#oauth2login[OAuth 2.0 Login] feature configures authentication support using an OAuth 2.0 and/or OpenID Connect 1.0 Provider.
A container element for client(s) registered (xref:servlet/oauth2/oauth2-client.adoc#oauth2Client-client-registration[ClientRegistration]) with an OAuth 2.0 or OpenID Connect 1.0 Provider.
The supported values are *client_secret_basic*, *client_secret_post*, *private_key_jwt*, *client_secret_jwt* and *none* https://tools.ietf.org/html/rfc6749#section-2.1[(public clients)].
The supported values are `authorization_code`, `client_credentials`, `password`, as well as, extension grant type `urn:ietf:params:oauth:grant-type:jwt-bearer`.
The client's registered redirect URI that the _Authorization Server_ redirects the end-user's user-agent to after the end-user has authenticated and authorized access to the client.
[[nsa-client-registration-scope]]
* **scope**
The scope(s) requested by the client during the Authorization Request flow, such as openid, email, or profile.
[[nsa-client-registration-client-name]]
* **client-name**
A descriptive name used for the client.
The name may be used in certain scenarios, such as when displaying the name of the client in the auto-generated login page.
[[nsa-client-registration-provider-id]]
* **provider-id**
A reference to the associated provider. May reference a `<provider>` element or use one of the common providers (google, github, facebook, okta).
The URI used to retrieve the https://tools.ietf.org/html/rfc7517[JSON Web Key (JWK)] Set from the Authorization Server, which contains the cryptographic key(s) used to verify the https://tools.ietf.org/html/rfc7515[JSON Web Signature (JWS)] of the ID Token and optionally the UserInfo Response.
[[nsa-provider-issuer-uri]]
* **issuer-uri**
The URI used to initially configure a `ClientRegistration` using discovery of an OpenID Connect Provider's https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderConfig[Configuration endpoint] or an Authorization Server's https://tools.ietf.org/html/rfc8414#section-3[Metadata endpoint].
This is a top-level element which can be used to inject a custom implementation of `HttpFirewall` into the `FilterChainProxy` created by the namespace.
The default implementation should be suitable for most applications.
Lists the access attributes which will be stored in the `FilterInvocationSecurityMetadataSource` for the defined URL pattern/method combination.
This should be a comma-separated list of the security configuration attributes (such as role names).
[[nsa-intercept-url-method]]
* **method**
The HTTP Method which will be used in combination with the pattern and servlet path (optional) to match an incoming request.
If omitted, any method will match.
If an identical pattern is specified with and without a method, the method-specific match will take precedence.
[[nsa-intercept-url-pattern]]
* **pattern**
The pattern which defines the URL path.
The content will depend on the `request-matcher` attribute from the containing http element, so will default to ant path syntax.
[[nsa-intercept-url-request-matcher-ref]]
* **request-matcher-ref**
A reference to a `RequestMatcher` that will be used to determine if this `<intercept-url>` is used.
[[nsa-intercept-url-requires-channel]]
* **requires-channel**
Can be "http" or "https" depending on whether a particular URL pattern should be accessed over HTTP or HTTPS respectively.
Alternatively the value "any" can be used when there is no preference.
If this attribute is present on any `<intercept-url>` element, then a `ChannelProcessingFilter` will be added to the filter stack and its additional dependencies added to the application context.
If a `<port-mappings>` configuration is added, this will be used to by the `SecureChannelProcessor` and `InsecureChannelProcessor` beans to determine the ports used for redirecting to HTTP/HTTPS.
NOTE: This property is invalid for <<nsa-filter-security-metadata-source,filter-security-metadata-source>>
[[nsa-intercept-url-servlet-path]]
* **servlet-path**
The servlet path which will be used in combination with the pattern and HTTP method to match an incoming request.
This attribute is only applicable when <<nsa-http-request-matcher,request-matcher>> is 'mvc'.
In addition, the value is only required in the following 2 use cases: 1) There are 2 or more `HttpServlet` 's registered in the `ServletContext` that have mappings starting with `'/'` and are different; 2) The pattern starts with the same value of a registered `HttpServlet` path, excluding the default (root) `HttpServlet` `'/'`.
NOTE: This property is invalid for <<nsa-filter-security-metadata-source,filter-security-metadata-source>>
Reference to an AuthenticationFailureHandler bean which should be used to handle a failed authentication request.
Should not be used in combination with authentication-failure-url as the implementation should always deal with navigation to the subsequent destination
[[nsa-openid-login-authentication-failure-url]]
* **authentication-failure-url**
The URL for the login failure page.
If no login failure URL is specified, Spring Security will automatically create a failure login URL at /login?login_error and a corresponding filter to render that login failure URL when requested.
Reference to an AuthenticationSuccessHandler bean which should be used to handle a successful authentication request.
Should not be used in combination with <<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
[[nsa-openid-login-default-target-url]]
* **default-target-url**
The URL that will be redirected to after successful authentication, if the user's previous action could not be resumed.
This generally happens if the user visits a login page without having first requested a secured operation that triggers authentication.
If unspecified, defaults to the root of the application.
[[nsa-openid-login-login-page]]
* **login-page**
The URL for the login page.
If no login URL is specified, Spring Security will automatically create a login URL at /login and a corresponding filter to render that login URL when requested.
[[nsa-openid-login-login-processing-url]]
* **login-processing-url**
The URL that the login form is posted to.
If unspecified, it defaults to /login.
[[nsa-openid-login-password-parameter]]
* **password-parameter**
The name of the request parameter which contains the password.
Defaults to "password".
[[nsa-openid-login-user-service-ref]]
* **user-service-ref**
A reference to a user-service (or UserDetailsService bean) Id
[[nsa-openid-login-username-parameter]]
* **username-parameter**
The name of the request parameter which contains the username.
More than one can be used, in which case each must have an `identifier-match` attribute, containing a regular expression which is matched against the supplied OpenID identifier.
This allows different attribute lists to be fetched from different providers (Google, Yahoo etc).
A regular expression which will be compared against the claimed identity, when deciding which attribute-exchange configuration to use during authentication.
Adds the `RememberMeAuthenticationFilter` to the stack.
This in turn will be configured with either a `TokenBasedRememberMeServices`, a `PersistentTokenBasedRememberMeServices` or a user-specified bean implementing `RememberMeServices` depending on the attribute settings.
Sets the `authenticationSuccessHandler` property on the `RememberMeAuthenticationFilter` if custom navigation is required.
The value should be the name of a `AuthenticationSuccessHandler` bean in the application context.
[[nsa-remember-me-data-source-ref]]
* **data-source-ref**
A reference to a `DataSource` bean.
If this is set, `PersistentTokenBasedRememberMeServices` will be used and configured with a `JdbcTokenRepositoryImpl` instance.
[[nsa-remember-me-remember-me-parameter]]
* **remember-me-parameter**
The name of the request parameter which toggles remember-me authentication.
Defaults to "remember-me".
Maps to the "parameter" property of `AbstractRememberMeServices`.
[[nsa-remember-me-remember-me-cookie]]
* **remember-me-cookie**
The name of cookie which store the token for remember-me authentication.
Defaults to "remember-me".
Maps to the "cookieName" property of `AbstractRememberMeServices`.
[[nsa-remember-me-key]]
* **key**
Maps to the "key" property of `AbstractRememberMeServices`.
Should be set to a unique value to ensure that remember-me cookies are only valid within the one application footnote:[
This doesn't affect the use of `PersistentTokenBasedRememberMeServices`, where the tokens are stored on the server side.
].
If this is not set a secure random value will be generated.
Since generating secure random values can take a while, setting this value explicitly can help improve startup times when using the remember-me functionality.
[[nsa-remember-me-services-alias]]
* **services-alias**
Exports the internally defined `RememberMeServices` as a bean alias, allowing it to be used by other beans in the application context.
[[nsa-remember-me-services-ref]]
* **services-ref**
Allows complete control of the `RememberMeServices` implementation that will be used by the filter.
The value should be the `id` of a bean in the application context which implements this interface.
Should also implement `LogoutHandler` if a logout filter is in use.
[[nsa-remember-me-token-repository-ref]]
* **token-repository-ref**
Configures a `PersistentTokenBasedRememberMeServices` but allows the use of a custom `PersistentTokenRepository` bean.
[[nsa-remember-me-token-validity-seconds]]
* **token-validity-seconds**
Maps to the `tokenValiditySeconds` property of `AbstractRememberMeServices`.
Specifies the period in seconds for which the remember-me cookie should be valid.
By default it will be valid for 14 days.
[[nsa-remember-me-use-secure-cookie]]
* **use-secure-cookie**
It is recommended that remember-me cookies are only submitted over HTTPS and thus should be flagged as "secure".
By default, a secure cookie will be used if the connection over which the login request is made is secure (as it should be).
If you set this property to `false`, secure cookies will not be used.
Setting it to `true` will always set the secure flag on the cookie.
This attribute maps to the `useSecureCookie` property of `AbstractRememberMeServices`.
[[nsa-remember-me-user-service-ref]]
* **user-service-ref**
The remember-me services implementations require access to a `UserDetailsService`, so there has to be one defined in the application context.
If there is only one, it will be selected and used automatically by the namespace configuration.
If there are multiple instances, you can specify a bean `id` explicitly using this attribute.
Sets the `RequestCache` instance which will be used by the `ExceptionTranslationFilter` to store request information before invoking an `AuthenticationEntryPoint`.
Indicates how session fixation protection will be applied when a user authenticates.
If set to "none", no protection will be applied.
"newSession" will create a new empty session, with only Spring Security-related attributes migrated.
"migrateSession" will create a new session and copy all session attributes to the new session.
In Servlet 3.1 (Java EE 7) and newer containers, specifying "changeSessionId" will keep the existing session and use the container-supplied session fixation protection (HttpServletRequest#changeSessionId()).
Defaults to "changeSessionId" in Servlet 3.1 and newer containers, "migrateSession" in older containers.
Throws an exception if "changeSessionId" is used in older containers.
+
If session fixation protection is enabled, the `SessionManagementFilter` is injected with an appropriately configured `DefaultSessionAuthenticationStrategy`.
Adds support for concurrent session control, allowing limits to be placed on the number of active sessions a user can have.
A `ConcurrentSessionFilter` will be created, and a `ConcurrentSessionControlAuthenticationStrategy` will be used with the `SessionManagementFilter`.
If a `form-login` element has been declared, the strategy object will also be injected into the created authentication filter.
An instance of `SessionRegistry` (a `SessionRegistryImpl` instance unless the user wishes to use a custom bean) will be created for use by the strategy.
If set to "true" a `SessionAuthenticationException` will be raised when a user attempts to exceed the maximum allowed number of sessions.
The default behaviour is to expire the original session.
[[nsa-concurrency-control-expired-url]]
* **expired-url**
The URL a user will be redirected to if they attempt to use a session which has been "expired" by the concurrent session controller because the user has exceeded the number of allowed sessions and has logged in again elsewhere.
Should be set unless `exception-if-maximum-exceeded` is set.
If no value is supplied, an expiry message will just be written directly back to the response.
Used within to define a specific URL pattern and the list of filters which apply to the URLs matching that pattern.
When multiple filter-chain elements are assembled in a list in order to configure a FilterChainProxy, the most specific patterns must be placed at the top of the list, with most general ones at the bottom.
The websocket-message-broker element has two different modes.
If the <<nsa-websocket-message-broker-id,websocket-message-broker@id>> is not specified, then it will do the following things:
* Ensure that any SimpAnnotationMethodMessageHandler has the AuthenticationPrincipalArgumentResolver registered as a custom argument resolver.
This allows the use of `@AuthenticationPrincipal` to resolve the principal of the current `Authentication`
* Ensures that the SecurityContextChannelInterceptor is automatically registered for the clientInboundChannel.
This populates the SecurityContextHolder with the user that is found in the Message
* Ensures that a ChannelSecurityInterceptor is registered with the clientInboundChannel.
This allows authorization rules to be specified for a message.
* Ensures that a CsrfChannelInterceptor is registered with the clientInboundChannel.
This ensures that only requests from the original domain are enabled.
* Ensures that a CsrfTokenHandshakeInterceptor is registered with WebSocketHttpRequestHandler, TransportHandlingSockJsService, or DefaultSockJsService.
This ensures that the expected CsrfToken from the HttpServletRequest is copied into the WebSocket Session attributes.
If additional control is necessary, the id can be specified and a ChannelSecurityInterceptor will be assigned to the specified id.
All the wiring with Spring's messaging infrastructure can then be done manually.
This is more cumbersome, but provides greater control over the configuration.
* **pattern** An ant based pattern that matches on the Message destination.
For example, "/**" matches any Message with a destination; "/admin/**" matches any Message that has a destination that starts with "/admin/**".
[[nsa-intercept-message-type]]
* **type** The type of message to match on.
Valid values are defined in SimpMessageType (i.e. CONNECT, CONNECT_ACK, HEARTBEAT, MESSAGE, SUBSCRIBE, UNSUBSCRIBE, DISCONNECT, DISCONNECT_ACK, OTHER).
[[nsa-intercept-message-access]]
* **access** The expression used to secure the Message.
For example, "denyAll" will deny access to all of the matching Messages; "permitAll" will grant access to all of the matching Messages; "hasRole('ADMIN') requires the current user to have the role 'ROLE_ADMIN' for the matching Messages.
Before Spring Security 3.0, an `AuthenticationManager` was automatically registered internally.
Now you must register one explicitly using the `<authentication-manager>` element.
This creates an instance of Spring Security's `ProviderManager` class, which needs to be configured with a list of one or more `AuthenticationProvider` instances.
These can either be created using syntax elements provided by the namespace, or they can be standard bean definitions, marked for addition to the list using the `authentication-provider` element.
This attribute allows you to define an alias name for the internal instance for use in your own configuration.
[[nsa-authentication-manager-erase-credentials]]
* **erase-credentials**
If set to true, the AuthenticationManager will attempt to clear any credentials data in the returned Authentication object, once the user has been authenticated.
Literally it maps to the `eraseCredentialsAfterAuthentication` property of the xref:servlet/authentication/architecture/index.adoc#servlet-authentication-providermanager[`ProviderManager`].
`DaoAuthenticationProvider` loads user information from a `UserDetailsService` and compares the username/password combination with the values supplied at login.
The `UserDetailsService` instance can be defined either by using an available namespace element (`jdbc-user-service` or by using the `user-service-ref` attribute to point to a bean defined elsewhere in the application context).
Defines a reference to a Spring bean that implements `AuthenticationProvider`.
If you have written your own `AuthenticationProvider` implementation (or want to configure one of Spring Security's own implementations as a traditional bean for some reason, then you can use the following syntax to add it to the internal list of `ProviderManager`:
Authentication providers can optionally be configured to use a password encoder as described in the xref:features/authentication/password-storage.adoc#authentication-password-storage[Password Storage].
This element is the primary means of adding support for securing methods on Spring Security beans.
Methods can be secured by the use of annotations (defined at the interface or class level) or by defining a set of pointcuts as child elements, using AspectJ syntax.
A reference to an `AuthenticationManager` that should be used for method security.
[[nsa-global-method-security-jsr250-annotations]]
* **jsr250-annotations**
Specifies whether JSR-250 style attributes are to be used (for example "RolesAllowed").
This will require the javax.annotation.security classes on the classpath.
Setting this to true also adds a `Jsr250Voter` to the `AccessDecisionManager`, so you need to make sure you do this if you are using a custom implementation and want to use these annotations.
Specifies whether the use of Spring Security's pre and post invocation annotations (@PreFilter, @PreAuthorize, @PostFilter, @PostAuthorize) should be enabled for this application context.
Defaults to "disabled".
[[nsa-global-method-security-proxy-target-class]]
* **proxy-target-class**
If true, class based proxying will be used instead of interface based proxying.
[[nsa-global-method-security-run-as-manager-ref]]
* **run-as-manager-ref**
A reference to an optional `RunAsManager` implementation which will be used by the configured `MethodSecurityInterceptor`
This element can be used to decorate an `AfterInvocationProvider` for use by the security interceptor maintained by the `<global-method-security>` namespace.
You can define zero or more of these within the `global-method-security` element, each with a `ref` attribute pointing to an `AfterInvocationProvider` bean instance within your application context.
Allows the default expression-based mechanism for handling Spring Security's pre and post invocation annotations (@PreFilter, @PreAuthorize, @PostFilter, @PostAuthorize) to be replaced entirely.
Customizes the `PreInvocationAuthorizationAdviceVoter` with the ref as the `PreInvocationAuthorizationAdviceVoter` for the <pre-post-annotation-handling> element.
Rather than defining security attributes on an individual method or class basis using the `@Secured` annotation, you can define cross-cutting security constraints across whole sets of methods and interfaces in your service layer using the `<protect-pointcut>` element.
This element sets up a Spring LDAP `ContextSource` for use by the other LDAP beans, defining the location of the LDAP server and other information (such as a username and password, if it doesn't allow anonymous access) for connecting to it.
It can also be used to create an embedded server for testing.
Explicitly specifies which embedded ldap server should use. Values are `apacheds` and `unboundid`. By default, it will depends if the library is available in the classpath.
Allows explicit customization of the loaded user object by specifying a UserDetailsContextMapper bean which will be called with the context information from the user's directory entry
If your users are at a fixed location in the directory (i.e. you can work out the DN directly from the username without doing a directory search), you can use this attribute to map directly to the DN.
It maps directly to the `userDnPatterns` property of `AbstractLdapAuthenticator`.
If you need to perform a search to locate the user in the directory, then you can set these attributes to control the search.
The `BindAuthenticator` will be configured with a `FilterBasedLdapUserSearch` and the attribute values map directly to the first two arguments of that bean's constructor.
If these attributes aren't set and no `user-dn-pattern` has been supplied as an alternative, then the default search values of `+user-search-filter="(uid={0})"+` and `user-search-base=""` will be used.
The substituted parameter is the user's login name.
+
If you need to perform a search to locate the user in the directory, then you can set these attributes to control the search.
The `BindAuthenticator` will be configured with a `FilterBasedLdapUserSearch` and the attribute values map directly to the first two arguments of that bean's constructor.
If these attributes aren't set and no `user-dn-pattern` has been supplied as an alternative, then the default search values of `+user-search-filter="(uid={0})"+` and `user-search-base=""` will be used.
This is used as child element to `<ldap-provider>` and switches the authentication strategy from `BindAuthenticator` to `PasswordComparisonAuthenticator`.
A bean identifier, used for referring to the bean elsewhere in the context.
[[nsa-ldap-user-service-role-prefix]]
* **role-prefix**
A non-empty string prefix that will be added to role strings loaded from persistent storage (e.g.
"ROLE_").
Use the value "none" for no prefix in cases where the default is non-empty.
[[nsa-ldap-user-service-server-ref]]
* **server-ref**
The optional server to use.
If omitted, and a default LDAP server is registered (using <ldap-server> with no Id), that server will be used.
[[nsa-ldap-user-service-user-context-mapper-ref]]
* **user-context-mapper-ref**
Allows explicit customization of the loaded user object by specifying a UserDetailsContextMapper bean which will be called with the context information from the user's directory entry
[[nsa-ldap-user-service-user-details-class]]
* **user-details-class**
Allows the objectClass of the user entry to be specified.
If set, the framework will attempt to load standard attributes for the defined class into the returned UserDetails object
[[nsa-ldap-user-service-user-search-base]]
* **user-search-base**
Search base for user searches.
Defaults to "".
Only used with a 'user-search-filter'.
[[nsa-ldap-user-service-user-search-filter]]
* **user-search-filter**
The LDAP filter used to search for users (optional).