Web Application Security
-
AuthenticationSuccessHandler
-
AuthenticationFailureHandler
-
BCryptPasswordEncoder
-
Cipher
-
ExceptionTranslator
-
FilterChainProxy
-
HttpServletRequest
-
HttpServletResponse
-
HttpMethod
-
InjectionPoint
-
Interceptor
-
MutableContext
-
RequestCache
-
RequestContextHolder
-
RequestMatch
-
RequestMatcher
-
RequestMatcherRegistry
-
RequestMapping
-
ServletContext
-
SessionManager
-
UserDetailsChecker
-
UserDetailsService
-
UserDetailsServiceImpl
-
ValidationException
-
Validator
-
access-decision-manager-ref
-
authentication-manager-ref
-
default-target-url
-
disable-url-rewriting
-
entry-point-ref
-
filter-all-dispatcher-types
-
jaas-api-provision
-
observation-registry-ref
-
pattern
-
realm
-
require-channel
-
servlet-api-provision
-
use-authorization-manager
-
use-expressions
-
use-secure-cookie
-
user-service-ref
<debug>
启用 Spring Security 调试基础架构。 这将提供可读的(多行)调试信息,以监视进入安全过滤器的请求。 这可能包括敏感信息,例如请求参数或标头,并且只应在开发环境中使用。
Enables Spring Security debugging infrastructure. This will provide human-readable (multi-line) debugging information to monitor requests coming into the security filters. This may include sensitive information, such as request parameters or headers, and should only be used in a development environment.
<http>
如果您在应用程序中使用了 <http>`元素,那么会创建一个名为“springSecurityFilterChain”的 `FilterChainProxy`bean,并且该元素中的配置将被用来在 `FilterChainProxy`中构建一个过滤器链。从 Spring Security 3.1 开始,可以再使用额外的 `http`元素添加额外的过滤器链。见 introductory chapter for how to set up the mapping from your `web.xml
。某些核心的过滤器始终会在过滤器链中创建,而其它过滤器将会根据其中出现的属性和子元素而添加到堆栈中。标准过滤器的顺序是固定的(在命名空间引言中见 the filter order table,移除之前框架版本中错误的常见来源,在这些版本中,用户必须在 `FilterChainProxy`bean 中明确配置过滤器链。当然,如果您想要完全控制配置,您仍然可以这样做。
If you use an <http>
element within your application, a FilterChainProxy
bean named "springSecurityFilterChain" is created and the configuration within the element is used to build a filter chain within
FilterChainProxy
.
As of Spring Security 3.1, additional http
elements can be used to add extra filter chains See the 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
the filter order table in the namespace introduction), removing a common source of errors with previous versions of the framework when users had to configure the filter chain explicitly in the
FilterChainProxy
bean.
You can, of course, still do this if you need full control of the configuration.
所有需要引用 AuthenticationManager
的过滤器都会自动注入由命名空间配置创建的内部实例。
All filters which require a reference to the AuthenticationManager
will be automatically injected with the internal instance created by the namespace configuration.
每个 <http>
命名空间块总是创建 SecurityContextPersistenceFilter
, ExceptionTranslationFilter
和 FilterSecurityInterceptor
。这些是固定的,不能被替代品取代。
Each <http>
namespace block always creates an SecurityContextPersistenceFilter
, an ExceptionTranslationFilter
and a FilterSecurityInterceptor
.
These are fixed and cannot be replaced with alternatives.
<http> Attributes
<http>
元素上的属性控制核心过滤器上的一些属性。
The attributes on the <http>
element control some of the properties on the core filters.
-
*access-decision-manager-ref*可选项属性,指定用于授权 HTTP 请求的 `AccessDecisionManager`实现的 ID。默认情况下,使用 `AffirmativeBased`实现与 `RoleVoter`和 `AuthenticatedVoter`一起使用。
-
access-decision-manager-ref Optional attribute specifying the ID of the
AccessDecisionManager
implementation which should be used for authorizing HTTP requests. By default anAffirmativeBased
implementation is used for with aRoleVoter
and anAuthenticatedVoter
.
-
*authentication-manager-ref*对用于由此 http 元素创建的 `FilterChain`所使用的 `AuthenticationManager`的引用。
-
authentication-manager-ref A reference to the
AuthenticationManager
used for theFilterChain
created by this http element.
-
*observation-registry-ref*用于 `FilterChain`和相关组件的 `ObservationRegistry`的引用。
-
observation-registry-ref A reference to the
ObservationRegistry
used for theFilterChain
and related components
-
*auto-config*自动注册一个登录表单、BASIC 认证和注销服务。如果将其设置为“true”,则添加所有这些功能(尽管仍然可以通过提供相应的元素自定义每个功能的配置)。如果未指定,则默认为“false”。不建议使用此属性。请改用显式配置元素以避免混淆。
-
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.
-
*create-session*控制 Spring Security 类创建 HTTP 会话的热切程度。选项包括:
-
always
- 若不存在会话,Spring Security 会主动创建一个会话。 -
always
- Spring Security will proactively create a session if one does not exist. -
ifRequired
- 只有在需要时,Spring Security 才创建会话(默认值)。 -
ifRequired
- Spring Security will only create a session only if one is required (default value). -
never
- Spring Security 从不创建会话,但会使用应用程序创建的会话(如果有的)。 -
never
- Spring Security will never create a session, but will make use of one if the application does. -
stateless
- Spring Security 不会创建会话,并忽略会话以获取 SpringAuthentication
。 -
stateless
- Spring Security will not create a session and ignore the session for obtaining a SpringAuthentication
.
-
-
create-session Controls the eagerness with which an HTTP session is created by Spring Security classes. Options include:
-
always
- 若不存在会话,Spring Security 会主动创建一个会话。 -
always
- Spring Security will proactively create a session if one does not exist. -
ifRequired
- 只有在需要时,Spring Security 才创建会话(默认值)。 -
ifRequired
- Spring Security will only create a session only if one is required (default value). -
never
- Spring Security 从不创建会话,但会使用应用程序创建的会话(如果有的)。 -
never
- Spring Security will never create a session, but will make use of one if the application does. -
stateless
- Spring Security 不会创建会话,并忽略会话以获取 SpringAuthentication
。 -
stateless
- Spring Security will not create a session and ignore the session for obtaining a SpringAuthentication
.
-
-
*disable-url-rewriting*阻止将会话 ID 附加到应用程序中的 URL。如果此属性设置为
true
,则客户端必须使用 cookie。默认值为true
。 -
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 istrue
.
-
*entry-point-ref*通常,使用的 `AuthenticationEntryPoint`会根据已配置的身份验证机制进行设置。此属性允许通过定义一个自定义 `AuthenticationEntryPoint`bean 来覆盖此行为,该 bean 将启动身份验证过程。
-
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 customizedAuthenticationEntryPoint
bean which will start the authentication process.
-
*jaas-api-provision*如果可用,则以从
JaasAuthenticationToken`获取的 `Subject`身份运行请求,这通过向堆栈添加 `JaasApiIntegrationFilter`bean 来实现。默认为 `false
。 -
jaas-api-provision If available, runs the request as the
Subject
acquired from theJaasAuthenticationToken
which is implemented by adding aJaasApiIntegrationFilter
bean to the stack. Defaults tofalse
.
-
*name*bean 标识符,用于在上下文中其他位置引用该 bean。
-
name A bean identifier, used for referring to the bean elsewhere in the context.
-
*once-per-request*对应于
FilterSecurityInterceptor`的 `observeOncePerRequest`属性。默认为 `false
。 -
once-per-request Corresponds to the
observeOncePerRequest
property ofFilterSecurityInterceptor
. Defaults tofalse
.
-
*filter-all-dispatcher-types*对应于
AuthorizationFilter`的 `shouldFilterAllDispatcherTypes`属性。当 `use-authorization-manager=false`时不起作用。默认为 `true
。 -
filter-all-dispatcher-types Corresponds to the
shouldFilterAllDispatcherTypes
property of theAuthorizationFilter
. Does not work whenuse-authorization-manager=false
. Defaults totrue
.
-
*pattern*为 http元素定义一个模式,控制将通过它定义的过滤器列表过滤哪些请求。解释取决于配置的 request-matcher。如果未定义模式,则所有请求都将匹配,因此应首先声明最具体的模式。
-
pattern Defining a pattern for the nsa-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. If no pattern is defined, all requests will be matched, so the most specific patterns should be declared first.
-
*realm*设置用于基本认证的领域名称(如果已启用)。对应于 `BasicAuthenticationEntryPoint`上的 `realmName`属性。
-
realm Sets the realm name used for basic authentication (if enabled). Corresponds to the
realmName
property onBasicAuthenticationEntryPoint
.
-
*request-matcher*定义
FilterChainProxy`中使用的 `RequestMatcher`策略和 `intercept-url`创建的 bean,以匹配传入的请求。目前的选项有 `mvc
、ant
、regex`和 `ciRegex
,分别用于 Spring MVC、Ant、正则表达式和小写正则表达式。对于每个 intercept-url元素使用其 pattern、method和 servlet-path属性创建一个单独的实例。Ant 路径使用AntPathRequestMatcher`匹配,正则表达式使用 `RegexRequestMatcher`匹配,对于 Spring MVC 路径匹配,使用 `MvcRequestMatcher
。有关确切执行匹配方式的更多详细信息,请参阅这些类的 Javadoc。如果有 Spring MVC 存在于类路径中,MVC 是默认策略,如果没有,则使用 Ant 路径。 -
request-matcher Defines the
RequestMatcher
strategy used in theFilterChainProxy
and the beans created by theintercept-url
to match incoming requests. Options are currentlymvc
,ant
,regex
andciRegex
, for Spring MVC, ant, regular-expression and case-insensitive regular-expression respectively. A separate instance is created for each nsa-intercept-url element using its nsa-intercept-url-pattern, nsa-intercept-url-method and nsa-intercept-url-servlet-path attributes. Ant paths are matched using anAntPathRequestMatcher
, regular expressions are matched using aRegexRequestMatcher
and for Spring MVC path matching theMvcRequestMatcher
is used. See the Javadoc for these classes for more details on exactly how the matching is performed. MVC is the default strategy if Spring MVC is present in the classpath, if not, Ant paths are used.
-
*request-matcher-ref*对实现
RequestMatcher`的 bean 的引用,该 bean 将确定是否应使用此 `FilterChain
。这是一种更为强大的 pattern替代方案。 -
request-matcher-ref A reference to a bean that implements
RequestMatcher
that will determine if thisFilterChain
should be used. This is a more powerful alternative to nsa-http-pattern.
-
*security*将请求模式映射到一个空的筛选器链,通过设置这个属性为
none
.不会应用任何安全设置,Spring 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.
-
*security-context-repository-ref*允许将自定义
SecurityContextHolderStrategy
引入SecurityContextPersistenceFilter
,SecurityContextHolderFilter
,BasicAuthenticationFilter
,UsernamePasswordAuthenticationFilter
,ExceptionTranslationFilter
,LogoutFilter
和其他。 -
security-context-repository-ref Allows injection of a custom
SecurityContextHolderStrategy
intoSecurityContextPersistenceFilter
,SecurityContextHolderFilter
,BasicAuthenticationFilter
,UsernamePasswordAuthenticationFilter
,ExceptionTranslationFilter
,LogoutFilter
, and others.
-
*security-context-explicit-save*如果为真,使用
SecurityContextHolderFilter
代替SecurityContextPersistenceFilter
. 需要显式保存 -
security-context-explicit-save If true, use
SecurityContextHolderFilter
instead ofSecurityContextPersistenceFilter
. Requires explicit save
-
*security-context-repository-ref*允许将自定义
SecurityContextRepository
引入SecurityContextPersistenceFilter
. -
security-context-repository-ref Allows injection of a custom
SecurityContextRepository
into theSecurityContextPersistenceFilter
.
-
*servlet-api-provision*提供
HttpServletRequest
安全方法(如isUserInRole()
和getPrincipal()
)的版本,这些方法通过将SecurityContextHolderAwareRequestFilter
bean 添加到堆栈中实现。默认值为true
. -
servlet-api-provision Provides versions of
HttpServletRequest
security methods such asisUserInRole()
andgetPrincipal()
which are implemented by adding aSecurityContextHolderAwareRequestFilter
bean to the stack. Defaults totrue
.
-
*use-expressions*在
access
属性中启用 EL 表达式,如 expression-based access-control 章节中所述。默认值为真。 -
use-expressions Enables EL-expressions in the
access
attribute, as described in the chapter on expression-based access-control. The default value is true.
<access-denied-handler>
该元素允许您为 `ExceptionTranslationFilter`所使用的默认 `AccessDeniedHandler`设置 `errorPage`属性,使用 error-page属性,或使用 ref属性来提供您自己的实现。这在 ExceptionTranslationFilter的章节中作了更详细的讨论。
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 attribute, or to supply your own implementation using the nsa-access-denied-handler-ref attribute.
This is discussed in more detail in the section on the ExceptionTranslationFilter.
<access-denied-handler> Attributes
-
*error-page*已验证用户的访问被拒绝的页面,如果他们请求他们无权访问的页面,将会被重定向到该页面。
-
error-page The access denied page that an authenticated user will be redirected to if they request a page which they don’t have the authority to access.
-
*ref*定义对类型为
AccessDeniedHandler
的 Spring bean 的引用。 -
ref Defines a reference to a Spring bean of type
AccessDeniedHandler
.
<cors>
此元素允许配置 CorsFilter
。 如果未指定 CorsFilter
或 CorsConfigurationSource
且 Spring MVC 在类路径中,则将 HandlerMappingIntrospector
用作 CorsConfigurationSource
。
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
.
<cors> Attributes
<cors>
元素上的属性控制 headers 元素。
The attributes on the <cors>
element control the headers element.
-
*ref*可选属性,用于指定
CorsFilter
的 Bean 名称。 -
ref Optional attribute that specifies the bean name of a
CorsFilter
.
-
*cors-configuration-source-ref*可选属性,用于指定要注入到 XML 命名空间创建的
CorsFilter
中的CorsConfigurationSource
的 Bean 名称。 -
cors-configuration-source-ref Optional attribute that specifies the bean name of a
CorsConfigurationSource
to be injected into aCorsFilter
created by the XML namespace.
<headers>
该元素用于配置附加的(安全性)标头以便随应答送出。它为几个标头启用了轻松配置,并且还允许通过 header元素设置自定义标头。可以在参考的 Security Headers章节中找到附加信息。
This element allows for configuring additional (security) headers to be send with the response. It enables easy configuration for several headers and also allows for setting custom headers through the nsa-header element. Additional information, can be found in the Security Headers section of the reference.
-
Cache-Control
,Pragma
, 和Expires
- 可以使用 cache-control 元素设置。这确保浏览器不会缓存您的安全页面。 -
Cache-Control
,Pragma
, andExpires
- Can be set using the nsa-cache-control element. This ensures that the browser does not cache your secured pages. -
Strict-Transport-Security
- 可以使用 hsts 元素设置。这将确保浏览器会自动请求 HTTPS 用于未来的请求。 -
Strict-Transport-Security
- Can be set using the nsa-hsts element. This ensures that the browser automatically requests HTTPS for future requests. -
X-Frame-Options
- 可以使用 frame-options 元素设置: X-Frame-Options 头部可以用于防止点击劫持攻击。 -
X-Frame-Options
- Can be set using the nsa-frame-options element. The X-Frame-Options header can be used to prevent clickjacking attacks. -
X-XSS-Protection
- 可以使用 xss-protection 元素设置: X-XSS-Protection 头部可由浏览器用于进行基本控制。 -
X-XSS-Protection
- Can be set using the nsa-xss-protection element. The X-XSS-Protection header can be used by browser to do basic control. -
X-Content-Type-Options
- 可以使用 content-type-options 元素设置: X-Content-Type-Options 头部可以防止 Internet Explorer 将响应 MIME 嗅探至距离已声明内容类型。这也适用于 Google Chrome,在下载扩展时。 -
X-Content-Type-Options
- Can be set using the nsa-content-type-options element. The X-Content-Type-Options header prevents Internet Explorer from MIME-sniffing a response away from the declared content-type. This also applies to Google Chrome, when downloading extensions. -
Public-Key-Pinning
或Public-Key-Pinning-Report-Only
- 可以使用 hpkp 元素设置:这使 HTTPS 网站可以抵御使用错误签发或其他欺诈证书进行冒充的攻击者。 -
Public-Key-Pinning
orPublic-Key-Pinning-Report-Only
- Can be set using the nsa-hpkp element. This allows HTTPS websites to resist impersonation by attackers using mis-issued or otherwise fraudulent certificates. -
Content-Security-Policy
或Content-Security-Policy-Report-Only
- 可以使用 content-security-policy 元素设置: Content Security Policy (CSP) 是 Web 应用程序可以利用来减轻内容注入漏洞(例如跨站点脚本 (XSS))的机制。 -
Content-Security-Policy
orContent-Security-Policy-Report-Only
- Can be set using the nsa-content-security-policy element. 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
- 可以使用 referrer-policy 元素设置: Referrer-Policy 是 Web 应用程序可以利用来管理引用字段的机制,该字段包含用户所在的上一页。 -
Referrer-Policy
- Can be set using the nsa-referrer-policy element, 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
- 可以使用 feature-policy 元素设置: Feature-Policy 是允许 Web 开发人员选择性地启用、禁用和修改浏览器中某些 API 和 Web 功能的行为的一种机制。 -
Feature-Policy
- Can be set using the nsa-feature-policy element, Feature-Policy is a mechanism that allows web developers to selectively enable, disable, and modify the behavior of certain APIs and web features in the browser. -
Cross-Origin-Opener-Policy
- 可以使用 cross-origin-opener-policy 元素设置: Cross-Origin-Opener-Policy 允许您确保顶级文档不与跨域文档共享浏览上下文组。 -
Cross-Origin-Opener-Policy
- Can be set using the nsa-cross-origin-opener-policy element, Cross-Origin-Opener-Policy is a mechanism that allows you to ensure a top-level document does not share a browsing context group with cross-origin documents. -
Cross-Origin-Embedder-Policy
- 可以使用 cross-origin-embedder-policy 元素设置: Cross-Origin-Embedder-Policy 是阻止文档加载任何未明确授予文档权限的跨域资源的机制。 -
Cross-Origin-Embedder-Policy
- Can be set using the nsa-cross-origin-embedder-policy element, Cross-Origin-Embedder-Policy is a mechanism that prevents a document from loading any cross-origin resources that don’t explicitly grant the document permission. -
Cross-Origin-Resource-Policy
- 可以使用 cross-origin-resource-policy 元素设置: Cross-Origin-Resource-Policy 传达了让浏览器阻止针对给定资源的 no-cors 跨域/跨站点请求的愿望。 -
Cross-Origin-Resource-Policy
- Can be set using the nsa-cross-origin-resource-policy element, Cross-Origin-Resource-Policy is a mechanism that conveys a desire that the browser blocks no-cors cross-origin/cross-site requests to the given resource.
<headers> Attributes
<headers>
元素上的属性控制 headers 元素。
The attributes on the <headers>
element control the headers element.
-
*defaults-disabled*可选属性,用于指定禁用 Spring Security 的默认 HTTP 响应标头。默认值为假(包括默认标头)。
-
defaults-disabled Optional attribute that specifies to disable the default Spring Security’s HTTP response headers. The default is false (the default headers are included).
-
*disabled*可选属性,用于指定禁用 Spring Security 的 HTTP 响应标头。默认值为假(标头已启用)。
-
disabled Optional attribute that specifies to disable Spring Security’s HTTP response headers. The default is false (the headers are enabled).
<cache-control>
添加 Cache-Control
, Pragma
和 Expires
headers 以确保浏览器不会缓存您的安全页面。
Adds Cache-Control
, Pragma
, and Expires
headers to ensure that the browser does not cache your secured pages.
<cache-control> Attributes
-
*disabled*指定是否应禁用 Cache Control。默认值为假。
-
disabled Specifies if Cache Control should be disabled. Default false.
<hsts>
启用后,将向任何安全请求的响应中添加 Strict-Transport-Security 头部。这允许服务器指示浏览器在将来的请求中自动使用 HTTPS。
When enabled adds the Strict-Transport-Security header to the response for any secure request. This allows the server to instruct browsers to automatically use HTTPS for future requests.
<hsts> Attributes
-
*disabled*指定是否应禁用 Strict-Transport-Security。默认值为假。
-
disabled Specifies if Strict-Transport-Security should be disabled. Default false.
-
*include-sub-domains*指定是否应包括子域。默认值为真。
-
include-sub-domains Specifies if subdomains should be included. Default true.
-
*max-age-seconds*指定主机应被视为已知 HSTS 主机的最长时间。默认一年。
-
max-age-seconds Specifies the maximum amount of time the host should be considered a Known HSTS Host. Default one year.
-
*request-matcher-ref*用于确定是否应设置头的 RequestMatcher 实例。默认值为 HttpServletRequest.isSecure() 为 true。
-
request-matcher-ref The RequestMatcher instance to be used to determine if the header should be set. Default is if HttpServletRequest.isSecure() is true.
-
*preload*指定是否应包含预加载。默认值为 false。
-
preload Specifies if preload should be included. Default false.
<hpkp>
启用后,将向任何安全请求的响应中添加 Public Key Pinning Extension for HTTP 头部。这允许 HTTPS 网站抵御攻击者使用错误签发或其他欺诈性证书进行的假冒。
When enabled adds the Public Key Pinning Extension for HTTP header to the response for any secure request. This allows HTTPS websites to resist impersonation by attackers using mis-issued or otherwise fraudulent certificates.
<hpkp> Attributes
-
*disabled*指定是否应禁用 HTTP 公钥固定 (HPKP)。默认值为 true。
-
disabled Specifies if HTTP Public Key Pinning (HPKP) should be disabled. Default true.
-
*include-sub-domains*指定是否应包含子域。默认值为 false。
-
include-sub-domains Specifies if subdomains should be included. Default false.
-
*max-age-seconds*设置 Public-Key-Pins 头的 max-age 指令的值。默认 60 天。
-
max-age-seconds Sets the value for the max-age directive of the Public-Key-Pins header. Default 60 days.
-
*report-only*指定浏览器是否应仅报告 pin 验证失败。默认值为 true。
-
report-only Specifies if the browser should only report pin validation failures. Default true.
-
*report-uri*指定浏览器应向其报告 pin 验证失败的 URI。
-
report-uri Specifies the URI to which the browser should report pin validation failures.
<pin>
<content-security-policy>
启用后,将向响应中添加 Content Security Policy (CSP) 头部。CSP 是一种 Web 应用程序可以利用的机制,以减轻内容注入漏洞,例如跨站点脚本 (XSS)。
When enabled adds the Content Security Policy (CSP) header to the response. CSP is a mechanism that web applications can leverage to mitigate content injection vulnerabilities, such as cross-site scripting (XSS).
<content-security-policy> Attributes
-
*policy-directives*Content-Security-Policy 头的安全策略指令,如果 report-only 设置为 true,则使用 Content-Security-Policy-Report-Only 头。
-
policy-directives The security policy directive(s) for the Content-Security-Policy header or if report-only is set to true, then the Content-Security-Policy-Report-Only header is used.
-
*report-only*设置为 true,以启用 Content-Security-Policy-Report-Only 头仅报告策略违规行为。默认为 false。
-
report-only Set to true, to enable the Content-Security-Policy-Report-Only header for reporting policy violations only. Defaults to false.
<referrer-policy>
如果启用,则向响应添加 Referrer Policy标头。
When enabled adds the Referrer Policy header to the response.
<referrer-policy> Attributes
-
*policy*Referrer-Policy 标头的策略。默认值“no-referrer”。
-
policy The policy for the Referrer-Policy header. Default "no-referrer".
<feature-policy>
如果启用,则向响应添加 Feature Policy标头。
When enabled adds the Feature Policy header to the response.
<feature-policy> Attributes
-
*policy-directives*Feature-Policy 标头的安全策略指令。
-
policy-directives The security policy directive(s) for the Feature-Policy header.
<frame-options>
如果启用,则向响应添加 X-Frame-Options header,这允许更新的浏览器执行一些安全性检查和防止 clickjacking攻击。
When enabled adds the X-Frame-Options header to the response, this allows newer browsers to do some security checks and prevent clickjacking attacks.
<frame-options> Attributes
-
*disabled*如果禁用,将不包含 X-Frame-Options 头。默认值为 false。
-
disabled If disabled, the X-Frame-Options header will not be included. Default false.
-
policy
-
`DENY`此页面无法在框架中显示,无论尝试执行此操作的网站如何。当指定 frame-options-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`此页面只能显示在与页面本身同源的框架中
-
SAMEORIGIN
The page can only be displayed in a frame on the same origin as the page itself
-
换句话说,如果您指定 DENY,不仅从其他网站加载页面尝试在框架中加载失败,而且从同一个网站加载时也会失败。另一方面,如果您指定 SAMEORIGIN,只要网站在框架中包含该页面并且与提供该页面的网站相同,您仍然可以在框架中使用该页面。
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.
<permissions-policy>
向响应添加 Permissions-Policy header。
Adds the Permissions-Policy header to the response.
<permissions-policy> Attributes
-
*policy*要为 `Permissions-Policy`头写入的策略值
-
policy The policy value to write for the
Permissions-Policy
header
<xss-protection>
向响应添加 X-XSS-Protection header来协助防御 reflected / Type-1 Cross-Site Scripting (XSS)攻击。这绝不是对 XSS 攻击的全面保护!
Adds the X-XSS-Protection header to the response to assist in protecting against reflected / Type-1 Cross-Site Scripting (XSS) attacks. This is in no-way a full protection to XSS attacks!
<xss-protection> Attributes
-
*xss-protection-disabled*不包括 reflected / Type-1 Cross-Site Scripting (XSS)保护的头。
-
xss-protection-disabled Do not include the header for reflected / Type-1 Cross-Site Scripting (XSS) protection.
-
*xss-protection-header-value*明确设置 reflected / Type-1 Cross-Site Scripting (XSS)头的值。一个: “0”、“1”、“1;mode=block”。默认为“0”。
-
xss-protection-header-value Explicitly set the value for reflected / Type-1 Cross-Site Scripting (XSS) header. One of: "0", "1", "1; mode=block". Defaults to "0".
<content-type-options>
向响应添加名为 nosniff 的 X-Content-Type-Options 标头。该 disables MIME-sniffing用于 IE8+ 和 Chrome 扩展。
Add the X-Content-Type-Options header with the value of nosniff to the response. This disables MIME-sniffing for IE8+ and Chrome extensions.
<content-type-options> Attributes
-
*disabled*指定是否应禁用内容类型选项。默认值为 false。
-
disabled Specifies if Content Type Options should be disabled. Default false.
Parent Elements of <content-type-options>
<cross-origin-embedder-policy>
如果启用,则向响应添加 Cross-Origin-Embedder-Policy标头。
When enabled adds the Cross-Origin-Embedder-Policy header to the response.
<cross-origin-embedder-policy> Attributes
-
policy`Cross-Origin-Embedder-Policy`头的策略。
-
policy The policy for the
Cross-Origin-Embedder-Policy
header.
<cross-origin-opener-policy>
如果启用,则向响应添加 Cross-Origin-Opener-Policy标头。
When enabled adds the Cross-Origin-Opener-Policy header to the response.
<cross-origin-opener-policy> Attributes
-
policy`Cross-Origin-Opener-Policy`头的策略。
-
policy The policy for the
Cross-Origin-Opener-Policy
header.
<cross-origin-resource-policy>
如果启用,则向响应添加 Cross-Origin-Resource-Policy标头。
When enabled adds the Cross-Origin-Resource-Policy header to the response.
<cross-origin-resource-policy> Attributes
-
policy`Cross-Origin-Resource-Policy`头的策略。
-
policy The policy for the
Cross-Origin-Resource-Policy
header.
<header>
向响应添加其他标头,需要指定名称和值。
Add additional headers to the response, both the name and value need to be specified.
<header-attributes> Attributes
-
*header-name*头的
name
。 -
header-name The
name
of the header.
-
*value*要添加的头的
value
。 -
value The
value
of the header to add.
-
*ref*对 `HeaderWriter`接口的自定义实现的引用。
-
ref Reference to a custom implementation of the
HeaderWriter
interface.
<anonymous>
将 AnonymousAuthenticationFilter
添加到堆栈和 AnonymousAuthenticationProvider
。如果您正在使用 IS_AUTHENTICATED_ANONYMOUSLY
属性,则需要此功能。
Adds an AnonymousAuthenticationFilter
to the stack and an AnonymousAuthenticationProvider
.
Required if you are using the IS_AUTHENTICATED_ANONYMOUSLY
attribute.
<anonymous> Attributes
-
*enabled*使用默认命名空间设置时,将自动启用匿名“身份验证”功能。您可以使用此属性禁用它。
-
enabled With the default namespace setup, the anonymous "authentication" facility is automatically enabled. You can disable it using this property.
-
*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.
-
*username*应分配给匿名请求的用户名。这允许识别担任者,这对于日志记录和审核很重要。如果未设置,则默认为
anonymousUser
. -
username The username that should be assigned to the anonymous request. This allows the principal to be identified, which may be important for logging and auditing. if unset, defaults to
anonymousUser
.
<csrf>
该元素将会向应用程序添加 Cross Site Request Forger (CSRF)保护。它还更新默认的 RequestCache,以便在身份验证成功后仅回复“GET”请求。可以在参考的 Cross Site Request Forgery (CSRF)章节中找到附加信息。
This element will add Cross Site Request Forger (CSRF) protection to the application. It also updates the default RequestCache to only replay "GET" requests upon successful authentication. Additional information can be found in the Cross Site Request Forgery (CSRF) section of the reference.
<csrf> Attributes
-
*disabled*指定禁用 Spring 安全性的 CSRF 保护的可选特性。默认值为 false(启用 CSRF 保护)。强烈建议启用 CSRF 保护。
-
disabled Optional attribute that specifies to disable Spring Security’s CSRF protection. The default is false (CSRF protection is enabled). It is highly recommended to leave CSRF protection enabled.
-
*token-repository-ref*要使用的 CsrfTokenRepository。默认值为
HttpSessionCsrfTokenRepository
. -
token-repository-ref The CsrfTokenRepository to use. The default is
HttpSessionCsrfTokenRepository
.
-
*request-handler-ref*要使用的可选
CsrfTokenRequestHandler
。默认值为CsrfTokenRequestAttributeHandler
. -
request-handler-ref The optional
CsrfTokenRequestHandler
to use. The default isCsrfTokenRequestAttributeHandler
.
-
*request-matcher-ref*将用于确定是否应应用 CSRF 的 RequestMatcher 实例。除“GET”、“TRACE”、“HEAD”、“OPTIONS”外,默认值为任何 HTTP 方法。
-
request-matcher-ref The RequestMatcher instance to be used to determine if CSRF should be applied. Default is any HTTP method except "GET", "TRACE", "HEAD", "OPTIONS".
<custom-filter>
该元素用于将过滤器添加到过滤器链中。它不创建任何附加的 bean,但它用于选择应用程序上下文中已经定义的类型为 `jakarta.servlet.Filter`的 bean,并且将其添加到 Spring Security 维护的过滤器链中的特定位置。可以在 namespace chapter中找到全部详细信息。
This element is used to add a filter to the filter chain.
It doesn’t create any additional beans but is used to select a bean of type jakarta.servlet.Filter
which is already defined in the application context and add that at a particular position in the filter chain maintained by Spring Security.
Full details can be found in the namespace chapter.
<custom-filter> Attributes
-
*after*自定义过滤器应在链中插入到其正后的过滤器。此功能仅适用于高级用户,他们希望将自己的过滤器混入安全过滤器链并且具备一些标准 Spring 安全性过滤器的知识。过滤器名称映射到特定的 Spring 安全性实现过滤器。
-
after The filter immediately after which the custom-filter should be placed in the chain. This feature will only be needed by advanced users who wish to mix their own filters into the security filter chain and have some knowledge of the standard Spring Security filters. The filter names map to specific Spring Security implementation filters.
-
*before*自定义过滤器应在链中插入到其正前的过滤器
-
before The filter immediately before which the custom-filter should be placed in the chain
-
*position*应在链中插入自定义过滤器的明确位置。在替换标准过滤器时使用。
-
position The explicit position at which the custom-filter should be placed in the chain. Use if you are replacing a standard filter.
-
*ref*定义对实现 `Filter`的 Spring bean 的引用。
-
ref Defines a reference to a Spring bean that implements
Filter
.
<expression-handler>
如果启用了基于表达式的访问控制,将使用定义的 SecurityExpressionHandler
实例。如果没有提供,将使用默认实现(不具有 ACL 支持)。
Defines the SecurityExpressionHandler
instance which will be used if expression-based access-control is enabled.
A default implementation (with no ACL support) will be used if not supplied.
<form-login>
用于向过滤器堆栈添加 UsernamePasswordAuthenticationFilter
,并向应用程序上下文添加 LoginUrlAuthenticationEntryPoint
以按需提供身份验证。这将始终优先于其他由命名空间创建的入口点。如果没有提供属性,则将在 URL“/login”上自动生成登录页面,此功能只是为了方便,不适用于生产(已经选择了一种视图技术,并且可以用于呈现自定义登录页面)。DefaultLoginPageGeneratingFilter
类负责呈现登录页面,并且将在需要时提供普通表单登录和/或 OIDC 的登录表单。可以使用 <<`<form-login>` 属性,nsa-form-login-attributes>> 自定义行为。
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" This feature is really just provided for convenience and is not intended for production (where a view technology will have been chosen and can be used to render a customized login page). The class DefaultLoginPageGeneratingFilter
is responsible for rendering the login page and will provide login forms for both normal form login and/or OIDC if required. The behaviour can be customized using the <<`<form-login>` Attributes,nsa-form-login-attributes>>.
<form-login> Attributes
-
*always-use-default-target*如果设置为
true
,则无论用户如何到达登录页面,用户始终将从 default-target-url给定的值开始。映射到UsernamePasswordAuthenticationFilter`的 `alwaysUseDefaultTargetUrl`属性。默认值为 `false
. -
always-use-default-target If set to
true
, the user will always start at the value given by nsa-form-login-default-target-url, regardless of how they arrived at the login page. Maps to thealwaysUseDefaultTargetUrl
property ofUsernamePasswordAuthenticationFilter
. Default value isfalse
.
-
*authentication-details-source-ref*对 `AuthenticationDetailsSource`的引用,其中认证过滤器将使用该引用
-
authentication-details-source-ref Reference to an
AuthenticationDetailsSource
which will be used by the authentication filter
-
*authentication-failure-handler-ref*可用作 authentication-failure-url的替代方法,让你在认证失败后可以完全控制导航流程。该值应该是应用程序上下文中 `AuthenticationFailureHandler`bean 的名称。
-
authentication-failure-handler-ref Can be used as an alternative to nsa-form-login-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.
-
*authentication-failure-url*映射到
UsernamePasswordAuthenticationFilter`的 `authenticationFailureUrl`属性。定义浏览器在登录失败时将被重定向到的 URL。默认为 `/login?error
,它将由自动登录页面生成器自动处理,使用错误消息重新渲染登录页面。 -
authentication-failure-url Maps to the
authenticationFailureUrl
property ofUsernamePasswordAuthenticationFilter
. 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.
-
*authentication-success-handler-ref*它可以用作 default-target-url和 always-use-default-target的替代方法,让你在认证成功后可以完全控制导航流程。该值应该是应用程序上下文中 `AuthenticationSuccessHandler`bean 的名称。默认情况下,将使用 `SavedRequestAwareAuthenticationSuccessHandler`并使用 default-target-url 注入它的实现。
-
authentication-success-handler-ref This can be used as an alternative to nsa-form-login-default-target-url and nsa-form-login-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 ofSavedRequestAwareAuthenticationSuccessHandler
is used and injected with the nsa-form-login-default-target-url.
-
*default-target-url*映射到 `UsernamePasswordAuthenticationFilter`的 `defaultTargetUrl`属性。如果未设置,则默认值为“/”(应用程序根目录)。用户将在此登录后被带到此 URL,前提是他们在尝试访问受保护资源时不会被要求登录,此时他们将被带到最初请求的 URL。
-
default-target-url Maps to the
defaultTargetUrl
property ofUsernamePasswordAuthenticationFilter
. 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.
-
*login-page*用于呈现登录页面的 URL。映射到 `LoginUrlAuthenticationEntryPoint`的 `loginFormUrl`属性。默认为“/login”。
-
login-page The URL that should be used to render the login page. Maps to the
loginFormUrl
property of theLoginUrlAuthenticationEntryPoint
. Defaults to "/login".
-
*login-processing-url*映射到 `UsernamePasswordAuthenticationFilter``filterProcessesUrl`属性。默认值为“/login”。
-
login-processing-url Maps to the
filterProcessesUrl
property ofUsernamePasswordAuthenticationFilter
. The default value is "/login".
-
*password-parameter*包含密码的请求参数的名称。默认为“password”。
-
password-parameter The name of the request parameter which contains the password. Defaults to "password".
-
*username-parameter*包含用户名的请求参数的名称。默认为“username”。
-
username-parameter The name of the request parameter which contains the username. Defaults to "username".
-
*authentication-success-forward-url*映射 `ForwardAuthenticationSuccessHandler`到 `UsernamePasswordAuthenticationFilter`的 `authenticationSuccessHandler`属性。
-
authentication-success-forward-url Maps a
ForwardAuthenticationSuccessHandler
toauthenticationSuccessHandler
property ofUsernamePasswordAuthenticationFilter
.
-
*authentication-failure-forward-url*映射 `ForwardAuthenticationFailureHandler`到 `UsernamePasswordAuthenticationFilter`的 `authenticationFailureHandler`属性。
-
authentication-failure-forward-url Maps a
ForwardAuthenticationFailureHandler
toauthenticationFailureHandler
property ofUsernamePasswordAuthenticationFilter
.
<oauth2-login>
OAuth 2.0 Login功能使用 OAuth 2.0 和/或 OpenID Connect 1.0 提供者来配置身份验证支持。
The OAuth 2.0 Login feature configures authentication support using an OAuth 2.0 and/or OpenID Connect 1.0 Provider.
<oauth2-login> Attributes
-
client-registration-repository-ref Reference to the
ClientRegistrationRepository
.
-
access-token-response-client-ref Reference to the
OAuth2AccessTokenResponseClient
.
-
user-service-ref Reference to the
OAuth2UserService
.
-
*oidc-user-service-ref*对 OpenID Connect `OAuth2UserService`的引用。
-
oidc-user-service-ref Reference to the OpenID Connect
OAuth2UserService
.
-
*login-processing-url*过滤器处理认证请求的 URI。
-
login-processing-url The URI where the filter processes authentication requests.
-
*login-page*用于向用户发送登录请求的 URI。
-
login-page The URI to send users to login.
-
authentication-success-handler-ref Reference to the
AuthenticationSuccessHandler
.
-
authentication-failure-handler-ref Reference to the
AuthenticationFailureHandler
.
-
jwt-decoder-factory-ref`OidcAuthorizationCodeAuthenticationProvider`使用的 `JwtDecoderFactory`的引用。
-
jwt-decoder-factory-ref Reference to the
JwtDecoderFactory
used byOidcAuthorizationCodeAuthenticationProvider
.
<oauth2-client>
配置 OAuth 2.0 Client的支持。
Configures OAuth 2.0 Client support.
<oauth2-client> Attributes
-
client-registration-repository-ref Reference to the
ClientRegistrationRepository
.
<authorization-code-grant>
Configures OAuth 2.0 Authorization Code Grant.
<client-registrations>
向 OAuth 2.0 或 OpenID Connect 1.0 提供者注册 (ClientRegistration) 的客户端的容器元素。
A container element for client(s) registered (ClientRegistration) with an OAuth 2.0 or OpenID Connect 1.0 Provider.
<client-registration>
代表一个已使用 OAuth 2.0 或 OpenID Connect 1.0 供应商注册的客户端。
Represents a client registered with an OAuth 2.0 or OpenID Connect 1.0 Provider.
<client-registration> Attributes
-
*registration-id*唯一标识 `ClientRegistration`的 ID。
-
registration-id The ID that uniquely identifies the
ClientRegistration
.
-
client-id The client identifier.
-
client-secret The client secret.
-
client-authentication-method*用于使用提供程序对客户端进行身份认证的方法。支持的值为 *client_secret_basic, client_secret_post, private_key_jwt, client_secret_jwt*和 *none (public clients)。
-
client-authentication-method The method used to authenticate the Client with the Provider. The supported values are client_secret_basic, client_secret_post, private_key_jwt, client_secret_jwt and none (public clients).
-
*redirect-uri*客户端的注册重定向 URI,_Authorization Server_在最终用户经过身份验证并授权了对客户端的访问权限后将最终用户用户代理重定向到该 URI。
-
redirect-uri The client’s registered redirect URI that the Authorization Server redirects the end-user’s user-agent to after the end-user has authenticated and authorized access to the client.
-
*scope*客户端在授权请求流程期间请求的范围 (scope),例如 openid、email 或 profile。
-
scope The scope(s) requested by the client during the Authorization Request flow, such as openid, email, or profile.
-
*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.
-
*provider-id*对关联提供程序的引用。可以引用 `<provider>`元素或使用其中一个通用提供程序 (google、github、facebook、okta)。
-
provider-id A reference to the associated provider. May reference a
<provider>
element or use one of the common providers (google, github, facebook, okta).
<provider>
OAuth 2.0 或 OpenID Connect 1.0 供应商的配置信息。
The configuration information for an OAuth 2.0 or OpenID Connect 1.0 Provider.
<provider> Attributes
-
*provider-id*唯一标识提供程序的 ID。
-
provider-id The ID that uniquely identifies the provider.
-
*token-uri*授权服务器的令牌端点 URI。
-
token-uri The Token Endpoint URI for the Authorization Server.
-
*user-info-uri*用于访问经过身份验证的最终用户声明/属性的用户信息端点 URI。
-
user-info-uri The UserInfo Endpoint URI used to access the claims/attributes of the authenticated end-user.
-
user-info-authentication-method*在向用户信息端点发送访问令牌时使用的身份验证方法。支持的值为 *header, form*和 *query。
-
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.
-
*user-info-user-name-attribute*用户信息响应中返回的属性名称,该名称引用最终用户的名称或标识符。
-
user-info-user-name-attribute The name of the attribute returned in the UserInfo Response that references the Name or Identifier of the end-user.
-
*jwk-set-uri*用于从授权服务器检索 JSON Web Key (JWK)集的 URI,其中包含用于验证 ID 令牌和用户信息响应(可选)的 JSON Web Signature (JWS)的加密密钥。
-
jwk-set-uri The URI used to retrieve the JSON Web Key (JWK) Set from the Authorization Server, which contains the cryptographic key(s) used to verify the JSON Web Signature (JWS) of the ID Token and optionally the UserInfo Response.
-
*issuer-uri*用于最初配置 `ClientRegistration`的 URI,该 URI 使用 OpenID Connect 提供程序的 Configuration endpoint或授权服务器的 Metadata endpoint进行发现。
-
issuer-uri The URI used to initially configure a
ClientRegistration
using discovery of an OpenID Connect Provider’s Configuration endpoint or an Authorization Server’s Metadata endpoint.
<oauth2-resource-server>
在配置中添加 BearerTokenAuthenticationFilter
、BearerTokenAuthenticationEntryPoint
和 BearerTokenAccessDeniedHandler
。此外,还必须指定 <jwt>
或 <opaque-token>
。
Adds a BearerTokenAuthenticationFilter
, BearerTokenAuthenticationEntryPoint
, and BearerTokenAccessDeniedHandler
to the configuration.
In addition, either <jwt>
or <opaque-token>
must be specified.
<oauth2-resource-server> Attributes
-
*authentication-manager-resolver-ref*对将在请求时解析 `AuthenticationManager`的 `AuthenticationManagerResolver`的引用。
-
authentication-manager-resolver-ref Reference to an
AuthenticationManagerResolver
which will resolve theAuthenticationManager
at request time
-
*bearer-token-resolver-ref*对将从请求中检索出示令牌的 `BearerTokenResolver`的引用。
-
bearer-token-resolver-ref Reference to a
BearerTokenResolver
which will retrieve the bearer token from the request
-
*entry-point-ref*对将处理未经授权请求的 `AuthenticationEntryPoint`的引用。
-
entry-point-ref Reference to a
AuthenticationEntryPoint
which will handle unauthorized requests
<jwt>
表示将授权 JWT 的 OAuth 2.0 资源服务器
Represents an OAuth 2.0 Resource Server that will authorize JWTs
<jwt> Attributes
-
*jwt-authentication-converter-ref*对 `Converter<Jwt, AbstractAuthenticationToken>`的引用。
-
jwt-authentication-converter-ref Reference to a
Converter<Jwt, AbstractAuthenticationToken>
-
*jwt-decoder-ref*对
JwtDecoder`的引用。这是一个更大的组件,它将覆盖 `jwk-set-uri
。 -
jwt-decoder-ref Reference to a
JwtDecoder
. This is a larger component that overridesjwk-set-uri
-
*jwk-set-uri*用于从 OAuth 2.0 授权服务器加载签名验证密钥的 JWK 集 Uri。
-
jwk-set-uri The JWK Set Uri used to load signing verification keys from an OAuth 2.0 Authorization Server
<opaque-token>
表示将授权不透明令牌的 OAuth 2.0 资源服务器
Represents an OAuth 2.0 Resource Server that will authorize opaque tokens
<opaque-token> Attributes
-
*introspector-ref*对
OpaqueTokenIntrospector`的引用。这是一个更大的组件,它将覆盖 `introspection-uri
,client-id`和 `client-secret
。 -
introspector-ref Reference to an
OpaqueTokenIntrospector
. This is a larger component that overridesintrospection-uri
,client-id
, andclient-secret
.
-
*introspection-uri*用于检查不透明令牌详细信息的内省 Uri。应附带
client-id`和 `client-secret
。 -
introspection-uri The Introspection Uri used to introspect the details of an opaque token. Should be accompanied with a
client-id
andclient-secret
.
-
*client-id*用于对提供的 `introspection-uri`进行客户端身份验证的客户端 Id。
-
client-id The Client Id to use for client authentication against the provided
introspection-uri
.
-
*client-secret*用于对提供的 `introspection-uri`进行客户端身份验证的客户端机密。
-
client-secret The Client Secret to use for client authentication against the provided
introspection-uri
.
-
*authentication-converter-ref*对 `OpaqueTokenAuthenticationConverter`的引用。负责将成功的内省结果转换成 `Authentication`实例。
-
authentication-converter-ref Reference to an
OpaqueTokenAuthenticationConverter
. Responsible for converting successful introspection result into anAuthentication
instance.
<relying-party-registrations>
向 SAML 2.0 身份提供者注册 (ClientRegistration) 的依赖方的容器元素。
The container element for relying party(ies) registered (ClientRegistration) with a SAML 2.0 Identity Provider.
<relying-party-registration>
表示向 SAML 2.0 标识提供者注册的依赖方
Represents a relying party registered with a SAML 2.0 Identity Provider
<relying-party-registration> Attributes
-
*registration-id*唯一标识 `RelyingPartyRegistration`的 ID。
-
registration-id The ID that uniquely identifies the
RelyingPartyRegistration
.
-
*metadata-location*断言方元数据位置。等同于 `<SPSSODescriptor>`中依赖方 `<AssertionConsumerService Location="…​"/>`中的值。
-
metadata-location The asserting party metadata location.
-
client-id The relying party’s EntityID.
-
assertion-consumer-service-location*AssertionConsumerService 位置。等同于 `<SPSSODescriptor>`中依赖方 `<SPSSODescriptor>`中的 `<AssertionConsumerService Binding="…​"/>`中的值。受支持的值为 *POST*和 *REDIRECT。
-
assertion-consumer-service-location The AssertionConsumerService Location. Equivalent to the value found in
<AssertionConsumerService Location="…"/>
in the relying party’s<SPSSODescriptor>
.
-
assertion-consumer-service-binding*AssertionConsumerService 绑定。等同于 `<SPSSODescriptor>`中依赖方 `<AssertionConsumerService Binding="…​"/>`中的值。受支持的值为 *POST*和 *REDIRECT。
-
assertion-consumer-service-binding the AssertionConsumerService Binding. Equivalent to the value found in
<AssertionConsumerService Binding="…"/>
in the relying party’s<SPSSODescriptor>
. The supported values are POST and REDIRECT.
-
*single-logout-service-location*SingleLogoutService 位置。等同于依赖方 <SPSSODescriptor> 中 <SingleLogoutService Location="…"/> 中的值。
-
single-logout-service-location The SingleLogoutService Location. Equivalent to the value found in <SingleLogoutService Location="…"/> in the relying party’s <SPSSODescriptor>.
-
*single-logout-service-response-location*SingleLogoutService ResponseLocation。等同于依赖方 <SPSSODescriptor> 中 <SingleLogoutService ResponseLocation="…"/> 中的值。
-
single-logout-service-response-location The SingleLogoutService ResponseLocation. Equivalent to the value found in <SingleLogoutService ResponseLocation="…"/> in the relying party’s <SPSSODescriptor>.
-
single-logout-service-binding*SingleLogoutService 绑定。等同于依赖方 <SPSSODescriptor> 中 <SingleLogoutService Binding="…"/> 中的值。受支持的值为 *POST*和 *REDIRECT。
-
single-logout-service-binding The SingleLogoutService Binding. Equivalent to the value found in <SingleLogoutService Binding="…"/> in the relying party’s <SPSSODescriptor>. The supported values are POST and REDIRECT.
-
*asserting-party-id*对相关断言方的引用。必须引用 `<asserting-party>`元素。
-
asserting-party-id A reference to the associated asserting party. Must reference an
<asserting-party>
element.
<decryption-credential>
<signing-credential>
<asserting-party>
SAML 2.0 断言方的配置信息。
The configuration information for a SAML 2.0 Asserting Party.
<asserting-party> Attributes
-
*asserting-party-id*唯一标识断言方的 ID。
-
asserting-party-id The ID that uniquely identifies the asserting party.
-
*entity-id*断言方的 EntityID
-
entity-id The EntityID of the Asserting Party
-
want-authn-requests-signed`WantAuthnRequestsSigned`设置,指示断言方更希望依赖方在发送 `AuthnRequest`之前对其进行签名。
-
want-authn-requests-signed The
WantAuthnRequestsSigned
setting, indicating the asserting party’s preference that relying parties should sign theAuthnRequest
before sending.
-
single-sign-on-service-location The SingleSignOnService Location.
-
single-sign-on-service-binding SingleSignOnService绑定。受支持的值为 POST*和 *REDIRECT。
-
single-sign-on-service-binding The SingleSignOnService Binding. The supported values are POST and REDIRECT.
-
*signing-algorithms*此断言方的 `org.opensaml.saml.ext.saml2alg.SigningMethod`算法列表,按偏好顺序排列。
-
signing-algorithms The list of
org.opensaml.saml.ext.saml2alg.SigningMethod
Algorithms for this asserting party, in preference order.
-
*single-logout-service-location*SingleLogoutService 位置。等同于断言方 <IDPSSODescriptor> 中 <SingleLogoutService Location="…"/> 中的值。
-
single-logout-service-location The SingleLogoutService Location. Equivalent to the value found in <SingleLogoutService Location="…"/> in the asserting party’s <IDPSSODescriptor>.
-
*single-logout-service-response-location*SingleLogoutService ResponseLocation。等同于断言方 <IDPSSODescriptor> 中 <SingleLogoutService ResponseLocation="…"/> 中的值。
-
single-logout-service-response-location The SingleLogoutService ResponseLocation. Equivalent to the value found in <SingleLogoutService ResponseLocation="…"/> in the asserting party’s <IDPSSODescriptor>.
-
single-logout-service-binding*SingleLogoutService 绑定。等同于断言方 <IDPSSODescriptor> 中 <SingleLogoutService Binding="…"/> 中的值。受支持的值为 *POST*和 *REDIRECT。
-
single-logout-service-binding The SingleLogoutService Binding. Equivalent to the value found in <SingleLogoutService Binding="…"/> in the asserting party’s <IDPSSODescriptor>. The supported values are POST and REDIRECT.
<encryption-credential>
<verification-credential>
<http-basic>
在配置中添加 BasicAuthenticationFilter
和 BasicAuthenticationEntryPoint
。仅在未启用基于表单登录的情况下,后者才会用作配置入口点。
Adds a BasicAuthenticationFilter
and BasicAuthenticationEntryPoint
to the configuration.
The latter will only be used as the configuration entry point if form-based login is not enabled.
<http-basic> Attributes
-
*authentication-details-source-ref*对 `AuthenticationDetailsSource`的引用,其中认证过滤器将使用该引用
-
authentication-details-source-ref Reference to an
AuthenticationDetailsSource
which will be used by the authentication filter
-
*entry-point-ref*设置由
BasicAuthenticationFilter`使用的 `AuthenticationEntryPoint
。 -
entry-point-ref Sets the
AuthenticationEntryPoint
which is used by theBasicAuthenticationFilter
.
<http-firewall> Element
这是一个顶级元素,可用于将自定义 HttpFirewall
实现注入到命名空间创建的 FilterChainProxy
中。默认实现应适用于大多数应用程序。
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.
<intercept-url>
此元素用于定义应用程序感兴趣的 URL 模式集,并配置处理这些 URL 的方式。它用于构建 FilterSecurityInterceptor
使用的 FilterInvocationSecurityMetadataSource
。如果需要使用 HTTPS 访问特定 URL,它还负责配置 ChannelProcessingFilter
。在将指定模式与传入请求进行匹配时,匹配按照声明元素的顺序进行。因此,最具体的模式应排在前面,最普通的模式应排在后面。
This element is used to define the set of URL patterns that the application is interested in and to configure how they should be handled.
It is used to construct the FilterInvocationSecurityMetadataSource
used by the FilterSecurityInterceptor
.
It is also responsible for configuring a ChannelProcessingFilter
if particular URLs need to be accessed by HTTPS, for example.
When matching the specified patterns against an incoming request, the matching is done in the order in which the elements are declared.
So the most specific patterns should come first and the most general should come last.
<intercept-url> Attributes
-
*access*列出将存储在 `FilterInvocationSecurityMetadataSource`中的访问属性,以用于定义的 URL 模式/方法组合。这应为安全配置属性(如角色名称)的逗号分隔列表。
-
access Lists the access attributes which will be stored in the
FilterInvocationSecurityMetadataSource
for the defined URL pattern/method combination. This should be a comma-separated list of the security configuration attributes (such as role names).
-
*method*将与模式和 Servlet 路径(可选)结合使用以匹配传入请求的 HTTP 方法。如果省略,则任何方法都将匹配。如果使用和不使用某个方法指定了相同的模式,则特定于方法的匹配将优先。
-
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.
-
*pattern*定义 URL 路径的模式。内容将取决于包含 http 元素的 `request-matcher`属性,因此如果 Spring MVC 在类路径中,则会默认为 MVC 匹配器。
-
pattern The pattern which defines the URL path. The content will depend on the
request-matcher
attribute from the containing http element, so will default to MVC matcher if Spring MVC is in the classpath.
-
*request-matcher-ref*对
RequestMatcher`的引用,将用于确定是否使用此 `<intercept-url>
。 -
request-matcher-ref A reference to a
RequestMatcher
that will be used to determine if this<intercept-url>
is used.
-
*requires-channel*可以是“http”或“https”,具体取决于是否应该分别通过 HTTP 或 HTTPS 访问特定的 URL 模式。或者,当没有首选项时,可以使用值“any”。如果此属性出现在任何
<intercept-url>`元素上,则会向过滤器堆栈中添加 `ChannelProcessingFilter
,并将其其他依赖项添加到应用程序上下文中。 -
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 aChannelProcessingFilter
will be added to the filter stack and its additional dependencies added to the application context.
如果添加了 <port-mappings>
配置,SecureChannelProcessor
和 InsecureChannelProcessor
Bean 将使用该配置来确定用于重定向到 HTTP/HTTPS 的端口。
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.
此属性对于 filter-security-metadata-source 无效。 |
This property is invalid for nsa-filter-security-metadata-source |
-
*servlet-path*与模式和 HTTP 方法结合使用以匹配传入请求的 servlet 路径。此属性仅适用于 request-matcher为“mvc”时。另外,仅在以下 2 种使用情况下需要使用该值:1)在
ServletContext`中注册了 2 个或更多 `HttpServlet
,其映射以“/”开头且不同;2)模式以已注册 `HttpServlet`路径的相同值开头,排除默认(根目录)`HttpServlet
‘/’`。 -
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 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 theServletContext
that have mappings starting with ’/'` and are different; 2) The pattern starts with the same value of a registeredHttpServlet
path, excluding the default (root)HttpServlet
’/'`.
此属性对于 filter-security-metadata-source 无效。 |
This property is invalid for nsa-filter-security-metadata-source |
<jee>
<logout>
在过滤器堆栈中添加 LogoutFilter
。它使用 SecurityContextLogoutHandler
进行配置。
Adds a LogoutFilter
to the filter stack.
This is configured with a SecurityContextLogoutHandler
.
<logout> Attributes
-
*invalidate-session*映射到
SecurityContextLogoutHandler`的 `invalidateHttpSession
。默认为“true”,因此会话将在注销时失效。 -
invalidate-session Maps to the
invalidateHttpSession
of theSecurityContextLogoutHandler
. Defaults to "true", so the session will be invalidated on logout.
-
*logout-success-url*用户注销后带到的目标 URL。默认为 <form-login-login-page>/?logout(即 /login?logout)[.iokays-translated-ede2d18ffce13aaa481ad9591e0d5dfd] 设置此属性将向
SessionManagementFilter
注入SimpleRedirectInvalidSessionStrategy
,该策略使用属性值进行配置。提交无效会话 ID 时,将调用该策略,重定向到配置的 URL。
Setting this attribute will inject the SessionManagementFilter
with a SimpleRedirectInvalidSessionStrategy
configured with the attribute value.
When an invalid session ID is submitted, the strategy will be invoked, redirecting to the configured URL.
-
logout-success-url The destination URL which the user will be taken to after logging out. Defaults to <form-login-login-page>/?logout (i.e. /login?logout)[.iokays-translated-ede2d18ffce13aaa481ad9591e0d5dfd] 设置此属性将向
SessionManagementFilter
注入SimpleRedirectInvalidSessionStrategy
,该策略使用属性值进行配置。提交无效会话 ID 时,将调用该策略,重定向到配置的 URL。
Setting this attribute will inject the SessionManagementFilter
with a SimpleRedirectInvalidSessionStrategy
configured with the attribute value.
When an invalid session ID is submitted, the strategy will be invoked, redirecting to the configured URL.
-
*logout-url*将导致注销的 URL(即过滤器将处理的 URL)。默认为“/logout”。
-
logout-url The URL which will cause a logout (i.e. which will be processed by the filter). Defaults to "/logout".
-
*success-handler-ref*可用于提供 `LogoutSuccessHandler`的实例,在注销后将调用该实例以控制导航。
-
success-handler-ref May be used to supply an instance of
LogoutSuccessHandler
which will be invoked to control the navigation after logging out.
<saml2-login>
SAML 2.0 Login 特性将通过 SAML 2.0 服务提供者配置验证支持。
The SAML 2.0 Login feature configures authentication support using an SAML 2.0 Service Provider.
<saml2-login> Attributes
-
relying-party-registration-repository-ref Reference to the
RelyingPartyRegistrationRepository
.
-
authentication-request-repository-ref Reference to the
Saml2AuthenticationRequestRepository
.
-
authentication-request-context-resolver-ref Reference to the
Saml2AuthenticationRequestResolver
.
-
authentication-converter-ref Reference to the
AuthenticationConverter
.
-
*login-processing-url*过滤器处理认证请求的 URI。
-
login-processing-url The URI where the filter processes authentication requests.
-
*login-page*用于向用户发送登录请求的 URI。
-
login-page The URI to send users to login.
-
authentication-success-handler-ref Reference to the
AuthenticationSuccessHandler
.
-
authentication-failure-handler-ref Reference to the
AuthenticationFailureHandler
.
-
authentication-manager-ref Reference to the
AuthenticationManager
.
<saml2-logout>
SAML 2.0 Single Logout 特性将配置支持 RP 和 AP 发起的 SAML 2.0 单点注销。
The SAML 2.0 Single Logout feature configures support for RP- and AP-initiated SAML 2.0 Single Logout.
<saml2-logout> Attributes
-
*logout-url*依赖方或断言方可以触发注销的 URL。
-
logout-url The URL by which the relying or asserting party can trigger logout.
-
*logout-request-url*断言方可以发送 SAML 2.0 注销请求的 URL。
-
logout-request-url The URL by which the asserting party can send a SAML 2.0 Logout Request.
-
*logout-response-url*断言方可以发送 SAML 2.0 注销响应的 URL。
-
logout-response-url The URL by which the asserting party can send a SAML 2.0 Logout Response.
-
relying-party-registration-repository-ref Reference to the
RelyingPartyRegistrationRepository
.
-
logout-request-validator-ref Reference to the
Saml2LogoutRequestValidator
.
-
logout-request-resolver-ref Reference to the
Saml2LogoutRequestResolver
.
-
logout-request-repository-ref Reference to the
Saml2LogoutRequestRepository
.
-
logout-response-validator-ref Reference to the
Saml2LogoutResponseValidator
.
-
logout-response-resolver-ref Reference to the
Saml2LogoutResponseResolver
.
<password-management>
<port-mappings>
默认情况下,PortMapperImpl
的实例将添加到配置中,以用于重定向到安全和不安全的 URL。这个元素可选择用于替代该类定义的默认映射。每个子 <port-mapping>
元素定义一对 HTTP:HTTPS 端口。默认映射为 80:443 和 8080:8443。可在 Redirect to HTTPS 中找到一个替代它们的示例。
By default, an instance of PortMapperImpl
will be added to the configuration for use in redirecting to secure and insecure URLs.
This element can optionally be used to override the default mappings which that class defines.
Each child <port-mapping>
element defines a pair of HTTP:HTTPS ports.
The default mappings are 80:443 and 8080:8443.
An example of overriding these can be found in Redirect to HTTPS.
<port-mapping>
<remember-me>
将 RememberMeAuthenticationFilter
添加到堆栈。这反过来将使用 TokenBasedRememberMeServices
、PersistentTokenBasedRememberMeServices
或实现 RememberMeServices
的用户指定 bean 根据属性设置进行配置。
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.
<remember-me> Attributes
-
*authentication-success-handler-ref*如果需要自定义导航,请设置 `RememberMeAuthenticationFilter`上的 `authenticationSuccessHandler`属性。该值应为应用程序上下文中的 `AuthenticationSuccessHandler`bean 的名称。
-
authentication-success-handler-ref Sets the
authenticationSuccessHandler
property on theRememberMeAuthenticationFilter
if custom navigation is required. The value should be the name of aAuthenticationSuccessHandler
bean in the application context.
-
*data-source-ref*对 `DataSource`bean 的引用。如果设置此项,将使用 `PersistentTokenBasedRememberMeServices`并将其配置为 `JdbcTokenRepositoryImpl`实例。
-
data-source-ref A reference to a
DataSource
bean. If this is set,PersistentTokenBasedRememberMeServices
will be used and configured with aJdbcTokenRepositoryImpl
instance.
-
*remember-me-parameter*切换记住我身份验证的请求参数名称。默认为“remember-me”。映射到 `AbstractRememberMeServices`的“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
.
-
*key*映射到 `AbstractRememberMeServices`的“key”属性。应设置一个唯一的值来确保记住我 cookie 仅在一个应用程序中有效。这不会影响令牌存储在服务器端时的 `PersistentTokenBasedRememberMeServices`的使用。如果未设置此项,将生成一个安全的随机值。由于生成安全的随机值需要一定的时间,因此在使用记住我功能时,显式设置此值有助于提高启动时间。
-
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 This doesn’t affect the use ofPersistentTokenBasedRememberMeServices
, 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.
-
*services-alias*将内部定义的 `RememberMeServices`导出为 bean 别名,允许应用程序上下文中的其他 bean 使用它。
-
services-alias Exports the internally defined
RememberMeServices
as a bean alias, allowing it to be used by other beans in the application context.
-
*services-ref*允许完全控制过滤器将使用的
RememberMeServices`实现方式。该值应为实现此界面的应用程序上下文中的 bean 的 `id
。如果注销过滤器正在使用中,还应实现LogoutHandler
。 -
services-ref Allows complete control of the
RememberMeServices
implementation that will be used by the filter. The value should be theid
of a bean in the application context which implements this interface. Should also implementLogoutHandler
if a logout filter is in use.
-
*token-repository-ref*配置
PersistentTokenBasedRememberMeServices
,但允许使用自定义 `PersistentTokenRepository`bean。 -
token-repository-ref Configures a
PersistentTokenBasedRememberMeServices
but allows the use of a customPersistentTokenRepository
bean.
-
*token-validity-seconds*映射到 `AbstractRememberMeServices`的 `tokenValiditySeconds`属性。指定记住我 cookie 应有效的时段(以秒为单位)。默认情况下,它将保留 14 天。
-
token-validity-seconds Maps to the
tokenValiditySeconds
property ofAbstractRememberMeServices
. Specifies the period in seconds for which the remember-me cookie should be valid. By default it will be valid for 14 days.
-
*user-service-ref*记住我服务实现需要访问
UserDetailsService
,因此必须在应用程序上下文中定义一个。如果只有一个,则命名空间配置会自动选择并使用它。如果有多个实例,可以使用此属性显式指定一个 beanid
。 -
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 beanid
explicitly using this attribute.
<request-cache> Element
<session-management>
会话管理相关功能是通过将 SessionManagementFilter
添加到筛选器堆栈来实现的。
Session-management related functionality is implemented by the addition of a SessionManagementFilter
to the filter stack.
<session-management> Attributes
-
*authentication-strategy-explicit-invocation*将此属性设置为 true 意味着不会注入
SessionManagementFilter
,并且需要显式调用 SessionAuthenticationStrategy。 -
authentication-strategy-explicit-invocation Setting this attribute to true will mean that
SessionManagementFilter
will not be injected and explicit invocation of SessionAuthenticationStrategy is required.
-
*invalid-session-url*设置此属性会使用配置有属性值的
SimpleRedirectInvalidSessionStrategy
向SessionManagementFilter
中注入。当提交无效的会话 ID 时,将调用此策略,并将其重定向到已配置的 URL。 -
invalid-session-url Setting this attribute will inject the
SessionManagementFilter
with aSimpleRedirectInvalidSessionStrategy
configured with the attribute value. When an invalid session ID is submitted, the strategy will be invoked, redirecting to the configured URL.
-
*invalid-session-url*允许注入 SessionManagementFilter 使用的 InvalidSessionStrategy 实例。使用此属性或
invalid-session-url
属性,但不能同时使用这两个属性。 -
invalid-session-url Allows injection of the InvalidSessionStrategy instance used by the SessionManagementFilter. Use either this or the
invalid-session-url
attribute but not both.
-
*session-authentication-error-url*定义当 SessionAuthenticationStrategy 引发异常时应显示的错误页面的 URL。如果未设置,则将向客户端返回未授权(401)错误代码。请注意,如果错误发生在基于表单的登录期间,则此属性不适用,此时用于身份验证失败的 URL 将具有优先权。
-
session-authentication-error-url Defines the URL of the error page which should be shown when the SessionAuthenticationStrategy raises an exception. If not set, an unauthorized (401) error code will be returned to the client. Note that this attribute doesn’t apply if the error occurs during a form-based login, where the URL for authentication failure will take precedence.
-
*session-authentication-strategy-ref*允许注入 SessionManagementFilter 使用的 SessionAuthenticationStrategy 实例
-
session-authentication-strategy-ref Allows injection of the SessionAuthenticationStrategy instance used by the SessionManagementFilter
-
*session-fixation-protection*表示当用户进行身份验证时,如何应用会话固化保护。如果设置为“none”,则不应用任何保护。“newSession”将创建一个新的空会话,并且只迁移与 Spring Security 相关的所有属性。“migrateSession”将创建一个新会话,并将所有会话属性复制到新会话中。在 Servlet 3.1(Java EE 7)和更新的容器中,指定“changeSessionId”将保留现有会话并使用容器提供的会话锁定保护(HttpServletRequest#changeSessionId())。在 Servlet 3.1 及更高版本容器中默认为“changeSessionId”,在旧容器中默认为“migrateSession”。如果在旧容器中使用“changeSessionId”,则会引发异常。[.iokays-translated-01129bda18316b13fa353cc52370e218] 如果启用会话固定保护,则将配置
SessionManagementFilter
注入适当配置的DefaultSessionAuthenticationStrategy
。有关更多详细信息,请参阅此类的 Javadoc。
If session fixation protection is enabled, the SessionManagementFilter
is injected with an appropriately configured DefaultSessionAuthenticationStrategy
.
See the Javadoc for this class for more details.
-
session-fixation-protection Indicates how session fixation protection will be applied when a user authenticates. If set to "none", no protection will be applied. "newSession" will create a new empty session, with only Spring Security-related attributes migrated. "migrateSession" will create a new session and copy all session attributes to the new session. In Servlet 3.1 (Java EE 7) and newer containers, specifying "changeSessionId" will keep the existing session and use the container-supplied session fixation protection (HttpServletRequest#changeSessionId()). Defaults to "changeSessionId" in Servlet 3.1 and newer containers, "migrateSession" in older containers. Throws an exception if "changeSessionId" is used in older containers.[.iokays-translated-01129bda18316b13fa353cc52370e218] 如果启用会话固定保护,则将配置
SessionManagementFilter
注入适当配置的DefaultSessionAuthenticationStrategy
。有关更多详细信息,请参阅此类的 Javadoc。
If session fixation protection is enabled, the SessionManagementFilter
is injected with an appropriately configured DefaultSessionAuthenticationStrategy
.
See the Javadoc for this class for more details.
<concurrency-control>
添加对并发会话控制的支持,允许对用户可以拥有的活动会话数进行限制。将创建一个 ConcurrentSessionFilter
,并且 ConcurrentSessionControlAuthenticationStrategy
将与 SessionManagementFilter
一起使用。如果已声明 form-login
元素,则策略对象还将注入到创建的身份验证筛选器中。将创建一个 SessionRegistry
实例(一个 SessionRegistryImpl
实例,除非用户希望使用自定义 bean)以供策略使用。
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.
<concurrency-control> Attributes
-
*error-if-maximum-exceeded*如果设为“true”,那么当用户尝试超过允许的最大会话数量时,将引发
SessionAuthenticationException
。默认行为是使原始会话过期。 -
error-if-maximum-exceeded If set to "true" a
SessionAuthenticationException
will be raised when a user attempts to exceed the maximum allowed number of sessions. The default behaviour is to expire the original session.
-
*expired-url*如果用户尝试使用已被并发会话控制器“过期”的会话(因为用户已超过允许的会话数量,并且已在其他地方重新登录),则用户将被重定向到的 URL。如果不设置此项,则应
exception-if-maximum-exceeded
设置。如果不提供任何值,则会将过期消息直接写回响应中。 -
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.
-
*expired-url*允许注入 ConcurrentSessionFilter 使用的 ExpiredSessionStrategy 实例
-
expired-url Allows injection of the ExpiredSessionStrategy instance used by the ConcurrentSessionFilter
-
*max-sessions*映射到
ConcurrentSessionControlAuthenticationStrategy
的maximumSessions
属性。指定-1
为值以支持无限会话。 -
max-sessions Maps to the
maximumSessions
property ofConcurrentSessionControlAuthenticationStrategy
. Specify-1
as the value to support unlimited sessions.
-
*session-registry-alias*在您自己的 Bean 或管理界面中引用内部会话注册表也会很有用。您可以使用
session-registry-alias
属性公开内部 Bean,并为其提供一个名称,以便在配置中的其他位置使用该名称。 -
session-registry-alias It can also be useful to have a reference to the internal session registry for use in your own beans or an admin interface. You can expose the internal bean using the
session-registry-alias
attribute, giving it a name that you can use elsewhere in your configuration.
-
*session-registry-ref*用户可以使用
session-registry-ref
属性提供他们自己的SessionRegistry
实现。其他并发会话控件 Bean 将被连接起来以使用它。 -
session-registry-ref The user can supply their own
SessionRegistry
implementation using thesession-registry-ref
attribute. The other concurrent session control beans will be wired up to use it.
<x509>
添加对 X.509 身份验证的支持。X509AuthenticationFilter
将被添加到堆栈,并且将创建 Http403ForbiddenEntryPoint
bean。只有在不使用任何其他身份验证机制时才使用后者(其唯一功能是返回 HTTP 403 错误代码)。还将创建一个 PreAuthenticatedAuthenticationProvider
,它将用户权限的加载委托给 UserDetailsService
。
Adds support for X.509 authentication.
An X509AuthenticationFilter
will be added to the stack and an Http403ForbiddenEntryPoint
bean will be created.
The latter will only be used if no other authentication mechanisms are in use (its only functionality is to return an HTTP 403 error code).
A PreAuthenticatedAuthenticationProvider
will also be created which delegates the loading of user authorities to a UserDetailsService
.
<x509> Attributes
-
*authentication-details-source-ref*对
AuthenticationDetailsSource
的引用 -
authentication-details-source-ref A reference to an
AuthenticationDetailsSource
-
*subject-principal-regex*定义一个正则表达式,该表达式将用于从证书中提取用户名(与
UserDetailsService
一起使用)。 -
subject-principal-regex Defines a regular expression which will be used to extract the username from the certificate (for use with the
UserDetailsService
).
-
*user-service-ref*允许在配置了多个实例的情况下,对 X.509 使用特定的
UserDetailsService
。如果未设置,它将尝试自动查找合适的实例并使用该实例。 -
user-service-ref Allows a specific
UserDetailsService
to be used with X.509 in the case where multiple instances are configured. If not set, an attempt will be made to locate a suitable instance automatically and use that.
<filter-chain-map>
用于使用 FilterChainMap 显式配置 FilterChainProxy 实例
Used to explicitly configure a FilterChainProxy instance with a FilterChainMap
<filter-chain-map> Attributes
-
*request-matcher*定义用于匹配传入请求的策略。当前选项有“ant”(用于 ant 路径模式)、“regex”(用于正则表达式)和“ciRegex”(用于不区分大小写的正则表达式)。
-
request-matcher Defines the strategy to use for matching incoming requests. Currently the options are 'ant' (for ant path patterns), 'regex' for regular expressions and 'ciRegex' for case-insensitive regular expressions.
<filter-chain>
在其中用于定义特定的 URL 模式和适用于匹配该模式的 URL 的筛选器列表。当多个过滤器链元素以列表方式组装在一起以配置 FilterChainProxy 时,最具体的模式必须放在列表顶部,最通用的模式必须放在底部。
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.
<filter-chain> Attributes
-
*filters*对实现
Filter
的 Spring Bean 的引用的逗号分隔列表。值“none”表示不应为该FilterChain
使用任何Filter
。 -
filters A comma separated list of references to Spring beans that implement
Filter
. The value "none" means that noFilter
should be used for thisFilterChain
.
-
*pattern*创建一个 RequestMatcher 的模式,并与 request-matcher 结合使用
-
pattern A pattern that creates RequestMatcher in combination with the nsa-filter-chain-map-request-matcher
-
*request-matcher-ref*对
RequestMatcher
的引用,它将用于确定是否应调用filters
属性中的任何Filter
。 -
request-matcher-ref A reference to a
RequestMatcher
that will be used to determine if anyFilter
from thefilters
attribute should be invoked.
<filter-security-metadata-source>
用于显式配置 FilterSecurityMetadataSource bean 以与 FilterSecurityInterceptor 一起使用。通常仅在你显式配置 FilterChainProxy(而不是使用<http>元素)时才需要。使用的 intercept-url 元素应仅包含模式、方法和访问属性。任何其他属性都会导致配置错误。
Used to explicitly configure a FilterSecurityMetadataSource bean for use with a FilterSecurityInterceptor. Usually only needed if you are configuring a FilterChainProxy explicitly, rather than using the<http> element. The intercept-url elements used should only contain pattern, method and access attributes. Any others will result in a configuration error.
<filter-security-metadata-source> Attributes
-
*id*Bean 标识符,用于在上下文的其他位置引用 Bean。
-
id A bean identifier, used for referring to the bean elsewhere in the context.
-
*request-matcher*为匹配传入请求定义要使用的策略。当前选项有“ant”(用于 ant 路径模式)、“regex”(用于正则表达式)和“ciRegex”(用于不区分大小写的正则表达式)。
-
request-matcher Defines the strategy use for matching incoming requests. Currently the options are 'ant' (for ant path patterns), 'regex' for regular expressions and 'ciRegex' for case-insensitive regular expressions.
-
*use-expressions*启用在 <intercept-url> 元素的“access”属性中使用表达式,而不是使用传统的配置属性列表。默认为“true”。如果启用,则每个属性应包含一个布尔表达式。如果表达式计算结果为“true”,则将授予访问权限。
-
use-expressions Enables the use of expressions in the 'access' attributes in <intercept-url> elements rather than the traditional list of configuration attributes. Defaults to 'true'. If enabled, each attribute should contain a single Boolean expression. If the expression evaluates to 'true', access will be granted.