Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

Commit

Permalink
Merge pull request #117 from Opetushallitus/sb3
Browse files Browse the repository at this point in the history
OPHYK-107 upgrade to Spring Boot 3
  • Loading branch information
tokarls authored Dec 10, 2024
2 parents 15e325e + 656d777 commit 9de54b1
Show file tree
Hide file tree
Showing 58 changed files with 910 additions and 1,113 deletions.
17 changes: 16 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,21 @@ on:
pull_request:
jobs:
build:
services:
postgres:
image: postgres:15.7
ports:
- 5433:5432
env:
POSTGRES_USER: varda-rekisterointi
POSTGRES_DB: varda-rekisterointi
POSTGRES_PASSWORD: varda-rekisterointi
POSTGRES_HOST_AUTH_METHOD: trust
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -34,7 +49,7 @@ jobs:
restore-keys: ${{ runner.os }}-sonar
- name: Build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn clean install -B -Dbranch=$GITHUB_REF_NAME -Drevision=$GITHUB_SHA -DbuildNumber=$GITHUB_RUN_NUMBER/$GITHUB_RUN_ATTEMPT org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=Opetushallitus_varda-rekisterointi
- name: Upload varda-rekisterointi-jar
Expand Down
9 changes: 0 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ Below is non-exhaustive list of the key technologies & frameworks used in the pr
* Postgresql
* Flyway
* Lombok
* Swagger
* db-scheduler

### Frontend
Expand All @@ -36,14 +35,6 @@ Required tools for building the project:

Project includes maven wrapper so it doesn't have to be installed. Just use `./mvnw` (unix) and `mvnw.cmd` (win).

## Database

Create database by running:

docker run --name varda-rekisterointi-db -p 5432:5432 -e POSTGRES_USER=varda-rekisterointi -e POSTGRES_PASSWORD=varda-rekisterointi -e POSTGRES_DB=varda-rekisterointi -d postgres:10.9

This will start the container. Later, it can be started and stopped with `docker <start|stop> varda-rekisterointi-db`. Integration tests automatically start and stop a database server.

## Build

mvn package
Expand Down
26 changes: 22 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
version: '3'
services:
varda-rekisterointi-db:
image: postgres:10.9
database:
container_name: varda-rekisterointi-db
image: postgres:15.7
environment:
- POSTGRES_USER=varda-rekisterointi
- POSTGRES_PASSWORD=varda-rekisterointi
- POSTGRES_DB=varda-rekisterointi
ports:
- "5432:5432"
- "5432:5432"
command: ["postgres", "-c", "log_statement=all"]
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 10s
timeout: 5s
retries: 5
test-database:
container_name: varda-rekisterointi-test-db
image: postgres:15.7
environment:
- POSTGRES_USER=varda-rekisterointi
- POSTGRES_PASSWORD=varda-rekisterointi
- POSTGRES_DB=varda-rekisterointi
ports:
- "5433:5432"
command: ["postgres", "-c", "log_statement=all"]
volumes:
database-data:
2 changes: 0 additions & 2 deletions oph-configuration/varda-rekisterointi.yml.template
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ varda-rekisterointi:
ryhmaperhepaivakoti: {{ kayttooikeus_ryhma_ryhmaperhepaivakoti }}
perhepaivahoitaja: {{ kayttooikeus_ryhma_perhepaivahoitaja }}
jotpa: {{ kayttooikeus_ryhma_jotpa_paakayttaja }}
swagger:
enabled: {{ varda_rekisterointi_swagger_enabled | default('false') }}
rekisterointi-ui:
username: {{ varda_rekisterointi_rekisterointi_ui_username }}
password: {{ varda_rekisterointi_rekisterointi_ui_password }}
944 changes: 474 additions & 470 deletions package-lock.json

Large diffs are not rendered by default.

118 changes: 20 additions & 98 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.18</version>
<relativePath/> <!-- lookup parent from repository -->
<version>3.4.0</version>
<relativePath/>
</parent>
<groupId>fi.vm.sade.varda.rekisterointi</groupId>
<artifactId>varda-rekisterointi</artifactId>
Expand All @@ -15,9 +15,6 @@

<properties>
<java.version>21</java.version>
<git-commit-id-plugin.version>4.0.0</git-commit-id-plugin.version>
<springfox.version>3.0.0</springfox.version>
<swagger.version>1.6.6</swagger.version>
<sonar.organization>opetushallitus</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
<sonar.sources>src/main/java,src/frontend</sonar.sources>
Expand Down Expand Up @@ -59,11 +56,6 @@
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
Expand All @@ -72,21 +64,25 @@
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
</dependency>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-database-postgresql</artifactId>
</dependency>
<dependency>
<groupId>nz.net.ultraq.thymeleaf</groupId>
<artifactId>thymeleaf-layout-dialect</artifactId>
</dependency>
<dependency>
<groupId>com.github.kagkarlsson</groupId>
<artifactId>db-scheduler-spring-boot-starter</artifactId>
<version>11.2</version>
<version>14.1.0</version>
</dependency>

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.30</version>
<version>1.18.36</version>
</dependency>

