Skip to content

Commit 414e9e7

Browse files
author
Steve Riesenberg
committed
Update exception handling config in samples
Closes gh-1204
1 parent 33f81cd commit 414e9e7

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

samples/demo-authorizationserver/src/main/java/sample/config/AuthorizationServerConfig.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.springframework.context.annotation.Configuration;
3131
import org.springframework.core.Ordered;
3232
import org.springframework.core.annotation.Order;
33+
import org.springframework.http.MediaType;
3334
import org.springframework.jdbc.core.JdbcTemplate;
3435
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase;
3536
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
@@ -55,6 +56,7 @@
5556
import org.springframework.security.oauth2.server.authorization.token.OAuth2TokenCustomizer;
5657
import org.springframework.security.web.SecurityFilterChain;
5758
import org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint;
59+
import org.springframework.security.web.util.matcher.MediaTypeRequestMatcher;
5860

5961
/**
6062
* @author Joe Grandja
@@ -116,8 +118,11 @@ public SecurityFilterChain authorizationServerSecurityFilterChain(
116118

117119
// @formatter:off
118120
http
119-
.exceptionHandling(exceptions ->
120-
exceptions.authenticationEntryPoint(new LoginUrlAuthenticationEntryPoint("/login"))
121+
.exceptionHandling((exceptions) -> exceptions
122+
.defaultAuthenticationEntryPointFor(
123+
new LoginUrlAuthenticationEntryPoint("/login"),
124+
new MediaTypeRequestMatcher(MediaType.TEXT_HTML)
125+
)
121126
)
122127
.oauth2ResourceServer(oauth2ResourceServer ->
123128
oauth2ResourceServer.jwt(Customizer.withDefaults()));

0 commit comments

Comments
 (0)