Skip to content

Commit 39f4fcd

Browse files
committed
Add AuthenticationEntryPointFailureHandler Preparation Steps
Issue gh-9429
1 parent ac7f726 commit 39f4fcd

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed

docs/modules/ROOT/pages/migration.adoc

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1623,6 +1623,86 @@ Second, if you still need your custom `access-decision-manager-ref` or have some
16231623
----
16241624
====
16251625

1626+
=== Propagate ``AuthenticationServiceException``s
1627+
1628+
{security-api-url}org/springframework/security/web/authentication/AuthenticationFilter.html[`AuthenticationFilter`] propagates {security-api-url}org/springframework/security/authentication/AuthenticationServiceException.html[``AuthenticationServiceException``]s to the {security-api-url}org/springframework/security/authentication/AuthenticationEntryPoint.html[`AuthenticationEntryPoint`].
1629+
Because ``AuthenticationServiceException``s represent a server-side error instead of a client-side error, in 6.0, this changes to propagate them to the container.
1630+
1631+
==== Configure `AuthenticationFailureHandler` to rethrow ``AuthenticationServiceException``s
1632+
1633+
To prepare for the 6.0 default, wire `AuthenticationFilter` instances with a `AuthenticationFailureHandler` that rethrows ``AuthenticationServiceException``s, like so:
1634+
1635+
====
1636+
.Java
1637+
[source,java,role="primary"]
1638+
----
1639+
AuthenticationFilter authenticationFilter = new AuthenticationFilter(...);
1640+
AuthenticationEntryPointFailureHandler handler = new AuthenticationEntryPointFailureHandler(...);
1641+
handler.setRethrowAuthenticationServiceException(true);
1642+
authenticationFilter.setAuthenticationFailureHandler(handler);
1643+
----
1644+
1645+
.Kotlin
1646+
[source,kotlin,role="secondary"]
1647+
----
1648+
val authenticationFilter: AuthenticationFilter = new AuthenticationFilter(...)
1649+
val handler: AuthenticationEntryPointFailureHandler = new AuthenticationEntryPointFailureHandler(...)
1650+
handler.setRethrowAuthenticationServiceException(true)
1651+
authenticationFilter.setAuthenticationFailureHandler(handler)
1652+
----
1653+
1654+
.Xml
1655+
[source,xml,role="secondary"]
1656+
----
1657+
<bean id="authenticationFilter" class="org.springframework.security.web.authentication.AuthenticationFilter">
1658+
<!-- ... -->
1659+
<property ref="authenticationFailureHandler"/>
1660+
</bean>
1661+
1662+
<bean id="authenticationFailureHandler" class="org.springframework.security.web.authentication.AuthenticationEntryPointFailureHandler">
1663+
<property name="rethrowAuthenticationServiceException" value="true"/>
1664+
</bean>
1665+
----
1666+
====
1667+
1668+
[[servlet-authenticationfailurehandler-opt-out]]
1669+
==== Opt-out Steps
1670+
1671+
If rethrowing ``AuthenticationServiceException``s gives you trouble, you can set the value to false instead of taking the 6.0 default, like so:
1672+
1673+
====
1674+
.Java
1675+
[source,java,role="primary"]
1676+
----
1677+
AuthenticationFilter authenticationFilter = new AuthenticationFilter(...);
1678+
AuthenticationEntryPointFailureHandler handler = new AuthenticationEntryPointFailureHandler(...);
1679+
handler.setRethrowAuthenticationServiceException(false);
1680+
authenticationFilter.setAuthenticationFailureHandler(handler);
1681+
----
1682+
1683+
.Kotlin
1684+
[source,kotlin,role="secondary"]
1685+
----
1686+
val authenticationFilter: AuthenticationFilter = new AuthenticationFilter(...)
1687+
val handler: AuthenticationEntryPointFailureHandler = new AuthenticationEntryPointFailureHandler(...)
1688+
handler.setRethrowAuthenticationServiceException(false)
1689+
authenticationFilter.setAuthenticationFailureHandler(handler)
1690+
----
1691+
1692+
.Xml
1693+
[source,xml,role="secondary"]
1694+
----
1695+
<bean id="authenticationFilter" class="org.springframework.security.web.authentication.AuthenticationFilter">
1696+
<!-- ... -->
1697+
<property ref="authenticationFailureHandler"/>
1698+
</bean>
1699+
1700+
<bean id="authenticationFailureHandler" class="org.springframework.security.web.authentication.AuthenticationEntryPointFailureHandler">
1701+
<property name="rethrowAuthenticationServiceException" value="false"/>
1702+
</bean>
1703+
----
1704+
====
1705+
16261706
== Reactive
16271707

16281708
=== Use `AuthorizationManager` for Method Security

0 commit comments

Comments
 (0)