aboutsummaryrefslogtreecommitdiffstats
path: root/lib/src
diff options
context:
space:
mode:
Diffstat (limited to 'lib/src')
-rw-r--r--lib/src/main/java/org/onap/portalng/bff/config/SecurityConfig.java31
-rw-r--r--lib/src/main/java/org/onap/portalng/bff/controller/RolesController.java2
-rw-r--r--lib/src/main/java/org/onap/portalng/bff/controller/UsersController.java2
-rw-r--r--lib/src/main/java/org/onap/portalng/bff/services/KeycloakService.java5
4 files changed, 17 insertions, 23 deletions
diff --git a/lib/src/main/java/org/onap/portalng/bff/config/SecurityConfig.java b/lib/src/main/java/org/onap/portalng/bff/config/SecurityConfig.java
index 94c87bd..4ae842a 100644
--- a/lib/src/main/java/org/onap/portalng/bff/config/SecurityConfig.java
+++ b/lib/src/main/java/org/onap/portalng/bff/config/SecurityConfig.java
@@ -21,6 +21,8 @@
package org.onap.portalng.bff.config;
+import static org.springframework.security.config.Customizer.withDefaults;
+
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -43,23 +45,20 @@ public class SecurityConfig {
@Bean
public SecurityWebFilterChain securityWebFilterChain(ServerHttpSecurity http) {
- return http.httpBasic()
- .disable()
- .formLogin()
- .disable()
- .csrf()
- .disable()
- .cors()
- .and()
- .authorizeExchange()
- .pathMatchers(unauthenticatedEndpoints)
- .permitAll()
- .anyExchange()
- .authenticated()
- .and()
+ return http.httpBasic(
+ basic ->
+ basic
+ .disable()
+ .formLogin(login -> login.disable().csrf(csrf -> csrf.disable().cors())))
+ .authorizeExchange(
+ exchange ->
+ exchange
+ .pathMatchers(unauthenticatedEndpoints)
+ .permitAll()
+ .anyExchange()
+ .authenticated())
.oauth2ResourceServer(ServerHttpSecurity.OAuth2ResourceServerSpec::jwt)
- .oauth2Client()
- .and()
+ .oauth2Client(withDefaults())
.build();
}
diff --git a/lib/src/main/java/org/onap/portalng/bff/controller/RolesController.java b/lib/src/main/java/org/onap/portalng/bff/controller/RolesController.java
index 3958811..69b4093 100644
--- a/lib/src/main/java/org/onap/portalng/bff/controller/RolesController.java
+++ b/lib/src/main/java/org/onap/portalng/bff/controller/RolesController.java
@@ -25,7 +25,6 @@ import org.onap.portalng.bff.config.BffConfig;
import org.onap.portalng.bff.openapi.server.api.RolesApi;
import org.onap.portalng.bff.openapi.server.model.RoleListResponseApiDto;
import org.onap.portalng.bff.services.KeycloakService;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.server.ServerWebExchange;
@@ -38,7 +37,6 @@ public class RolesController extends AbstractBffController implements RolesApi {
private final KeycloakService keycloakService;
- @Autowired
public RolesController(BffConfig bffConfig, KeycloakService keycloakService) {
super(bffConfig);
this.keycloakService = keycloakService;
diff --git a/lib/src/main/java/org/onap/portalng/bff/controller/UsersController.java b/lib/src/main/java/org/onap/portalng/bff/controller/UsersController.java
index f2c5653..a8561af 100644
--- a/lib/src/main/java/org/onap/portalng/bff/controller/UsersController.java
+++ b/lib/src/main/java/org/onap/portalng/bff/controller/UsersController.java
@@ -31,7 +31,6 @@ import org.onap.portalng.bff.openapi.server.model.UpdateUserRequestApiDto;
import org.onap.portalng.bff.openapi.server.model.UserListResponseApiDto;
import org.onap.portalng.bff.openapi.server.model.UserResponseApiDto;
import org.onap.portalng.bff.services.KeycloakService;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.server.ServerWebExchange;
@@ -53,7 +52,6 @@ public class UsersController extends AbstractBffController implements UsersApi {
private final KeycloakService keycloakService;
- @Autowired
public UsersController(BffConfig bffConfig, KeycloakService keycloakService) {
super(bffConfig);
this.keycloakService = keycloakService;
diff --git a/lib/src/main/java/org/onap/portalng/bff/services/KeycloakService.java b/lib/src/main/java/org/onap/portalng/bff/services/KeycloakService.java
index 5780ad0..92aad46 100644
--- a/lib/src/main/java/org/onap/portalng/bff/services/KeycloakService.java
+++ b/lib/src/main/java/org/onap/portalng/bff/services/KeycloakService.java
@@ -71,9 +71,8 @@ public class KeycloakService {
DownstreamApiProblemException.builder()
.status(Status.NOT_FOUND)
.detail(
- String.format(
- "Roles not found in the realm: %s",
- absentRoles.stream().map(RoleApiDto::getName).toList()))
+ "Roles not found in the realm: %s"
+ .formatted(absentRoles.stream().map(RoleApiDto::getName).toList()))
.downstreamSystem(ProblemApiDto.DownstreamSystemEnum.KEYCLOAK.toString())
.title(HttpStatus.NOT_FOUND.toString())
.build());