Spring Security 7.0 新特性
Spring Security 7.0 提供了多項新功能。以下是本次釋出的亮點,您也可以檢視釋出說明以獲取每個功能和錯誤修復的詳細列表。
模組
-
Spring Security Kerberos 擴充套件現在是 Spring Security 的一部分。詳情請參閱參考資料的 Kerberos 部分。
-
Spring Authorization Server 現在是 Spring Security 的一部分。詳情請參閱參考資料的 OAuth 2.0 授權伺服器 部分。
核心
-
增加了對多因素認證的支援。
-
移除了
AuthorizationManager#check,取而代之的是AuthorizationManager#authorize。 -
增加了
AllAuthoritiesAuthorizationManager和AllAuthoritiesReactiveAuthorizationManager,以及用於授權HttpServletRequests和方法安全表示式的相應方法。 -
增加了
AuthorizationManagerFactory,用於在基於請求和基於方法的授權元件中建立AuthorizationManager例項。 -
增加了
Authentication.Builder,用於修改和合並Authentication例項。 -
將訪問 API (
AccessDecisionManager,AccessDecisionVoter等) 移至一個新模組spring-security-access。
配置
-
從
HttpSecurityDSL 中移除了and(),轉而使用 lambda 方法。 -
移除了
authorizeRequests,取而代之的是authorizeHttpRequests。 -
簡化了
authorizeRequests的表示式遷移。 -
增加了對基於 SPA 的 CSRF 配置的支援。
-
增加了對將缺失許可權繫結到認證機制的支援。
- Java
-
http.csrf((csrf) -> csrf.spa());
加密
-
增加了基於 Password4j 的密碼編碼器,為流行的雜湊演算法提供了替代實現。
-
Argon2Password4jPasswordEncoder- Argon2 -
BcryptPassword4jPasswordEncoder- BCrypt -
ScryptPassword4jPasswordEncoder- SCrypt -
Pbkdf2Password4jPasswordEncoder- PBKDF2 -
BalloonHashingPassword4jPasswordEncoder- Balloon Hashing
-
OAuth 2.0
-
移除了對密碼授權的支援。
-
增加了對 HTTP 服務客戶端的 OAuth2 支援。
-
增加了對
NimbusJwtDecoder中自定義JwkSource的支援,允許使用 Nimbus 的JwkSourceBuilderAPI。 -
增加了
NimbusJwtEncoder的構建器,支援指定 EC 或 RSA 金鑰對或秘密金鑰。 -
增加了在型別級別支援
@ClientRegistrationId,消除了方法級別的重複需求。 -
增加了對OAuth 2.0 動態註冊協議的支援。
-
在 OAuth 2.0 授權伺服器中預設啟用 PKCE。
SAML 2.0
-
移除了基於
AssertingPartyDetails類的 API 方法,轉而支援AssertingPartyMetadata介面。 -
從
Saml2AuthenticationTokenConverter中移除了 GET 請求支援。 -
增加了基於 JDBC 的
AssertingPartyMetadataRepository。 -
修改了 SLO,使其在驗證失敗時仍返回
<saml2:LogoutResponse>。 -
移除了 Open SAML 4 支援;應用程式應遷移到 Open SAML 5。