<dependency>
<groupId>fi.vm.sade</groupId>
<artifactId>auditlogger</artifactId>
Expand All @@ -95,86 +91,49 @@
<dependency>
<groupId>fi.vm.sade.java-utils</groupId>
<artifactId>java-properties</artifactId>
<version>0.1.0-SNAPSHOT</version>
<version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fi.vm.sade.java-utils</groupId>
<artifactId>java-http</artifactId>
<version>0.5.0-SNAPSHOT</version>
<version>1.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fi.vm.sade.java-utils</groupId>
<artifactId>suomifi-valtuudet-client</artifactId>
<version>0.1.0-SNAPSHOT</version>
<version>1.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fi.vm.sade.java-utils</groupId>
<artifactId>opintopolku-user-details-service</artifactId>
<version>0.5.0-SNAPSHOT</version>
<version>0.5.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fi.vm.sade.java-utils</groupId>
<artifactId>opintopolku-cas-servlet-filter</artifactId>
<version>0.1.2-SNAPSHOT</version>
<version>1.0.1-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock-jre8-standalone</artifactId>
<version>2.35.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>2.2.220</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<version>2.2</version>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
<version>${springfox.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-bean-validators</artifactId>
<version>${springfox.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${springfox.version}</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>${swagger.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.wiremock</groupId>
<artifactId>wiremock-jetty12</artifactId>
<version>3.9.2</version>
<scope>test</scope>
</dependency>
</dependencies>

Expand Down Expand Up @@ -257,41 +216,4 @@
</snapshots>
</repository>
</repositories>

<profiles>
<profile>
<id>dev</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<configuration>
<mainClass>fi.vm.sade.varda.rekisterointi.Application</mainClass>
<systemProperties>
<systemProperty>
<key>spring.profiles.active</key>
<value>dev</value>
</systemProperty>
<systemProperty>
<key>spring.config.additional-location</key>
<value>src/main/resources/dev.yml</value>
</systemProperty>
<systemProperty>
<key>varda-rekisterointi.baseUrl</key>
<value>https://localhost:8081</value>
</systemProperty>
<systemProperty>
<key>baseUrl</key>
<value>https://virkailija.untuvaopintopolku.fi</value>
</systemProperty>
</systemProperties>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>
2 changes: 1 addition & 1 deletion src/frontend/hakija/RekisterointiAloitus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default function RekisterointiAloitus() {
<p>
<a
className={`oph-button oph-button-primary ${styles.varimuutos}`}
href="/varda-rekisterointi/hakija"
href="/varda-rekisterointi/hakija?login=true"
>
{i18n.translateWithLang('HAKIJA_ALOITA_REKISTEROITYMINEN', data.kieli)}
</a>
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/hakija/RekisterointiValmis.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default function RekisterointiValmis() {
></Fieldset>
<p>{i18n.translate('REKISTEROINNIN_KASITTELY_OHJE')}</p>
<div className={styles.center}>
<Image />
<img src={Image} />
</div>
</form>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,55 @@
package fi.vm.sade.varda.rekisterointi.configuration;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.core.annotation.Order;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.ProviderManager;
import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
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.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.provisioning.InMemoryUserDetailsManager;
import org.springframework.security.web.SecurityFilterChain;

import static fi.vm.sade.varda.rekisterointi.util.Constants.JOTPA_ROLE;
import static fi.vm.sade.varda.rekisterointi.util.Constants.PAAKAYTTAJA_AUTHORITY;
import static fi.vm.sade.varda.rekisterointi.util.Constants.VARDA_ROLE;
import static fi.vm.sade.varda.rekisterointi.util.Constants.VIRKAILIJA_ROLE;
import static fi.vm.sade.varda.rekisterointi.util.Constants.VIRKAILIJA_UI_ROLES;
import static fi.vm.sade.varda.rekisterointi.util.Constants.PAAKAYTTAJA_ROLE;

import static org.springframework.security.config.Customizer.withDefaults;

@Profile("dev")
@Configuration
@EnableWebSecurity
public class DevVirkailijaWebSecurityConfiguration extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.csrf().disable().authorizeRequests()
.antMatchers("/virkailija/**").permitAll()
.anyRequest().authenticated()
.and().exceptionHandling()
.and().httpBasic();
;
@EnableMethodSecurity(jsr250Enabled = false, prePostEnabled = true, securedEnabled = true)
public class DevVirkailijaWebSecurityConfiguration {
@Profile("dev")
@Bean
@Order(1)
SecurityFilterChain devVirkailijaSecurityFilterChain(HttpSecurity http) throws Exception {
return http
.headers(headers -> headers.disable())
.csrf(csrf -> csrf.disable())
.securityMatcher("/virkailija/**")
.authorizeHttpRequests(authz -> authz.anyRequest().authenticated())
.httpBasic(withDefaults())
.authenticationManager(authenticationManager())
.build();
}

AuthenticationManager authenticationManager() {
DaoAuthenticationProvider authenticationProvider = new DaoAuthenticationProvider();
authenticationProvider.setUserDetailsService(userDetailsService());
return new ProviderManager(authenticationProvider);
}

@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication()
.withUser("devaaja").password("{noop}devaaja")
.authorities(PAAKAYTTAJA_AUTHORITY);
}
UserDetailsService userDetailsService() {
UserDetails specialUser = User.withUsername("devaaja")
.password("{noop}devaaja")
.roles(PAAKAYTTAJA_ROLE)
.build();

return new InMemoryUserDetailsManager(specialUser);
}
}
Loading

0 comments on commit 9de54b1

Please sign in to comment.