File tree Expand file tree Collapse file tree 3 files changed +18
-4
lines changed
docs/src/docs/asciidoc/examples/src/main/java/sample Expand file tree Collapse file tree 3 files changed +18
-4
lines changed Original file line number Diff line number Diff line change 30
30
import org .springframework .context .annotation .Bean ;
31
31
import org .springframework .context .annotation .Configuration ;
32
32
import org .springframework .core .annotation .Order ;
33
+ import org .springframework .http .MediaType ;
33
34
import org .springframework .security .config .Customizer ;
34
35
import org .springframework .security .config .annotation .web .builders .HttpSecurity ;
35
36
import org .springframework .security .config .annotation .web .configuration .EnableWebSecurity ;
50
51
import org .springframework .security .provisioning .InMemoryUserDetailsManager ;
51
52
import org .springframework .security .web .SecurityFilterChain ;
52
53
import org .springframework .security .web .authentication .LoginUrlAuthenticationEntryPoint ;
54
+ import org .springframework .security .web .util .matcher .MediaTypeRequestMatcher ;
53
55
54
56
@ Configuration
55
57
@ EnableWebSecurity
@@ -67,8 +69,10 @@ public SecurityFilterChain authorizationServerSecurityFilterChain(HttpSecurity h
67
69
// Redirect to the login page when not authenticated from the
68
70
// authorization endpoint
69
71
.exceptionHandling ((exceptions ) -> exceptions
70
- .authenticationEntryPoint (
71
- new LoginUrlAuthenticationEntryPoint ("/login" ))
72
+ .defaultAuthenticationEntryPointFor (
73
+ new LoginUrlAuthenticationEntryPoint ("/login" ),
74
+ new MediaTypeRequestMatcher (MediaType .TEXT_HTML )
75
+ )
72
76
)
73
77
// Accept access tokens for User Info and/or Client Registration
74
78
.oauth2ResourceServer ((oauth2 ) -> oauth2 .jwt (Customizer .withDefaults ()));
Original file line number Diff line number Diff line change 30
30
import org .springframework .context .annotation .Bean ;
31
31
import org .springframework .context .annotation .Configuration ;
32
32
import org .springframework .core .annotation .Order ;
33
+ import org .springframework .http .MediaType ;
33
34
import org .springframework .security .config .Customizer ;
34
35
import org .springframework .security .config .annotation .web .builders .HttpSecurity ;
35
36
import org .springframework .security .config .annotation .web .configurers .oauth2 .server .resource .OAuth2ResourceServerConfigurer ;
50
51
import org .springframework .security .provisioning .InMemoryUserDetailsManager ;
51
52
import org .springframework .security .web .SecurityFilterChain ;
52
53
import org .springframework .security .web .authentication .LoginUrlAuthenticationEntryPoint ;
54
+ import org .springframework .security .web .util .matcher .MediaTypeRequestMatcher ;
53
55
54
56
@ Configuration (proxyBeanMethods = false )
55
57
public class EnableUserInfoSecurityConfig {
@@ -64,7 +66,10 @@ public SecurityFilterChain authorizationServerSecurityFilterChain(HttpSecurity h
64
66
http
65
67
.oauth2ResourceServer (OAuth2ResourceServerConfigurer ::jwt ) // <2>
66
68
.exceptionHandling ((exceptions ) -> exceptions
67
- .authenticationEntryPoint (new LoginUrlAuthenticationEntryPoint ("/login" ))
69
+ .defaultAuthenticationEntryPointFor (
70
+ new LoginUrlAuthenticationEntryPoint ("/login" ),
71
+ new MediaTypeRequestMatcher (MediaType .TEXT_HTML )
72
+ )
68
73
);
69
74
// @formatter:on
70
75
Original file line number Diff line number Diff line change 31
31
import org .springframework .context .annotation .Bean ;
32
32
import org .springframework .context .annotation .Configuration ;
33
33
import org .springframework .core .annotation .Order ;
34
+ import org .springframework .http .MediaType ;
34
35
import org .springframework .security .config .Customizer ;
35
36
import org .springframework .security .config .annotation .web .builders .HttpSecurity ;
36
37
import org .springframework .security .config .annotation .web .configurers .oauth2 .server .resource .OAuth2ResourceServerConfigurer ;
55
56
import org .springframework .security .provisioning .InMemoryUserDetailsManager ;
56
57
import org .springframework .security .web .SecurityFilterChain ;
57
58
import org .springframework .security .web .authentication .LoginUrlAuthenticationEntryPoint ;
59
+ import org .springframework .security .web .util .matcher .MediaTypeRequestMatcher ;
58
60
import org .springframework .security .web .util .matcher .RequestMatcher ;
59
61
60
62
@ Configuration (proxyBeanMethods = false )
@@ -90,7 +92,10 @@ public SecurityFilterChain authorizationServerSecurityFilterChain(HttpSecurity h
90
92
.csrf (csrf -> csrf .ignoringRequestMatchers (endpointsMatcher ))
91
93
.oauth2ResourceServer (OAuth2ResourceServerConfigurer ::jwt ) // <4>
92
94
.exceptionHandling ((exceptions ) -> exceptions
93
- .authenticationEntryPoint (new LoginUrlAuthenticationEntryPoint ("/login" ))
95
+ .defaultAuthenticationEntryPointFor (
96
+ new LoginUrlAuthenticationEntryPoint ("/login" ),
97
+ new MediaTypeRequestMatcher (MediaType .TEXT_HTML )
98
+ )
94
99
)
95
100
.apply (authorizationServerConfigurer ); // <5>
96
101
// @formatter:on
You can’t perform that action at this time.
0 commit comments