Skip to content

Commit 4e5424e

Browse files
authored
Merge pull request #181 from rostilos/1.5.7-rc
1.5.7 fix platform functional and security issues issues, fix surefire fork jvm exit warning
2 parents ffcd1f9 + add1059 commit 4e5424e

31 files changed

Lines changed: 240 additions & 133 deletions

File tree

java-ecosystem/libs/core/src/it/resources/application-it.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Core module IT properties (local copy — can't use test-support's)
2-
spring.jpa.hibernate.ddl-auto=create-drop
2+
spring.jpa.hibernate.ddl-auto=create
33
spring.jpa.show-sql=false
44
spring.jpa.properties.hibernate.format_sql=false
55
spring.datasource.hikari.maximum-pool-size=5

java-ecosystem/libs/core/src/main/java/module-info.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,7 @@
7373
opens org.rostilos.codecrow.core.model.workspace
7474
to org.hibernate.orm.core, spring.beans, spring.context, spring.core, org.rostilos.codecrow.vcs;
7575

76-
opens org.rostilos.codecrow.core.model.user
77-
to org.hibernate.orm.core, spring.beans, spring.context, spring.core;
76+
opens org.rostilos.codecrow.core.model.user;
7877

7978
opens org.rostilos.codecrow.core.model.vcs
8079
to org.hibernate.orm.core, spring.beans, spring.context, spring.core, org.rostilos.codecrow.vcs;
@@ -89,6 +88,8 @@
8988
exports org.rostilos.codecrow.core.model.branch;
9089
exports org.rostilos.codecrow.core.persistence.repository.branch;
9190
exports org.rostilos.codecrow.core.model.project.config;
91+
opens org.rostilos.codecrow.core.model.project.config to com.fasterxml.jackson.databind;
92+
9293
exports org.rostilos.codecrow.core.model.analysis;
9394
exports org.rostilos.codecrow.core.persistence.repository.analysis;
9495

java-ecosystem/libs/core/src/main/java/org/rostilos/codecrow/core/dto/qualitygate/QualityGateDTO.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.rostilos.codecrow.core.dto.qualitygate;
22

3+
import com.fasterxml.jackson.annotation.JsonProperty;
34
import org.rostilos.codecrow.core.model.qualitygate.QualityGate;
45

56
import java.time.OffsetDateTime;
@@ -40,7 +41,9 @@ public static QualityGateDTO fromEntity(QualityGate entity) {
4041
public String getDescription() { return description; }
4142
public void setDescription(String description) { this.description = description; }
4243

44+
@JsonProperty("isDefault")
4345
public boolean isDefault() { return isDefault; }
46+
@JsonProperty("isDefault")
4447
public void setDefault(boolean isDefault) { this.isDefault = isDefault; }
4548

4649
public boolean isActive() { return active; }

java-ecosystem/libs/core/src/main/java/org/rostilos/codecrow/core/persistence/repository/workspace/WorkspaceMemberRepository.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import org.rostilos.codecrow.core.model.workspace.Workspace;
77
import org.rostilos.codecrow.core.model.workspace.WorkspaceMember;
8+
import org.springframework.data.jpa.repository.EntityGraph;
89
import org.springframework.data.jpa.repository.JpaRepository;
910
import org.springframework.data.jpa.repository.Modifying;
1011
import org.springframework.data.jpa.repository.Query;
@@ -15,6 +16,7 @@
1516
public interface WorkspaceMemberRepository extends JpaRepository<WorkspaceMember, Long> {
1617
Optional<WorkspaceMember> findByWorkspaceIdAndUserId(Long workspaceId, Long userId);
1718
java.util.List<WorkspaceMember> findByUser_Id(Long userId);
19+
@EntityGraph(attributePaths = "user")
1820
java.util.List<WorkspaceMember> findByWorkspace_Id(Long workspaceId);
1921
Long countByWorkspace_Id(Long workspaceId);
2022

@@ -25,4 +27,4 @@ public interface WorkspaceMemberRepository extends JpaRepository<WorkspaceMember
2527
@Query("SELECT wm.workspace FROM WorkspaceMember wm " +
2628
"WHERE wm.user.id = :userId AND wm.status = 'ACTIVE'")
2729
List<Workspace> findActiveWorkspacesByUserId(@Param("userId") Long userId);
28-
}
30+
}

java-ecosystem/libs/security/src/main/java/module-info.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,7 @@
2424
opens org.rostilos.codecrow.security.pipelineagent to spring.core, spring.beans, spring.context;
2525
opens org.rostilos.codecrow.security.pipelineagent.jwt to spring.core, spring.beans, spring.context;
2626
opens org.rostilos.codecrow.security.jwt.utils to spring.core, spring.beans, spring.context;
27+
opens org.rostilos.codecrow.security.service to spring.core, spring.beans, spring.context;
28+
opens org.rostilos.codecrow.security.web;
29+
opens org.rostilos.codecrow.security.web.jwt to spring.core, spring.beans, spring.context;
2730
}

java-ecosystem/libs/security/src/main/java/org/rostilos/codecrow/security/pipelineagent/PipelineAgentSecurityConfig.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import org.springframework.security.web.SecurityFilterChain;
1919
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
2020

21-
@Configuration
21+
@Configuration(proxyBeanMethods = false)
2222
@EnableMethodSecurity(securedEnabled = true, jsr250Enabled = true)
2323
public class PipelineAgentSecurityConfig {
2424
@Value("${codecrow.security.encryption-key}")
@@ -57,7 +57,7 @@ public ProjectInternalJwtFilter internalJwtFilter() {
5757
}
5858

5959
@Bean
60-
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
60+
public SecurityFilterChain filterChain(HttpSecurity http, ProjectInternalJwtFilter internalJwtFilter) throws Exception {
6161
http.csrf(csrf -> csrf.disable())
6262
.sessionManagement(session -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
6363
.authorizeHttpRequests(auth ->
@@ -70,7 +70,7 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
7070
);
7171

7272
// Register internal project-level JWT validator before username/password filter
73-
http.addFilterBefore(internalJwtFilter(), UsernamePasswordAuthenticationFilter.class);
73+
http.addFilterBefore(internalJwtFilter, UsernamePasswordAuthenticationFilter.class);
7474

7575
return http.build();
7676
}

java-ecosystem/libs/security/src/main/java/org/rostilos/codecrow/security/web/InternalApiSecurityFilter.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse
3737
FilterChain filterChain) throws ServletException, IOException {
3838
String requestUri = request.getRequestURI();
3939

40-
if (requestUri.startsWith(INTERNAL_API_PATH) || requestUri.startsWith(INTERNAL_PROJECTS_PATH)) {
40+
if (isInternalApiRequest(requestUri)) {
4141
if (!validateInternalSecret(request, response)) {
4242
return;
4343
}
@@ -46,6 +46,12 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse
4646
filterChain.doFilter(request, response);
4747
}
4848

49+
private boolean isInternalApiRequest(String requestUri) {
50+
return requestUri.startsWith(INTERNAL_API_PATH)
51+
|| requestUri.equals("/internal/projects")
52+
|| requestUri.startsWith(INTERNAL_PROJECTS_PATH);
53+
}
54+
4955
private boolean validateInternalSecret(HttpServletRequest request, HttpServletResponse response)
5056
throws IOException {
5157
if (internalApiSecret == null || internalApiSecret.isBlank()) {

java-ecosystem/libs/security/src/main/java/org/rostilos/codecrow/security/web/WebSecurityConfig.java

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import org.springframework.web.cors.CorsConfigurationSource;
2727
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
2828

29-
@Configuration
29+
@Configuration(proxyBeanMethods = false)
3030
@EnableMethodSecurity(securedEnabled = true, jsr250Enabled = true)
3131
public class WebSecurityConfig {
3232
@Value("${codecrow.security.encryption-key}")
@@ -57,15 +57,19 @@ public AuthTokenFilter authenticationJwtTokenFilter() {
5757
}
5858

5959
@Bean
60-
public DaoAuthenticationProvider authenticationProvider() {
60+
public DaoAuthenticationProvider authenticationProvider(PasswordEncoder passwordEncoder) {
6161
DaoAuthenticationProvider authProvider = new DaoAuthenticationProvider();
6262

6363
authProvider.setUserDetailsService(userDetailsService);
64-
authProvider.setPasswordEncoder(passwordEncoder());
64+
authProvider.setPasswordEncoder(passwordEncoder);
6565

6666
return authProvider;
6767
}
6868

69+
public DaoAuthenticationProvider authenticationProvider() {
70+
return authenticationProvider(passwordEncoder());
71+
}
72+
6973
@Bean
7074
public AuthenticationManager authenticationManager(AuthenticationConfiguration authConfig) throws Exception {
7175
return authConfig.getAuthenticationManager();
@@ -104,9 +108,14 @@ public CorsConfigurationSource corsConfigurationSource() {
104108
}
105109

106110
@Bean
107-
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
111+
public SecurityFilterChain filterChain(
112+
HttpSecurity http,
113+
CorsConfigurationSource corsConfigurationSource,
114+
DaoAuthenticationProvider authenticationProvider,
115+
AuthTokenFilter authTokenFilter
116+
) throws Exception {
108117
http.csrf(AbstractHttpConfigurer::disable)
109-
.cors(cors -> cors.configurationSource(corsConfigurationSource()))
118+
.cors(cors -> cors.configurationSource(corsConfigurationSource))
110119
.exceptionHandling(exception -> exception.authenticationEntryPoint(unauthorizedHandler))
111120
.sessionManagement(session -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
112121
// Allow framing from Bitbucket for Connect App configure page
@@ -133,6 +142,7 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
133142
// GitHub App webhooks (installation lifecycle, no user session)
134143
.requestMatchers("/api/integrations/*/app/webhook").permitAll()
135144
.requestMatchers("/actuator/**").permitAll()
145+
.requestMatchers("/internal/projects").permitAll()
136146
.requestMatchers("/internal/projects/**").permitAll()
137147
.requestMatchers("/api/internal/**").permitAll()
138148
.requestMatchers("/swagger-ui-custom.html").permitAll()
@@ -149,9 +159,9 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
149159
.requestMatchers("/api/webhooks/**").permitAll()
150160
.anyRequest().authenticated());
151161

152-
http.authenticationProvider(authenticationProvider());
162+
http.authenticationProvider(authenticationProvider);
153163

154-
http.addFilterBefore(authenticationJwtTokenFilter(), UsernamePasswordAuthenticationFilter.class);
164+
http.addFilterBefore(authTokenFilter, UsernamePasswordAuthenticationFilter.class);
155165

156166
return http.build();
157167
}

java-ecosystem/libs/test-support/src/main/java/org/rostilos/codecrow/testsupport/base/IntegrationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
/**
1212
* Meta-annotation for JPA/Repository integration tests.
1313
* <p>
14-
* Starts a shared Testcontainers PostgreSQL, uses create-drop DDL,
14+
* Starts a shared Testcontainers PostgreSQL, creates schema on context start,
1515
* activates the "it" profile.
1616
*/
1717
@Target(ElementType.TYPE)

0 commit comments

Comments
 (0)