diff options
Diffstat (limited to 'lib')
5 files changed, 22 insertions, 28 deletions
diff --git a/lib/build.gradle b/lib/build.gradle index 44b2920..1e8d11c 100644 --- a/lib/build.gradle +++ b/lib/build.gradle @@ -2,7 +2,7 @@ plugins { id 'java' id 'org.springframework.boot' id 'io.spring.dependency-management' - id 'com.github.johnrengelman.shadow' + id 'com.github.johnrengelman.shadow' id 'maven-publish' // publish lib jar to artifact repository id 'com.diffplug.spotless' // code formatting id 'com.github.spotbugs' // bug linting that can be picked up by IDE @@ -31,10 +31,10 @@ dependencies { implementation "org.mapstruct.extensions.spring:mapstruct-spring-extensions:$mapStructExtensionsVersion" implementation "io.swagger.core.v3:swagger-annotations:$swaggerV3Version" - implementation(platform("io.micrometer:micrometer-tracing-bom:$micrometerVersion")) - implementation("io.micrometer:micrometer-tracing") - implementation("io.micrometer:micrometer-tracing-bridge-otel") - implementation("io.opentelemetry:opentelemetry-exporter-zipkin") + implementation 'io.micrometer:micrometer-tracing' + implementation 'io.micrometer:micrometer-tracing-bridge-otel' + implementation 'io.opentelemetry:opentelemetry-exporter-zipkin' + implementation 'io.micrometer:micrometer-registry-prometheus' annotationProcessor "org.mapstruct:mapstruct-processor:$mapStructVersion" annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor' 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()); |