11package org .patinanetwork .codebloom .api .auth .security ;
22
3- import org .springframework .boot .context .properties .EnableConfigurationProperties ;
43import org .springframework .context .annotation .Bean ;
54import org .springframework .context .annotation .Configuration ;
65import org .springframework .core .annotation .Order ;
76import org .springframework .security .config .annotation .web .builders .HttpSecurity ;
87import org .springframework .security .config .annotation .web .configuration .EnableWebSecurity ;
98import org .springframework .security .config .annotation .web .configuration .WebSecurityCustomizer ;
109import org .springframework .security .config .annotation .web .configurers .AbstractHttpConfigurer ;
11- import org .springframework .security .core .userdetails .User ;
12- import org .springframework .security .core .userdetails .UserDetailsService ;
13- import org .springframework .security .provisioning .InMemoryUserDetailsManager ;
1410import org .springframework .security .web .SecurityFilterChain ;
1511import org .springframework .security .web .authentication .AuthenticationSuccessHandler ;
1612
2016 * @see <a href= "https://github.com/tahminator/codebloom/tree/main/docs/auth.md">Authentication Documentation</a>
2117 */
2218@ Configuration
23- @ EnableConfigurationProperties (SecurityActuatorProperties .class )
2419@ EnableWebSecurity
2520public class SecurityConfig {
2621
@@ -30,29 +25,6 @@ public SecurityConfig(final AuthenticationSuccessHandler customAuthenticationSuc
3025 this .customAuthenticationSuccessHandler = customAuthenticationSuccessHandler ;
3126 }
3227
33- @ Bean
34- UserDetailsService userDetailsService (SecurityActuatorProperties props ) {
35- return new InMemoryUserDetailsManager (User .withUsername (props .username ())
36- .password ("{noop}" + props .password ())
37- .roles ("ACTUATOR" )
38- .build ());
39- }
40-
41- /**
42- * Security filter chain for actuator endpoints with HTTP Basic authentication. This needs to be processed first
43- * (Order 1) to prevent OAuth from being applied.
44- */
45- @ Bean
46- @ Order (1 )
47- public SecurityFilterChain actuatorSecurityFilterChain (final HttpSecurity http ) throws Exception {
48- http .securityMatcher ("/actuator/**" )
49- .csrf (AbstractHttpConfigurer ::disable )
50- .authorizeHttpRequests (auth -> auth .anyRequest ().hasRole ("ACTUATOR" ))
51- .httpBasic (basic -> {});
52-
53- return http .build ();
54- }
55-
5628 @ Bean
5729 @ Order (2 )
5830 SecurityFilterChain embedSecurity (HttpSecurity http ) throws Exception {
0 commit comments