diff --git a/apps/backend/pom.xml b/apps/backend/pom.xml index 0f2aaa5a5..52a9eb2b8 100644 --- a/apps/backend/pom.xml +++ b/apps/backend/pom.xml @@ -5,7 +5,7 @@ org.springframework.boot spring-boot-starter-parent - 2.7.10 + 3.1.3 no.nav.data @@ -18,19 +18,17 @@ 17 1.6.14 - 3.2.0 + 3.5.1 1.3.10 7.3 - 11.3.2 + 11.4.9 8.11.2 4.44.0 4.4 5.47.0 - 1.13.4 - - 1.0.3 + 1.13.10 42.5.4 @@ -54,7 +52,7 @@ 1.17.6 2.27.2 2.13.10 - 5.5.0 + 5.8.0 3.3.0 @@ -154,6 +152,14 @@ com.microsoft.azure msal4j + + + + com.nimbusds + oauth2-oidc-sdk + + + com.fasterxml.woodstox @@ -184,12 +190,9 @@ ${nav-vault-jdbc.version} - - - io.hypersistence - hypersistence-utils-hibernate-55 - ${hypersistence-utils-hibernate-55.version} + hypersistence-utils-hibernate-62 + ${hypersistence-utils-hibernate-62.version} net.javacrumbs.shedlock @@ -602,6 +605,8 @@ true false true + + jakarta.validation.constraints.NotNull diff --git a/apps/backend/src/main/java/no/nav/data/common/CommonConfig.java b/apps/backend/src/main/java/no/nav/data/common/CommonConfig.java index 064a3089a..42fd13aec 100644 --- a/apps/backend/src/main/java/no/nav/data/common/CommonConfig.java +++ b/apps/backend/src/main/java/no/nav/data/common/CommonConfig.java @@ -16,6 +16,7 @@ import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.web.client.RestTemplate; + import javax.sql.DataSource; import static java.util.Collections.emptyList; diff --git a/apps/backend/src/main/java/no/nav/data/common/auditing/AuditVersionListener.java b/apps/backend/src/main/java/no/nav/data/common/auditing/AuditVersionListener.java index c300d7533..1eb8ab5f3 100644 --- a/apps/backend/src/main/java/no/nav/data/common/auditing/AuditVersionListener.java +++ b/apps/backend/src/main/java/no/nav/data/common/auditing/AuditVersionListener.java @@ -10,6 +10,10 @@ import com.fasterxml.jackson.databind.ser.PropertyWriter; import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter; import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider; +import jakarta.persistence.Entity; +import jakarta.persistence.PrePersist; +import jakarta.persistence.PreRemove; +import jakarta.persistence.PreUpdate; import lombok.extern.slf4j.Slf4j; import no.nav.data.common.auditing.domain.Action; import no.nav.data.common.auditing.domain.AuditVersion; @@ -24,10 +28,6 @@ import java.util.Optional; import java.util.UUID; -import javax.persistence.Entity; -import javax.persistence.PrePersist; -import javax.persistence.PreRemove; -import javax.persistence.PreUpdate; import static no.nav.data.common.storage.domain.TypeRegistration.isAudited; diff --git a/apps/backend/src/main/java/no/nav/data/common/auditing/domain/AuditVersion.java b/apps/backend/src/main/java/no/nav/data/common/auditing/domain/AuditVersion.java index acc16ad4b..e8553b626 100644 --- a/apps/backend/src/main/java/no/nav/data/common/auditing/domain/AuditVersion.java +++ b/apps/backend/src/main/java/no/nav/data/common/auditing/domain/AuditVersion.java @@ -1,5 +1,6 @@ package no.nav.data.common.auditing.domain; +import jakarta.persistence.*; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -13,17 +14,11 @@ import no.nav.data.common.utils.JsonUtils; import no.nav.data.team.po.domain.ProductArea; import no.nav.data.team.team.domain.Team; -import org.hibernate.annotations.Type; +import org.hibernate.annotations.JdbcTypeCode; +import org.hibernate.type.SqlTypes; import java.time.LocalDateTime; import java.util.UUID; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.EnumType; -import javax.persistence.Enumerated; -import javax.persistence.Id; -import javax.persistence.Table; -import javax.persistence.Transient; @Data @Builder @@ -38,7 +33,6 @@ public class AuditVersion { public static final String PA_TYPE = TypeRegistration.typeOf(ProductArea.class); @Id - @Type(type = "pg-uuid") @Column(name = "AUDIT_ID") @Builder.Default private UUID id = UUID.randomUUID(); @@ -60,7 +54,7 @@ public class AuditVersion { @Column(name = "USER_ID", nullable = false, updatable = false) private String user; - @Type(type = "jsonb") + @JdbcTypeCode(SqlTypes.JSON) @Column(name = "DATA", nullable = false, updatable = false) private String data; diff --git a/apps/backend/src/main/java/no/nav/data/common/auditing/domain/Auditable.java b/apps/backend/src/main/java/no/nav/data/common/auditing/domain/Auditable.java index 73ed1c826..77d46d764 100644 --- a/apps/backend/src/main/java/no/nav/data/common/auditing/domain/Auditable.java +++ b/apps/backend/src/main/java/no/nav/data/common/auditing/domain/Auditable.java @@ -1,6 +1,9 @@ package no.nav.data.common.auditing.domain; import com.fasterxml.jackson.annotation.JsonFilter; +import jakarta.persistence.Column; +import jakarta.persistence.EntityListeners; +import jakarta.persistence.MappedSuperclass; import lombok.Getter; import lombok.Setter; import lombok.experimental.FieldNameConstants; @@ -13,9 +16,6 @@ import org.springframework.data.jpa.domain.support.AuditingEntityListener; import java.time.LocalDateTime; -import javax.persistence.Column; -import javax.persistence.EntityListeners; -import javax.persistence.MappedSuperclass; @Getter @Setter diff --git a/apps/backend/src/main/java/no/nav/data/common/jpa/JpaConfig.java b/apps/backend/src/main/java/no/nav/data/common/jpa/JpaConfig.java index 031907b45..36d6b8215 100644 --- a/apps/backend/src/main/java/no/nav/data/common/jpa/JpaConfig.java +++ b/apps/backend/src/main/java/no/nav/data/common/jpa/JpaConfig.java @@ -1,6 +1,7 @@ package no.nav.data.common.jpa; import io.prometheus.client.hibernate.HibernateStatisticsCollector; +import jakarta.persistence.EntityManagerFactory; import lombok.extern.slf4j.Slf4j; import no.nav.data.AppStarter; import no.nav.data.common.auditing.AuditVersionListener; @@ -17,7 +18,6 @@ import org.springframework.data.jpa.repository.config.EnableJpaAuditing; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; -import javax.persistence.EntityManagerFactory; import static no.nav.data.common.utils.MdcUtils.wrapAsync; diff --git a/apps/backend/src/main/java/no/nav/data/common/jpa/package-info.java b/apps/backend/src/main/java/no/nav/data/common/jpa/package-info.java deleted file mode 100644 index 38d3437cb..000000000 --- a/apps/backend/src/main/java/no/nav/data/common/jpa/package-info.java +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Register json typedefs - */ -@TypeDefs({ - @TypeDef(name = "jsonb", typeClass = JsonBinaryType.class), - @TypeDef(name = "jsonb-node", typeClass = JsonNodeBinaryType.class) -}) -package no.nav.data.common.jpa; - -import io.hypersistence.utils.hibernate.type.json.JsonBinaryType; -import io.hypersistence.utils.hibernate.type.json.JsonNodeBinaryType; -import org.hibernate.annotations.TypeDef; -import org.hibernate.annotations.TypeDefs; \ No newline at end of file diff --git a/apps/backend/src/main/java/no/nav/data/common/kafka/KafkaConfig.java b/apps/backend/src/main/java/no/nav/data/common/kafka/KafkaConfig.java index f0f9769c6..9725cf7b0 100644 --- a/apps/backend/src/main/java/no/nav/data/common/kafka/KafkaConfig.java +++ b/apps/backend/src/main/java/no/nav/data/common/kafka/KafkaConfig.java @@ -39,8 +39,8 @@ public KafkaMessageListenerContainer nomRessursContainer( containerProps.setPollTimeout(500); var container = new KafkaMessageListenerContainer<>(consumerFactory, containerProps); - container.setBatchErrorHandler(new KafkaErrorHandler()); - container.getContainerProperties().setAuthorizationExceptionRetryInterval(Duration.ofMinutes(5)); + container.setCommonErrorHandler(new KafkaErrorHandler()); + container.getContainerProperties().setAuthExceptionRetryInterval(Duration.ofMinutes(5)); return container; } diff --git a/apps/backend/src/main/java/no/nav/data/common/kafka/KafkaErrorHandler.java b/apps/backend/src/main/java/no/nav/data/common/kafka/KafkaErrorHandler.java index d87bb1b66..64c2b7927 100644 --- a/apps/backend/src/main/java/no/nav/data/common/kafka/KafkaErrorHandler.java +++ b/apps/backend/src/main/java/no/nav/data/common/kafka/KafkaErrorHandler.java @@ -3,13 +3,14 @@ import lombok.extern.slf4j.Slf4j; import org.apache.kafka.clients.consumer.Consumer; import org.apache.kafka.clients.consumer.ConsumerRecord; -import org.apache.kafka.clients.consumer.ConsumerRecords; +import org.jetbrains.annotations.NotNull; import org.springframework.core.task.SimpleAsyncTaskExecutor; -import org.springframework.kafka.listener.ContainerStoppingBatchErrorHandler; +import org.springframework.kafka.listener.CommonContainerStoppingErrorHandler; import org.springframework.kafka.listener.MessageListenerContainer; import org.springframework.stereotype.Component; import java.time.Duration; +import java.util.List; import java.util.Optional; import java.util.concurrent.Executor; import java.util.concurrent.atomic.AtomicInteger; @@ -17,7 +18,7 @@ @Slf4j @Component -public class KafkaErrorHandler extends ContainerStoppingBatchErrorHandler { +public class KafkaErrorHandler extends CommonContainerStoppingErrorHandler { private final Executor executor; @@ -35,15 +36,15 @@ public KafkaErrorHandler() { } @Override - public void handle(Exception e, ConsumerRecords records, Consumer consumer, MessageListenerContainer container) { + public void handleRemaining(@NotNull Exception thrownException, List> records, @NotNull Consumer consumer, @NotNull MessageListenerContainer container) { var record = records.iterator().hasNext() ? records.iterator().next() : null; Optional.ofNullable(record) .map(ConsumerRecord::topic) - .ifPresent(topic -> scheduleRestart(e, records, consumer, container, topic)); + .ifPresent(topic -> scheduleRestart(thrownException, records, consumer, container, topic)); } @SuppressWarnings({"pmd:DoNotUseThreads", "fb-contrib:SEC_SIDE_EFFECT_CONSTRUCTOR"}) - private void scheduleRestart(Exception e, ConsumerRecords records, Consumer consumer, MessageListenerContainer container, String topic) { + private void scheduleRestart(Exception thrownException, List> records, Consumer consumer, MessageListenerContainer container, String topic) { long now = System.currentTimeMillis(); if (now - lastError.getAndSet(now) > COUNTER_RESET_TIME) { counter.set(0); @@ -62,7 +63,7 @@ private void scheduleRestart(Exception e, ConsumerRecords records, Consume }); log.warn("Stopping kafka container topic={} for {}", topic, Duration.ofMillis(stopTime).toString()); - super.handle(e, records, consumer, container); + super.handleRemaining(thrownException, records, consumer, container); } } diff --git a/apps/backend/src/main/java/no/nav/data/common/security/AuthController.java b/apps/backend/src/main/java/no/nav/data/common/security/AuthController.java index 1b924f721..cb14cd693 100644 --- a/apps/backend/src/main/java/no/nav/data/common/security/AuthController.java +++ b/apps/backend/src/main/java/no/nav/data/common/security/AuthController.java @@ -5,6 +5,9 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.servlet.http.Cookie; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import no.nav.data.common.exceptions.TechnicalException; @@ -27,9 +30,6 @@ import org.springframework.web.util.UriComponentsBuilder; import java.io.IOException; -import javax.servlet.http.Cookie; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; import static no.nav.data.common.security.SecurityConstants.COOKIE_NAME; import static no.nav.data.common.utils.Constants.SESSION_LENGTH; @@ -79,10 +79,10 @@ public void login(HttpServletRequest request, HttpServletResponse response, @CrossOrigin @PostMapping(OAUTH_2_CALLBACK_URL) public void oidc(HttpServletRequest request, HttpServletResponse response, - @RequestParam(value = CODE, required = false) String code, - @RequestParam(value = ERROR, required = false) String error, - @RequestParam(value = ERROR_DESCRIPTION, required = false) String errorDesc, - @RequestParam(STATE) String stateJson + @RequestParam(value = CODE, required = false) String code, + @RequestParam(value = ERROR, required = false) String error, + @RequestParam(value = ERROR_DESCRIPTION, required = false) String errorDesc, + @RequestParam(STATE) String stateJson ) throws IOException { log.debug("Request to auth"); OAuthState state; diff --git a/apps/backend/src/main/java/no/nav/data/common/security/WebSecurityConfig.java b/apps/backend/src/main/java/no/nav/data/common/security/WebSecurityConfig.java index 99be72a75..100105adb 100644 --- a/apps/backend/src/main/java/no/nav/data/common/security/WebSecurityConfig.java +++ b/apps/backend/src/main/java/no/nav/data/common/security/WebSecurityConfig.java @@ -3,46 +3,79 @@ import no.nav.data.common.security.azure.AADStatelessAuthenticationFilter; import no.nav.data.common.security.dto.AppRole; import no.nav.data.common.web.UserFilter; -import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; import org.springframework.http.HttpMethod; -import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; +import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity; import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer; import org.springframework.security.config.http.SessionCreationPolicy; +import org.springframework.security.web.SecurityFilterChain; import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; @Configuration -@EnableGlobalMethodSecurity(prePostEnabled = true, jsr250Enabled = true) -public class WebSecurityConfig extends WebSecurityConfigurerAdapter { +@EnableWebSecurity +@EnableMethodSecurity(jsr250Enabled = true) +public class WebSecurityConfig { private final UserFilter userFilter = new UserFilter(); - @Autowired(required = false) - private AADStatelessAuthenticationFilter aadAuthFilter; - @Autowired(required = false) - private SecurityProperties securityProperties; + private final AADStatelessAuthenticationFilter aadAuthFilter; - @Override - protected void configure(HttpSecurity http) throws Exception { - http.csrf().disable() - .logout().disable() - .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS); - addFilters(http); + public WebSecurityConfig(AADStatelessAuthenticationFilter aadAuthFilter) { + this.aadAuthFilter = aadAuthFilter; + } - if (securityProperties == null || !securityProperties.isEnabled()) { - return; - } + @Bean + @Profile("test") + public SecurityFilterChain testSecurityFilterChain(HttpSecurity httpSecurity) throws Exception { + httpSecurity + .csrf(AbstractHttpConfigurer::disable) + .logout(AbstractHttpConfigurer::disable) + .sessionManagement((sessionManagement) -> + sessionManagement.sessionCreationPolicy(SessionCreationPolicy.STATELESS)); + addFilters(httpSecurity); + + return httpSecurity.build(); + } + + @Bean + @Profile("!test") + public SecurityFilterChain securityFilterChain(HttpSecurity httpSecurity) throws Exception { + httpSecurity + .csrf(AbstractHttpConfigurer::disable) + .logout(AbstractHttpConfigurer::disable) + .sessionManagement((sessionManagement) -> + sessionManagement.sessionCreationPolicy(SessionCreationPolicy.STATELESS)) + .authorizeHttpRequests((auth) -> auth + .requestMatchers(allowAllEndpoints()).permitAll() + .requestMatchers(HttpMethod.GET, getAndOptionsEndpoints()).permitAll() + .requestMatchers(HttpMethod.OPTIONS, getAndOptionsEndpoints()).permitAll() + .requestMatchers(adminOnlyEndpoints()).hasRole(AppRole.ADMIN.name()) + .requestMatchers(HttpMethod.POST, "/resource/multi").permitAll() + .requestMatchers("/logout").authenticated() + .requestMatchers("/**").hasRole(AppRole.WRITE.name()) + ); + + addFilters(httpSecurity); + + return httpSecurity.build(); + } - allowAll(http, + String[] allowAllEndpoints() { + return new String[]{ "/login", "/oauth2/callback", "/userinfo", "/internal/**", "/swagger*/**" - ); + }; + } - allowGetAndOptions(http, + String[] getAndOptionsEndpoints() { + return new String[]{ "/team/**", "/productarea/**", "/cluster/**", @@ -58,46 +91,23 @@ protected void configure(HttpSecurity http) throws Exception { "/settings/**", "/notification/**", "/integration/pcat/**" - ); + }; + } - adminOnly(http, + String[] adminOnlyEndpoints() { + return new String[]{ "/audit/**", "/settings/**", "/admin/**", "/location/**" - ); - - http.authorizeRequests().antMatchers(HttpMethod.POST, "/resource/multi").permitAll(); - - http.authorizeRequests().antMatchers("/logout").authenticated(); - http.authorizeRequests().anyRequest().hasRole(AppRole.WRITE.name()); - } - - private void adminOnly(HttpSecurity http, String... paths) throws Exception { - for (String path : paths) { - http.authorizeRequests().antMatchers(path).hasRole(AppRole.ADMIN.name()); - } - } - - private void allowAll(HttpSecurity http, String... paths) throws Exception { - for (String path : paths) { - http.authorizeRequests().antMatchers(path).permitAll(); - } - } - - private void allowGetAndOptions(HttpSecurity http, String... paths) throws Exception { - for (String path : paths) { - http.authorizeRequests().antMatchers(HttpMethod.GET, path).permitAll(); - http.authorizeRequests().antMatchers(HttpMethod.OPTIONS, path).permitAll(); - } + }; } private void addFilters(HttpSecurity http) { - // In lightweight mvc tests where authfilter isnt initialized + // In lightweight mvc tests where authfilter isn't initialized if (aadAuthFilter != null) { http.addFilterBefore(aadAuthFilter, UsernamePasswordAuthenticationFilter.class); } http.addFilterAfter(userFilter, UsernamePasswordAuthenticationFilter.class); } - } diff --git a/apps/backend/src/main/java/no/nav/data/common/security/azure/AADStatelessAuthenticationFilter.java b/apps/backend/src/main/java/no/nav/data/common/security/azure/AADStatelessAuthenticationFilter.java index 6d0d52fc7..ffafe146b 100644 --- a/apps/backend/src/main/java/no/nav/data/common/security/azure/AADStatelessAuthenticationFilter.java +++ b/apps/backend/src/main/java/no/nav/data/common/security/azure/AADStatelessAuthenticationFilter.java @@ -18,6 +18,11 @@ import com.nimbusds.jwt.proc.JWTClaimsSetVerifier; import com.nimbusds.openid.connect.sdk.op.OIDCProviderMetadata; import io.prometheus.client.Counter; +import jakarta.servlet.FilterChain; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.Cookie; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import lombok.extern.slf4j.Slf4j; import no.nav.data.common.security.AppIdMapping; import no.nav.data.common.security.AuthController; @@ -39,11 +44,6 @@ import java.util.Optional; import java.util.Set; import java.util.stream.Stream; -import javax.servlet.FilterChain; -import javax.servlet.ServletException; -import javax.servlet.http.Cookie; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; import static no.nav.data.common.security.SecurityConstants.COOKIE_NAME; import static no.nav.data.common.security.SecurityConstants.TOKEN_TYPE; diff --git a/apps/backend/src/main/java/no/nav/data/common/security/domain/Auth.java b/apps/backend/src/main/java/no/nav/data/common/security/domain/Auth.java index 49c7080df..ccf4c39f7 100644 --- a/apps/backend/src/main/java/no/nav/data/common/security/domain/Auth.java +++ b/apps/backend/src/main/java/no/nav/data/common/security/domain/Auth.java @@ -1,20 +1,15 @@ package no.nav.data.common.security.domain; +import jakarta.persistence.*; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import no.nav.data.common.security.Encryptor; -import org.hibernate.annotations.Type; import org.springframework.util.Assert; import java.time.LocalDateTime; import java.util.UUID; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; -import javax.persistence.Transient; @Data @Builder @@ -25,7 +20,6 @@ public class Auth { @Id - @Type(type = "pg-uuid") @Column(name = "ID") private UUID id; diff --git a/apps/backend/src/main/java/no/nav/data/common/storage/domain/GenericStorage.java b/apps/backend/src/main/java/no/nav/data/common/storage/domain/GenericStorage.java index 1dc9c9feb..0fa92cd63 100644 --- a/apps/backend/src/main/java/no/nav/data/common/storage/domain/GenericStorage.java +++ b/apps/backend/src/main/java/no/nav/data/common/storage/domain/GenericStorage.java @@ -1,6 +1,11 @@ package no.nav.data.common.storage.domain; import com.fasterxml.jackson.databind.JsonNode; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; +import jakarta.validation.constraints.NotNull; import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; @@ -13,17 +18,13 @@ import no.nav.data.team.po.domain.ProductArea; import no.nav.data.team.resource.domain.Resource; import no.nav.data.team.team.domain.Team; -import org.hibernate.annotations.Type; +import org.hibernate.annotations.JdbcTypeCode; +import org.hibernate.type.SqlTypes; import org.springframework.util.Assert; import java.util.Collection; import java.util.List; import java.util.UUID; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; -import javax.validation.constraints.NotNull; import static no.nav.data.common.utils.StreamUtils.convert; @@ -37,7 +38,6 @@ public class GenericStorage extends Auditable { @Id - @Type(type = "pg-uuid") @Column(name = "ID") private UUID id; @@ -45,7 +45,7 @@ public class GenericStorage extends Auditable { @Column(name = "TYPE", nullable = false, updatable = false) private String type; - @Type(type = "jsonb") + @JdbcTypeCode(SqlTypes.JSON) @Column(name = "DATA", nullable = false) private JsonNode data; diff --git a/apps/backend/src/main/java/no/nav/data/common/utils/MdcExecutor.java b/apps/backend/src/main/java/no/nav/data/common/utils/MdcExecutor.java index 36948b63a..1ddf82a90 100644 --- a/apps/backend/src/main/java/no/nav/data/common/utils/MdcExecutor.java +++ b/apps/backend/src/main/java/no/nav/data/common/utils/MdcExecutor.java @@ -1,5 +1,7 @@ package no.nav.data.common.utils; +import jakarta.annotation.PreDestroy; +import jakarta.validation.constraints.NotNull; import org.slf4j.MDC; import org.springframework.scheduling.concurrent.CustomizableThreadFactory; import org.springframework.util.concurrent.ListenableFutureCallback; @@ -9,8 +11,6 @@ import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.function.Consumer; -import javax.annotation.PreDestroy; -import javax.validation.constraints.NotNull; public class MdcExecutor extends ThreadPoolExecutor { diff --git a/apps/backend/src/main/java/no/nav/data/common/web/CorrelationFilter.java b/apps/backend/src/main/java/no/nav/data/common/web/CorrelationFilter.java index f721decb4..368f5e31b 100644 --- a/apps/backend/src/main/java/no/nav/data/common/web/CorrelationFilter.java +++ b/apps/backend/src/main/java/no/nav/data/common/web/CorrelationFilter.java @@ -1,5 +1,9 @@ package no.nav.data.common.web; +import jakarta.servlet.FilterChain; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import no.nav.data.common.utils.MdcUtils; import org.springframework.core.annotation.Order; import org.springframework.security.web.util.UrlUtils; @@ -8,10 +12,6 @@ import java.io.IOException; import java.util.Optional; -import javax.servlet.FilterChain; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; import static no.nav.data.common.utils.Constants.HEADER_CALL_ID; import static no.nav.data.common.utils.Constants.HEADER_CONSUMER_ID; diff --git a/apps/backend/src/main/java/no/nav/data/common/web/UserFilter.java b/apps/backend/src/main/java/no/nav/data/common/web/UserFilter.java index f2dd6c5b9..ddeea4390 100644 --- a/apps/backend/src/main/java/no/nav/data/common/web/UserFilter.java +++ b/apps/backend/src/main/java/no/nav/data/common/web/UserFilter.java @@ -1,13 +1,13 @@ package no.nav.data.common.web; +import jakarta.servlet.FilterChain; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import no.nav.data.common.utils.MdcUtils; import org.springframework.web.filter.OncePerRequestFilter; import java.io.IOException; -import javax.servlet.FilterChain; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; public class UserFilter extends OncePerRequestFilter { diff --git a/apps/backend/src/main/java/no/nav/data/team/cluster/ClusterController.java b/apps/backend/src/main/java/no/nav/data/team/cluster/ClusterController.java index 3beb112bf..47ea5c970 100644 --- a/apps/backend/src/main/java/no/nav/data/team/cluster/ClusterController.java +++ b/apps/backend/src/main/java/no/nav/data/team/cluster/ClusterController.java @@ -3,6 +3,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; import lombok.extern.slf4j.Slf4j; import no.nav.data.common.exceptions.ValidationException; import no.nav.data.common.rest.RestResponsePage; @@ -25,7 +26,6 @@ import java.util.Objects; import java.util.UUID; -import javax.validation.Valid; import static no.nav.data.common.utils.StreamUtils.convert; diff --git a/apps/backend/src/main/java/no/nav/data/team/dashboard/dto/DashResponse.java b/apps/backend/src/main/java/no/nav/data/team/dashboard/dto/DashResponse.java index 9b77ed838..cdddd8b29 100644 --- a/apps/backend/src/main/java/no/nav/data/team/dashboard/dto/DashResponse.java +++ b/apps/backend/src/main/java/no/nav/data/team/dashboard/dto/DashResponse.java @@ -2,6 +2,7 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; +import jakarta.validation.constraints.NotNull; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -10,7 +11,6 @@ import no.nav.data.team.team.domain.TeamRole; import no.nav.data.team.team.domain.TeamType; -import javax.validation.constraints.NotNull; import java.util.List; import java.util.Map; import java.util.UUID; diff --git a/apps/backend/src/main/java/no/nav/data/team/member/MemberController.java b/apps/backend/src/main/java/no/nav/data/team/member/MemberController.java index b417f5540..24dd2f36a 100644 --- a/apps/backend/src/main/java/no/nav/data/team/member/MemberController.java +++ b/apps/backend/src/main/java/no/nav/data/team/member/MemberController.java @@ -5,8 +5,8 @@ import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.servlet.http.HttpServletResponse; import lombok.extern.slf4j.Slf4j; -import lombok.val; import no.nav.data.common.TeamCatalogProps; import no.nav.data.common.exceptions.TechnicalException; import no.nav.data.common.exceptions.ValidationException; @@ -28,8 +28,6 @@ import org.springframework.web.bind.annotation.RestController; import java.util.Optional; -import java.util.function.Function; -import javax.servlet.http.HttpServletResponse; import static no.nav.data.common.export.ExcelBuilder.SPREADSHEETML_SHEET_MIME; import static no.nav.data.common.utils.StreamUtils.convert; diff --git a/apps/backend/src/main/java/no/nav/data/team/po/ProductAreaController.java b/apps/backend/src/main/java/no/nav/data/team/po/ProductAreaController.java index 02d0664b2..dadb4c54c 100644 --- a/apps/backend/src/main/java/no/nav/data/team/po/ProductAreaController.java +++ b/apps/backend/src/main/java/no/nav/data/team/po/ProductAreaController.java @@ -3,6 +3,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; import lombok.extern.slf4j.Slf4j; import no.nav.data.common.TeamCatalogProps; import no.nav.data.common.exceptions.ValidationException; @@ -27,7 +28,6 @@ import java.util.Objects; import java.util.UUID; -import javax.validation.Valid; import static no.nav.data.common.utils.StreamUtils.convert; diff --git a/apps/backend/src/main/java/no/nav/data/team/team/TeamController.java b/apps/backend/src/main/java/no/nav/data/team/team/TeamController.java index 6d821ad79..00620d07a 100644 --- a/apps/backend/src/main/java/no/nav/data/team/team/TeamController.java +++ b/apps/backend/src/main/java/no/nav/data/team/team/TeamController.java @@ -5,6 +5,8 @@ import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.servlet.http.HttpServletResponse; +import jakarta.validation.Valid; import lombok.extern.slf4j.Slf4j; import lombok.val; import no.nav.data.common.exceptions.TechnicalException; @@ -33,8 +35,6 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; import java.util.HashMap; import java.util.List; import java.util.Objects; diff --git a/apps/backend/src/main/resources/application.properties b/apps/backend/src/main/resources/application.properties index c1201d198..a08771580 100644 --- a/apps/backend/src/main/resources/application.properties +++ b/apps/backend/src/main/resources/application.properties @@ -11,7 +11,7 @@ springdoc.swagger-ui.path=/api # DATABASE spring.datasource.url=jdbc:postgresql://localhost:5412/postgres -spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQL95Dialect +spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true spring.jpa.hibernate.ddl-auto=none spring.jpa.open-in-view=false diff --git a/apps/backend/src/test/java/no/nav/data/team/cluster/ClusterControllerIT.java b/apps/backend/src/test/java/no/nav/data/team/cluster/ClusterControllerIT.java index fc5e1e6d0..8228c69c6 100644 --- a/apps/backend/src/test/java/no/nav/data/team/cluster/ClusterControllerIT.java +++ b/apps/backend/src/test/java/no/nav/data/team/cluster/ClusterControllerIT.java @@ -8,11 +8,9 @@ import no.nav.data.team.cluster.dto.ClusterRequest; import no.nav.data.team.cluster.dto.ClusterResponse; import no.nav.data.team.member.dto.MemberResponse; -import no.nav.data.team.po.ProductAreaController; -import no.nav.data.team.po.domain.ProductArea; import no.nav.data.team.resource.dto.ResourceResponse; -import no.nav.data.team.shared.dto.Links; import no.nav.data.team.shared.domain.DomainObjectStatus; +import no.nav.data.team.shared.dto.Links; import no.nav.data.team.team.domain.Team; import no.nav.data.team.team.domain.TeamRole; import org.junit.jupiter.api.BeforeEach; @@ -200,9 +198,9 @@ void getClusterStatus() { var cluster3 = createClusterRequestWithStatus(DomainObjectStatus.PLANNED, "cluster 3"); - var post1 = restTemplate.postForEntity("/cluster/", cluster1, ClusterResponse.class); - var post2 = restTemplate.postForEntity("/cluster/", cluster2, ClusterResponse.class); - var post3 = restTemplate.postForEntity("/cluster/", cluster3, ClusterResponse.class); + var post1 = restTemplate.postForEntity("/cluster", cluster1, ClusterResponse.class); + var post2 = restTemplate.postForEntity("/cluster", cluster2, ClusterResponse.class); + var post3 = restTemplate.postForEntity("/cluster", cluster3, ClusterResponse.class); diff --git a/apps/backend/src/test/java/no/nav/data/team/kafka/KafkaContainer.java b/apps/backend/src/test/java/no/nav/data/team/kafka/KafkaContainer.java index e9b2a518c..59687bd38 100644 --- a/apps/backend/src/test/java/no/nav/data/team/kafka/KafkaContainer.java +++ b/apps/backend/src/test/java/no/nav/data/team/kafka/KafkaContainer.java @@ -1,6 +1,5 @@ package no.nav.data.team.kafka; -import org.springframework.util.SocketUtils; import org.testcontainers.containers.Network; import org.testcontainers.utility.DockerImageName; diff --git a/apps/backend/src/test/java/no/nav/data/team/kafka/SchemaRegistryContainer.java b/apps/backend/src/test/java/no/nav/data/team/kafka/SchemaRegistryContainer.java index 253419c8c..2923f4d26 100644 --- a/apps/backend/src/test/java/no/nav/data/team/kafka/SchemaRegistryContainer.java +++ b/apps/backend/src/test/java/no/nav/data/team/kafka/SchemaRegistryContainer.java @@ -1,6 +1,5 @@ package no.nav.data.team.kafka; -import org.springframework.util.SocketUtils; import org.testcontainers.containers.GenericContainer; import org.testcontainers.containers.KafkaContainer; import org.testcontainers.containers.wait.strategy.HttpWaitStrategy; diff --git a/apps/backend/src/test/java/no/nav/data/team/po/ProductAreaControllerIT.java b/apps/backend/src/test/java/no/nav/data/team/po/ProductAreaControllerIT.java index 04d582ad3..1be75aba2 100644 --- a/apps/backend/src/test/java/no/nav/data/team/po/ProductAreaControllerIT.java +++ b/apps/backend/src/test/java/no/nav/data/team/po/ProductAreaControllerIT.java @@ -321,9 +321,9 @@ void getProductAreaStatus() { var po2 = createProductAreaRequestWithStatus(DomainObjectStatus.INACTIVE, "po 2"); var po3 = createProductAreaRequestWithStatus(DomainObjectStatus.PLANNED, "po 3"); - var post1 = restTemplate.postForEntity("/productarea/", po1, ProductAreaResponse.class); - var post2 =restTemplate.postForEntity("/productarea/", po2, ProductAreaResponse.class); - var post3 =restTemplate.postForEntity("/productarea/", po3, ProductAreaResponse.class); + var post1 = restTemplate.postForEntity("/productarea", po1, ProductAreaResponse.class); + var post2 =restTemplate.postForEntity("/productarea", po2, ProductAreaResponse.class); + var post3 =restTemplate.postForEntity("/productarea", po3, ProductAreaResponse.class); ResponseEntity resp1 = restTemplate.getForEntity("/productarea/{id}", ProductAreaResponse.class, post1.getBody().getId()); diff --git a/apps/backend/src/test/java/no/nav/data/team/team/TeamControllerIT.java b/apps/backend/src/test/java/no/nav/data/team/team/TeamControllerIT.java index ffd0a7f35..3b55fe005 100644 --- a/apps/backend/src/test/java/no/nav/data/team/team/TeamControllerIT.java +++ b/apps/backend/src/test/java/no/nav/data/team/team/TeamControllerIT.java @@ -408,9 +408,9 @@ void getTeamStatus() { var team3 = createTeamRequestWithStatus(DomainObjectStatus.PLANNED, "team 3"); - var post1 = restTemplate.postForEntity("/team/", team1, TeamResponse.class); - var post2 = restTemplate.postForEntity("/team/", team2, TeamResponse.class); - var post3 = restTemplate.postForEntity("/team/", team3, TeamResponse.class); + var post1 = restTemplate.postForEntity("/team", team1, TeamResponse.class); + var post2 = restTemplate.postForEntity("/team", team2, TeamResponse.class); + var post3 = restTemplate.postForEntity("/team", team3, TeamResponse.class); ResponseEntity resp1 = restTemplate.getForEntity("/team/{id}", TeamResponse.class, post1.getBody().getId()); diff --git a/apps/frontend/src/api/adminApi.ts b/apps/frontend/src/api/adminApi.ts index d973a22cc..6ce364035 100644 --- a/apps/frontend/src/api/adminApi.ts +++ b/apps/frontend/src/api/adminApi.ts @@ -29,7 +29,7 @@ export const getAuditLog = async (id: string) => { export const getAudits = async (page: number, count: number, table?: ObjectType) => { return ( await axios.get>( - `${env.teamCatalogBaseUrl}/audit/?pageNumber=${page}&pageSize=${count}` + (table ? `&table=${table}` : ""), + `${env.teamCatalogBaseUrl}/audit?pageNumber=${page}&pageSize=${count}` + (table ? `&table=${table}` : ""), ) ).data; };