Refactor disable basic auth 83/138283/1
authorsaul.gill <saul.gill@est.tech>
Wed, 19 Jun 2024 09:49:38 +0000 (10:49 +0100)
committersaul.gill <saul.gill@est.tech>
Wed, 19 Jun 2024 09:49:40 +0000 (10:49 +0100)
Issue-ID: POLICY-5044
Change-Id: Ib9db9fddd5890458c8ec830cef465e9c884f7c40
Signed-off-by: saul.gill <saul.gill@est.tech>
runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/SecurityConfig.java

index 2e75db1..9d50fc7 100644 (file)
@@ -45,16 +45,16 @@ public class SecurityConfig {
      */
     @Bean
     public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
-        http
-            .httpBasic(Customizer.withDefaults())
-            .authorizeHttpRequests(authorize -> {
-                if (useBasicAuth) {
-                    authorize.anyRequest().authenticated();
-                } else {
-                    authorize.anyRequest().permitAll();
-                }
-            })
-            .csrf(AbstractHttpConfigurer::disable);
+        if (useBasicAuth) {
+            http
+                    .httpBasic(Customizer.withDefaults())
+                    .authorizeHttpRequests(authorize -> authorize.anyRequest().authenticated());
+        } else {
+            http
+                    .authorizeHttpRequests(authorize -> authorize.anyRequest().permitAll());
+        }
+
+        http.csrf(AbstractHttpConfigurer::disable);
         return http.build();
     }
 }