@@ -42,56 +42,10 @@ public class SecurityConfig {
4242 @ Bean
4343 public SecurityFilterChain securityFilterChain (HttpSecurity http ) throws Exception {
4444
45- /* http
46- .authorizeRequests(authorize -> authorize
47- .requestMatchers("/sso/v1/**", "/api/v1/**").authenticated() // Pages that need authentication
48- .requestMatchers("/node/**", "/js/**", "/css/**", "/images/**", "/error", "/sso/login", "/api/v1/login/authenticate").permitAll() // Public endpoints
49- .anyRequest().authenticated() // Other pages need authentication
50- )
51- .logout(logout -> logout
52- .logoutSuccessUrl("/sso/login?logout") // Redirect after logout
53- )
54- .sessionManagement(session -> session
55- .sessionCreationPolicy(SessionCreationPolicy.STATELESS)
56- )
57- .oauth2Login(oauth2 -> oauth2 // Enable OAuth2 login
58- .loginPage("/oauth2/authorization/keycloak") // Redirect to Keycloak
59- )
60- .oauth2ResourceServer(oauth2 -> oauth2
61- .jwt(jwt -> jwt.jwtAuthenticationConverter(jwtAuthenticationConverterForKeycloak()))
62- )
63- .csrf(csrf -> csrf
64- .csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse())
65- )
66-
67- .cors(Customizer.withDefaults())
68- .exceptionHandling(exception -> exception
69- .accessDeniedPage("/error") // Handle access denied with error page
70- );*/
71- /*
7245 http
73- .authorizeRequests(authorize -> authorize
74- .requestMatchers("/sso/v1/**", "/api/v1/**").authenticated()
75- .requestMatchers("/node/**", "/js/**", "/css/**", "/images/**", "/error", "/sso/login", "/api/v1/login/authenticate").permitAll()
76- .anyRequest().authenticated()
77- )
78- .sessionManagement(session -> session
79- .sessionCreationPolicy(SessionCreationPolicy.STATELESS)
80- )
81- .oauth2Login(oauth2 -> oauth2
82- .loginPage("/oauth2/authorization/keycloak")
83- )
84- .oauth2ResourceServer(oauth2 -> oauth2
85- .jwt(jwt -> jwt.jwtAuthenticationConverter(jwtAuthenticationConverterForKeycloak()))
86- )
87- .csrf(csrf -> csrf
88- .csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse())
89- )
90- .cors(Customizer.withDefaults())
91- .exceptionHandling(exception -> exception
92- .accessDeniedPage("/error")
93- );*/
94- http .authorizeHttpRequests (auth -> auth .requestMatchers ("/**" ).fullyAuthenticated ())
46+ .authorizeHttpRequests (auth -> auth .
47+ requestMatchers ("/actuator/**" ).permitAll () // Public endpoints
48+ .requestMatchers ("/**" ).fullyAuthenticated ())
9549 .oauth2ResourceServer (oauth2 -> oauth2
9650 .jwt (jwt -> jwt .jwtAuthenticationConverter (jwtAuthenticationConverterForKeycloak ()))
9751 )
@@ -104,12 +58,6 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti
10458 return http .build ();
10559 }
10660
107- /*
108- @Bean
109- public JwtDecoder jwtDecoder(OAuth2ResourceServerProperties properties) {
110- return JwtDecoders.fromIssuerLocation("http://localhost:8180/realms/sentrius");
111- }
112- */
11361 @ Bean
11462 public JwtAuthenticationConverter jwtAuthenticationConverterForKeycloak () {
11563 JwtAuthenticationConverter converter = new JwtAuthenticationConverter ();
0 commit comments