Authorization 迁移

本站(springdoc.cn)中的内容来源于 spring.io ,原始版权归属于 spring.io。由 springboot.io - Spring Boot中文社区 进行翻译,整理。可供个人学习、研究,未经许可,不得进行任何转载、商用或与之相关的行为。 商标声明:Spring 是 Pivotal Software, Inc. 在美国以及其他国家的商标。

下面的步骤涉及到如何完成授权支持的迁移。

使用 AuthorizationManager 实现方法安全

该功能没有进一步的迁移步骤。

使用 AuthorizationManager 来实现消息安全(Message Security)

在 6.0 中,<websocket-message-broker> 默认将 use-authorization-manager 设为 true。因此,要完成迁移,请删除任何 websocket-message-broker@use-authorization-manager=true 属性。

例如:

Xml
<websocket-message-broker use-authorization-manager="true"/>

changes to:

Xml
<websocket-message-broker/>

对于这个功能,Java或Kotlin没有进一步的迁移步骤。

使用 AuthorizationManager 保证请求安全(Request Security)

在6.0中,<http> 的默认值是 once-per-Requestfalsefilter-all-dispatcher-typestrueuse-authorization-managertrue。另外,authorizeRequests#filterSecurityInterceptorOncePerRequest 默认为 falseauthorizeHttpRequests#filterAllDispatcherTypes 默认为 true。因此,为了完成迁移,可以删除任何默认值。

例如,如果你选择了6.0默认的 filter-all-dispatcher-typesauthorizeHttpRequests#filterAllDispatcherTypes,像这样。

Java
http
    .authorizeHttpRequests((authorize) -> authorize
        .filterAllDispatcherTypes(true)
        // ...
    )
Kotlin
http {
	authorizeHttpRequests {
		filterAllDispatcherTypes = true
        // ...
	}
}
Xml
<http use-authorization-manager="true" filter-all-dispatcher-types="true"/>

则可以删除默认值。

Java
http
    .authorizeHttpRequests((authorize) -> authorize
        // ...
    )
Kotlin
http {
	authorizeHttpRequests {
		// ...
	}
}
Xml
<http/>

once-per-request 仅在 use-authorization-manager="false" 时适用, filter-all-dispatcher-types 仅在 use-authorization-manager="true" 时适用。