This repository has been archived by the owner on Jan 10, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #117 from Opetushallitus/sb3
OPHYK-107 upgrade to Spring Boot 3
- Loading branch information
Showing
58 changed files
with
910 additions
and
1,113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 42 additions & 23 deletions
65
...a/fi/vm/sade/varda/rekisterointi/configuration/DevVirkailijaWebSecurityConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
Oops, something went wrong.