Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion compose.yaml

This file was deleted.

41 changes: 1 addition & 40 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,5 @@
name: projekt-arendehantering

services:
app:
image: projekt-arendehantering:latest
container_name: projekt-arendehantering-app
ports:
- "8080:8080"
environment:
# Pick ONE DB profile when starting: --profile postgres OR --profile mysql
SPRING_DATASOURCE_URL: ${SPRING_DATASOURCE_URL:-jdbc:postgresql://postgres:5432/arende}
SPRING_DATASOURCE_USERNAME: ${SPRING_DATASOURCE_USERNAME:-arende}
SPRING_DATASOURCE_PASSWORD: ${SPRING_DATASOURCE_PASSWORD:-arende}
SPRING_JPA_HIBERNATE_DDL_AUTO: ${SPRING_JPA_HIBERNATE_DDL_AUTO:-update}
depends_on:
postgres:
condition: service_healthy
mysql:
condition: service_healthy

postgres:
postgresql:
image: postgres:17-alpine
container_name: projekt-arendehantering-postgres
profiles: ["postgres"]
Expand All @@ -36,26 +17,6 @@ services:
timeout: 3s
retries: 20

mysql:
image: mysql:9.4
container_name: projekt-arendehantering-mysql
profiles: ["mysql"]
environment:
MYSQL_DATABASE: arende
MYSQL_USER: arende
MYSQL_PASSWORD: arende
MYSQL_ROOT_PASSWORD: root
ports:
- "3306:3306"
volumes:
- mysql_data:/var/lib/mysql
healthcheck:
test: ["CMD-SHELL", "mysqladmin ping -h 127.0.0.1 -uroot -p$$MYSQL_ROOT_PASSWORD --silent"]
interval: 5s
timeout: 5s
retries: 30

volumes:
postgres_data:
mysql_data:

31 changes: 31 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,37 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
Comment on lines +67 to +70
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Spring Security will break existing header-based authentication.

The codebase uses HeaderCurrentUserAdapter which reads X-User-Id and X-Role headers for authentication. Adding spring-boot-starter-security without defining a custom SecurityFilterChain bean will:

  1. Enable HTTP Basic authentication by default
  2. Protect all endpoints (including /, /ui/cases, etc.)
  3. Override the existing header-based auth mechanism

You must provide a SecurityFilterChain bean that integrates with your header-based authentication or permits the appropriate endpoints.

💡 Example SecurityFilterChain to preserve header-based auth
`@Configuration`
`@EnableWebSecurity`
public class SecurityConfig {

    `@Bean`
    public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
        http
            .csrf(csrf -> csrf.disable()) // if using API headers
            .authorizeHttpRequests(auth -> auth
                .anyRequest().permitAll() // adjust as needed
            )
            .httpBasic(basic -> basic.disable());
        return http.build();
    }
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pom.xml` around lines 67 - 70, Adding spring-boot-starter-security will
enable default security and break header-based auth; add a SecurityFilterChain
bean to preserve HeaderCurrentUserAdapter behavior. Create a `@Configuration`
class (e.g., SecurityConfig) that declares a `@Bean` SecurityFilterChain
filterChain(HttpSecurity http) and configure it to disable httpBasic and CSRF
(if using API headers), and either permit the endpoints you want (e.g.,
anyRequest().permitAll()) or integrate with your header adapter by ensuring
requests with X-User-Id/X-Role are allowed; reference HeaderCurrentUserAdapter
when wiring any custom authentication logic so the new SecurityFilterChain does
not override the existing header-based mechanism.

<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webmvc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>annotationProcessor</scope>
</dependency>
Comment on lines +84 to +88
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Invalid Maven scope: annotationProcessor is not recognized.

The pipeline failure confirms that annotationProcessor is not a valid Maven dependency scope. Maven only allows: provided, compile, runtime, test, system.

For Lombok in Maven, use provided scope and configure annotation processing in the compiler plugin:

🐛 Proposed fix for Lombok configuration
         <dependency>
             <groupId>org.projectlombok</groupId>
             <artifactId>lombok</artifactId>
-            <scope>annotationProcessor</scope>
+            <scope>provided</scope>
         </dependency>

Additionally, configure the maven-compiler-plugin for annotation processing:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <annotationProcessorPaths>
                    <path>
                        <groupId>org.projectlombok</groupId>
                        <artifactId>lombok</artifactId>
                    </path>
                </annotationProcessorPaths>
            </configuration>
        </plugin>
        <!-- existing spring-boot-maven-plugin -->
    </plugins>
</build>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>annotationProcessor</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
🧰 Tools
🪛 GitHub Actions: CI Pipeline

[warning] 87-87: 'dependencies.dependency.scope' for org.projectlombok:lombok:jar must be one of [provided, compile, runtime, test, system] but is 'annotationProcessor'. @ line 87, column 20

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pom.xml` around lines 84 - 88, Replace the invalid Maven scope on the Lombok
dependency (artifactId lombok) from "annotationProcessor" to "provided", and add
configuration to the maven-compiler-plugin to enable annotation processing by
declaring lombok under annotationProcessorPaths so the compiler plugin can find
the Lombok annotation processor at build time.

<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-springsecurity6</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
8 changes: 8 additions & 0 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
spring.application.name=Projekt-arendehantering

spring.datasource.url=jdbc:postgresql://localhost:5432/arende
spring.datasource.username=arende
spring.datasource.password=arende

spring.jpa.hibernate.ddl-auto=update
spring.datasource.driver-class-name=org.postgresql.Driver
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect