You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{security-api-url}org/springframework/security/web/server/Webauthentication/AuthenticationWebFilter.html[`AuthenticationFilter`] propagates {security-api-url}org/springframework/security/authentication/AuthenticationServiceException.html[``AuthenticationServiceException``]s to the {security-api-url}org/springframework/security/web/server/ServerAuthenticationEntryPoint.html[`ServerAuthenticationEntryPoint`].
1957
+
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.
1958
+
1959
+
==== Configure `ServerAuthenticationFailureHandler` to rethrow ``AuthenticationServiceException``s
1960
+
1961
+
To prepare for the 6.0 default, `httpBasic` and `oauth2ResourceServer` should be configured to rethrow ``AuthenticationServiceException``s.
1962
+
1963
+
For each, construct the appropriate authentication entry point for `httpBasic` and for `oauth2ResourceServer`:
1964
+
1965
+
====
1966
+
.Java
1967
+
[source,java,role="primary"]
1968
+
----
1969
+
ServerAuthenticationEntryPoint bearerEntryPoint = new BearerTokenServerAuthenticationEntryPoint();
1970
+
ServerAuthenticationEntryPoint basicEntryPoint = new HttpStatusServerEntryPoint(HttpStatus.UNAUTHORIZED);
1971
+
----
1972
+
1973
+
.Kotlin
1974
+
[source,kotlin,role="secondary"]
1975
+
----
1976
+
val bearerEntryPoint: ServerAuthenticationEntryPoint = BearerTokenServerAuthenticationEntryPoint()
1977
+
val basicEntryPoint: ServerAuthenticationEntryPoint = HttpStatusServerEntryPoint(HttpStatus.UNAUTHORIZED)
1978
+
----
1979
+
====
1980
+
1981
+
[NOTE]
1982
+
====
1983
+
If you use a custom `AuthenticationEntryPoint` for either or both mechanisms, use that one instead for the remaining steps.
1984
+
====
1985
+
1986
+
Then, construct and configure a `ServerAuthenticationEntryPointFailureHandler` for each one:
1987
+
1988
+
====
1989
+
.Java
1990
+
[source,java,role="primary"]
1991
+
----
1992
+
AuthenticationFailureHandler bearerFailureHandler = new ServerAuthenticationEntryPointFailureHandler(bearerEntryPoint);
To opt-out of the 6.0 defaults and instead continue to pass `AuthenticationServiceException` on to ``ServerAuthenticationEntryPoint``s, you can follow the same steps as above, except set `rethrowAuthenticationServiceException` to false.
0 commit comments