diff options
author | Fiete Ostkamp <Fiete.Ostkamp@telekom.de> | 2024-09-04 09:10:38 +0200 |
---|---|---|
committer | Fiete Ostkamp <Fiete.Ostkamp@telekom.de> | 2024-09-04 09:14:14 +0200 |
commit | cd116feda5f14db413ae5eba57d14d55202a0de5 (patch) | |
tree | 2533a13e5a5aade19ef647aac28848aeefa760e9 /lib/src/main | |
parent | 9ad020e36d7dba6e9e2fdd2e5b5276e728de4bd3 (diff) |
Update spring-boot in bff
- update spring-boot (3.2.4 -> 3.3.3)
- add micrometer-registry-prometheus dependency for metrics
Issue-ID: PORTALNG-116
Change-Id: Iebda696126bdd42bdd4c48d363fe61a781a20f13
Signed-off-by: Fiete Ostkamp <Fiete.Ostkamp@telekom.de>
Diffstat (limited to 'lib/src/main')
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()); |