From e7cb56ce6aa7d6b5cc94b6d86c8aafd8beb67abf Mon Sep 17 00:00:00 2001 From: Marc Giffing Date: Sun, 4 Dec 2022 21:08:04 +0100 Subject: [PATCH 01/14] set version to 4.0.0-SNAPSHOT; set Java Version to 17 --- pom.xml | 12 +++++++----- wicket-spring-boot-context/pom.xml | 2 +- wicket-spring-boot-starter-example/pom.xml | 2 +- wicket-spring-boot-starter/pom.xml | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/pom.xml b/pom.xml index 7f122ce7..2eb16b8a 100644 --- a/pom.xml +++ b/pom.xml @@ -1,8 +1,10 @@ - + 4.0.0 com.giffing.wicket.spring.boot.starter wicket-spring-boot-starter-parent - 3.1.7 + 4.0.0-SNAPSHOT pom Wicket Spring Boot Starter Parent @@ -20,7 +22,7 @@ org.springframework.boot spring-boot-starter-parent - 2.7.5 + 3.0.0 @@ -50,7 +52,7 @@ UTF-8 - 11 + 17 1.8.0 9.12.0 9.12.0 @@ -316,6 +318,6 @@ - + diff --git a/wicket-spring-boot-context/pom.xml b/wicket-spring-boot-context/pom.xml index 8970b2fd..8f91de92 100644 --- a/wicket-spring-boot-context/pom.xml +++ b/wicket-spring-boot-context/pom.xml @@ -4,7 +4,7 @@ com.giffing.wicket.spring.boot.starter wicket-spring-boot-starter-parent - 3.1.7 + 4.0.0-SNAPSHOT wicket-spring-boot-context diff --git a/wicket-spring-boot-starter-example/pom.xml b/wicket-spring-boot-starter-example/pom.xml index df0d704a..b1f8c247 100644 --- a/wicket-spring-boot-starter-example/pom.xml +++ b/wicket-spring-boot-starter-example/pom.xml @@ -5,7 +5,7 @@ com.giffing.wicket.spring.boot.starter wicket-spring-boot-starter-parent - 3.1.7 + 4.0.0-SNAPSHOT .. diff --git a/wicket-spring-boot-starter/pom.xml b/wicket-spring-boot-starter/pom.xml index b0de8017..5dc97ef7 100644 --- a/wicket-spring-boot-starter/pom.xml +++ b/wicket-spring-boot-starter/pom.xml @@ -4,7 +4,7 @@ com.giffing.wicket.spring.boot.starter wicket-spring-boot-starter-parent - 3.1.7 + 4.0.0-SNAPSHOT .. From 5e4c02e165a3314f8beacce5cc1e9044f0c27468 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francesco=20Chicchiricc=C3=B2?= Date: Mon, 2 Jan 2023 16:09:29 +0100 Subject: [PATCH 02/14] Completing upgrade to Spring Boot 3 / Jakarta EE namespace --- pom.xml | 37 ++++++-- wicket-spring-boot-starter-example/pom.xml | 15 ++- .../spring/boot/example/model/Customer.java | 8 +- .../CustomerRepositoryServiceImpl.java | 18 ++-- .../action/panel/items/yesno/YesNoLink.java | 4 +- .../example/web/html/modal/YesNoModal.java | 18 +--- .../example/web/html/modal/YesNoPanel.html | 5 +- .../boot/example/web/pages/BasePage.java | 4 +- .../web/pages/errors/AccessDeniedPage.java | 2 +- .../example/web/pages/errors/ExpiredPage.java | 2 +- .../WicketWebSecurityAdapterConfig.java | 47 +++++---- .../boot/example/web/WicketBaseIntTest.java | 3 - .../boot/example/web/WicketBaseTest.java | 1 - .../example/web/WicketMockServletContext.java | 8 +- .../pages/customers/CustomerListIntTest.java | 95 +++++++++---------- .../pages/customers/CustomerListPageTest.java | 6 +- .../web/WicketWebApplicationConfig.java | 4 - .../src/test/resources/application.yml | 5 +- .../boot/starter/WicketAutoConfiguration.java | 3 +- .../WicketDependencyVersionChecker.java | 2 +- .../csrf/CsrfAttacksPreventionConfig.java | 22 +++-- .../csrf/CsrfAttacksPreventionProperties.java | 30 +++--- .../spring/security/SpringSecurityConfig.java | 14 +-- .../web/WicketWebInitializerProperties.java | 5 +- .../WicketWebInitializerAutoConfig.java | 1 - .../websocket/DummyWicketSessionResolver.java | 3 +- .../WicketServerEndpointConfigRegister.java | 12 +-- .../main/resources/META-INF/spring.factories | 5 +- ...ot.autoconfigure.AutoConfiguration.imports | 1 + 29 files changed, 181 insertions(+), 199 deletions(-) create mode 100644 wicket-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports diff --git a/pom.xml b/pom.xml index 2eb16b8a..738a5ab3 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ org.springframework.boot spring-boot-starter-parent - 3.0.0 + 3.0.1 @@ -54,10 +54,8 @@ UTF-8 17 1.8.0 - 9.12.0 - 9.12.0 - 5.3.0 - 2.16.0 + 10.0.0-M1-SNAPSHOT + 10.0.0-SNAPSHOT @@ -143,7 +141,7 @@ org.wicketstuff.htmlvalidator wicketstuff-htmlvalidator - 1.11 + ${wicketstuff.version} org.wicketstuff @@ -160,7 +158,7 @@ de.agilecoders.wicket.webjars wicket-webjars - 3.0.0-M3 + 3.0.6 @@ -277,7 +275,7 @@ - 11 + ${java.version} @@ -318,6 +316,27 @@ - + + + apache.snapshots.https + https://repository.apache.org/content/repositories/snapshots + + false + + + true + + + + sonatype + https://oss.sonatype.org/content/repositories/snapshots + + false + + + true + + + diff --git a/wicket-spring-boot-starter-example/pom.xml b/wicket-spring-boot-starter-example/pom.xml index b1f8c247..6129a38b 100644 --- a/wicket-spring-boot-starter-example/pom.xml +++ b/wicket-spring-boot-starter-example/pom.xml @@ -85,7 +85,7 @@ de.agilecoders.wicket jquery-selectors - 2.0.9 + 3.0.4 org.liquibase @@ -111,9 +111,8 @@ - org.hibernate + org.hibernate.orm hibernate-jpamodelgen - 5.0.5.Final provided @@ -161,7 +160,6 @@ org.apache.maven.plugins maven-release-plugin - 2.5.3 none @@ -182,8 +180,7 @@ maven-compiler-plugin - 1.8 - 1.8 + ${java.version} -proc:none @@ -207,9 +204,9 @@ - org.hibernate + org.hibernate.orm hibernate-jpamodelgen - 5.0.5.Final + ${hibernate.version} @@ -236,7 +233,7 @@ org.asciidoctor asciidoctor-maven-plugin - 1.5.2 + 2.2.2 output-html diff --git a/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/model/Customer.java b/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/model/Customer.java index 1dbc1c50..48fbda7c 100644 --- a/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/model/Customer.java +++ b/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/model/Customer.java @@ -2,10 +2,10 @@ import java.io.Serializable; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; import com.giffing.wicket.spring.boot.example.repository.Domain; diff --git a/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/repository/services/customer/CustomerRepositoryServiceImpl.java b/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/repository/services/customer/CustomerRepositoryServiceImpl.java index 5b1999d1..38e4a1b2 100644 --- a/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/repository/services/customer/CustomerRepositoryServiceImpl.java +++ b/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/repository/services/customer/CustomerRepositoryServiceImpl.java @@ -5,21 +5,17 @@ import java.util.List; import java.util.Optional; -import javax.annotation.Resource; -import javax.inject.Inject; -import javax.persistence.EntityManager; -import javax.persistence.TypedQuery; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Predicate; -import javax.persistence.criteria.Root; +import jakarta.annotation.Resource; +import jakarta.persistence.EntityManager; +import jakarta.persistence.TypedQuery; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.CriteriaQuery; +import jakarta.persistence.criteria.Predicate; +import jakarta.persistence.criteria.Root; import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Sort; import org.springframework.data.jpa.domain.Specification; -import org.springframework.stereotype.Component; import org.springframework.stereotype.Repository; -import org.springframework.transaction.annotation.Transactional; import com.giffing.wicket.spring.boot.example.model.Customer; import com.giffing.wicket.spring.boot.example.model.Customer_; diff --git a/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/web/general/action/panel/items/yesno/YesNoLink.java b/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/web/general/action/panel/items/yesno/YesNoLink.java index 4773f5df..d9c78f6c 100644 --- a/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/web/general/action/panel/items/yesno/YesNoLink.java +++ b/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/web/general/action/panel/items/yesno/YesNoLink.java @@ -25,9 +25,7 @@ protected void yesClicked(AjaxRequestTarget target) { } }; ((BasePage)getPage()).replaceDefaultModal(yesNoModal); - yesNoModal.showUnloadConfirmation(false); - yesNoModal.show(target); - + yesNoModal.open(target); } protected abstract void yesClicked(AjaxRequestTarget target); diff --git a/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/web/html/modal/YesNoModal.java b/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/web/html/modal/YesNoModal.java index a09ae078..14131d4d 100644 --- a/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/web/html/modal/YesNoModal.java +++ b/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/web/html/modal/YesNoModal.java @@ -1,21 +1,13 @@ package com.giffing.wicket.spring.boot.example.web.html.modal; import org.apache.wicket.ajax.AjaxRequestTarget; -import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow; -import org.apache.wicket.model.Model; +import org.apache.wicket.extensions.ajax.markup.html.modal.ModalDialog; -public abstract class YesNoModal extends ModalWindow { +public abstract class YesNoModal extends ModalDialog { public YesNoModal(String id) { super(id); - setMinimalHeight(200); - setMinimalWidth(400); - setInitialHeight(200); - setInitialWidth(400); - setAutoSize(false); - setTitle(Model.of("Are you sure?")); - String contentId = getContentId(); - YesNoPanel yesNoPanel = new YesNoPanel(contentId){ + YesNoPanel yesNoPanel = new YesNoPanel(CONTENT_ID){ @Override protected void yesClicked(AjaxRequestTarget target) { @@ -29,16 +21,12 @@ protected void noClicked(AjaxRequestTarget target) { }; setContent(yesNoPanel); - } protected void noClicked(AjaxRequestTarget target) { close(target); - } protected abstract void yesClicked(AjaxRequestTarget target); - - } diff --git a/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/web/html/modal/YesNoPanel.html b/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/web/html/modal/YesNoPanel.html index 9517acfc..86fcf1ad 100644 --- a/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/web/html/modal/YesNoPanel.html +++ b/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/web/html/modal/YesNoPanel.html @@ -1,4 +1,5 @@ + yes - no - \ No newline at end of file + no + diff --git a/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/web/pages/BasePage.java b/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/web/pages/BasePage.java index 28408939..6f77a99e 100644 --- a/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/web/pages/BasePage.java +++ b/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/web/pages/BasePage.java @@ -1,7 +1,7 @@ package com.giffing.wicket.spring.boot.example.web.pages; import org.apache.wicket.MarkupContainer; -import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow; +import org.apache.wicket.extensions.ajax.markup.html.modal.ModalDialog; import org.apache.wicket.markup.head.CssHeaderItem; import org.apache.wicket.markup.head.IHeaderResponse; import org.apache.wicket.markup.head.JavaScriptHeaderItem; @@ -34,7 +34,7 @@ private void initPage(){ add(defaultModal); } - public void replaceDefaultModal(ModalWindow newModal){ + public void replaceDefaultModal(ModalDialog newModal){ defaultModal.replaceWith(newModal); defaultModal = newModal; defaultModal.setOutputMarkupId(true); diff --git a/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/web/pages/errors/AccessDeniedPage.java b/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/web/pages/errors/AccessDeniedPage.java index 03294d8e..b1c64117 100644 --- a/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/web/pages/errors/AccessDeniedPage.java +++ b/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/web/pages/errors/AccessDeniedPage.java @@ -1,6 +1,6 @@ package com.giffing.wicket.spring.boot.example.web.pages.errors; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpServletResponse; import org.apache.wicket.request.http.WebResponse; import org.wicketstuff.annotation.mount.MountPath; diff --git a/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/web/pages/errors/ExpiredPage.java b/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/web/pages/errors/ExpiredPage.java index 30e95943..f1d0644d 100644 --- a/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/web/pages/errors/ExpiredPage.java +++ b/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/web/pages/errors/ExpiredPage.java @@ -1,6 +1,6 @@ package com.giffing.wicket.spring.boot.example.web.pages.errors; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpServletResponse; import org.apache.wicket.markup.html.WebPage; import org.apache.wicket.request.http.WebResponse; diff --git a/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/web/security/WicketWebSecurityAdapterConfig.java b/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/web/security/WicketWebSecurityAdapterConfig.java index 5e571b9b..423bebae 100644 --- a/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/web/security/WicketWebSecurityAdapterConfig.java +++ b/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/web/security/WicketWebSecurityAdapterConfig.java @@ -4,22 +4,23 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.security.authentication.AuthenticationManager; +import org.springframework.security.authentication.ProviderManager; +import org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration; 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.UserDetailsService; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; +import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.security.provisioning.InMemoryUserDetailsManager; import org.springframework.security.web.firewall.HttpFirewall; import org.springframework.security.web.firewall.StrictHttpFirewall; - -import com.giffing.wicket.spring.boot.starter.web.servlet.websocket.WicketSessionResolver; +import org.springframework.security.web.SecurityFilterChain; /** * Default Spring Boot Wicket security getting started configuration. Its only - * active if there is not other {@link WebSecurityConfigurerAdapter} present. - * + * active if there is not other {@link SecurityFilterChain} bean is present. + * * Holds hard coded users which should only be used to get started * * @author Marc Giffing @@ -27,28 +28,31 @@ */ @Configuration @EnableWebSecurity -public class WicketWebSecurityAdapterConfig extends WebSecurityConfigurerAdapter { - - @Override - protected void configure(HttpSecurity http) throws Exception { +public class WicketWebSecurityAdapterConfig { + + @ConditionalOnMissingBean + @Bean + public AuthenticationManager authenticationManager(AuthenticationConfiguration authenticationConfiguration) + throws Exception { + return authenticationConfiguration.getAuthenticationManager(); + } + + @ConditionalOnMissingBean + @Bean + public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { http .csrf().disable() - .authorizeRequests().antMatchers("/**").permitAll() + .authorizeHttpRequests().requestMatchers("/**").permitAll() .and().logout().permitAll(); http.headers().frameOptions().disable(); + return http.build(); } @Bean public static BCryptPasswordEncoder passwordEncoder() { - return new BCryptPasswordEncoder(); + return new BCryptPasswordEncoder(); } - - @Bean( name="authenticationManager") - @Override - public AuthenticationManager authenticationManagerBean() throws Exception { - return super.authenticationManagerBean(); - } - + @Bean //TODO Add Wicket Issue - problem with semicolon in wicket websocket url. Allow semicolon. public HttpFirewall allowUrlEncodedSlashHttpFirewall() { @@ -57,17 +61,18 @@ public HttpFirewall allowUrlEncodedSlashHttpFirewall() { return fw; } + @ConditionalOnMissingBean @Bean - public UserDetailsService userDetailsService() { + public UserDetailsService userDetailsService(final PasswordEncoder passwordEncoder) { InMemoryUserDetailsManager manager = new InMemoryUserDetailsManager(); manager.createUser( User.withUsername("admin") - .password(passwordEncoder().encode("admin")) + .password(passwordEncoder.encode("admin")) .authorities("USER", "ADMIN") .build()); manager.createUser( User.withUsername("customer") - .password(passwordEncoder().encode("customer")) + .password(passwordEncoder.encode("customer")) .authorities("USER", "ADMIN") .build()); return manager; diff --git a/wicket-spring-boot-starter-example/src/test/java/com/giffing/wicket/spring/boot/example/web/WicketBaseIntTest.java b/wicket-spring-boot-starter-example/src/test/java/com/giffing/wicket/spring/boot/example/web/WicketBaseIntTest.java index f3fb7837..92afa897 100644 --- a/wicket-spring-boot-starter-example/src/test/java/com/giffing/wicket/spring/boot/example/web/WicketBaseIntTest.java +++ b/wicket-spring-boot-starter-example/src/test/java/com/giffing/wicket/spring/boot/example/web/WicketBaseIntTest.java @@ -5,7 +5,6 @@ import org.apache.wicket.util.tester.WicketTester; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mockito; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @@ -13,7 +12,6 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Primary; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.test.context.junit.jupiter.SpringExtension; import com.giffing.wicket.spring.boot.example.WicketApplication; import com.giffing.wicket.spring.boot.example.web.pages.login.LoginPage; @@ -27,7 +25,6 @@ * @author Marc Giffing * */ -@ExtendWith(SpringExtension.class) @SpringBootTest(classes = WicketApplication.class) @EnableWebSecurity @Disabled diff --git a/wicket-spring-boot-starter-example/src/test/java/com/giffing/wicket/spring/boot/example/web/WicketBaseTest.java b/wicket-spring-boot-starter-example/src/test/java/com/giffing/wicket/spring/boot/example/web/WicketBaseTest.java index 41c94319..f9f4f633 100644 --- a/wicket-spring-boot-starter-example/src/test/java/com/giffing/wicket/spring/boot/example/web/WicketBaseTest.java +++ b/wicket-spring-boot-starter-example/src/test/java/com/giffing/wicket/spring/boot/example/web/WicketBaseTest.java @@ -15,7 +15,6 @@ import org.springframework.security.core.Authentication; import org.springframework.security.core.AuthenticationException; import org.springframework.test.context.junit.jupiter.SpringExtension; -import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.util.ReflectionTestUtils; import com.giffing.wicket.spring.boot.example.web.pages.home.HomePage; diff --git a/wicket-spring-boot-starter-example/src/test/java/com/giffing/wicket/spring/boot/example/web/WicketMockServletContext.java b/wicket-spring-boot-starter-example/src/test/java/com/giffing/wicket/spring/boot/example/web/WicketMockServletContext.java index 0a5e1748..ee92f189 100644 --- a/wicket-spring-boot-starter-example/src/test/java/com/giffing/wicket/spring/boot/example/web/WicketMockServletContext.java +++ b/wicket-spring-boot-starter-example/src/test/java/com/giffing/wicket/spring/boot/example/web/WicketMockServletContext.java @@ -1,10 +1,8 @@ package com.giffing.wicket.spring.boot.example.web; -import java.util.Arrays; -import java.util.HashSet; import java.util.Set; -import javax.servlet.SessionTrackingMode; +import jakarta.servlet.SessionTrackingMode; import org.apache.wicket.Application; import org.apache.wicket.protocol.http.mock.MockServletContext; @@ -17,12 +15,12 @@ public WicketMockServletContext(Application application, String path) { @Override public Set getDefaultSessionTrackingModes() { - return new HashSet<>(Arrays.asList( SessionTrackingMode.COOKIE )); + return Set.of(SessionTrackingMode.COOKIE); } @Override public Set getEffectiveSessionTrackingModes() { - return new HashSet<>(Arrays.asList( SessionTrackingMode.COOKIE )); + return Set.of(SessionTrackingMode.COOKIE); } } diff --git a/wicket-spring-boot-starter-example/src/test/java/com/giffing/wicket/spring/boot/example/web/pages/customers/CustomerListIntTest.java b/wicket-spring-boot-starter-example/src/test/java/com/giffing/wicket/spring/boot/example/web/pages/customers/CustomerListIntTest.java index 10c8c1a7..6f68d29a 100644 --- a/wicket-spring-boot-starter-example/src/test/java/com/giffing/wicket/spring/boot/example/web/pages/customers/CustomerListIntTest.java +++ b/wicket-spring-boot-starter-example/src/test/java/com/giffing/wicket/spring/boot/example/web/pages/customers/CustomerListIntTest.java @@ -1,69 +1,64 @@ package com.giffing.wicket.spring.boot.example.web.pages.customers; -import static org.assertj.core.api.Assertions.assertThat; import static org.hamcrest.CoreMatchers.equalTo; - +import static org.hamcrest.MatcherAssert.assertThat; import org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable; import org.apache.wicket.markup.repeater.Item; import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.annotation.Rollback; import org.springframework.transaction.annotation.Transactional; import com.giffing.wicket.spring.boot.example.model.Customer; -import com.giffing.wicket.spring.boot.example.repository.services.customer.CustomerRepositoryService; import com.giffing.wicket.spring.boot.example.repository.services.customer.filter.CustomerSort; import com.giffing.wicket.spring.boot.example.web.WicketBaseIntTest; import com.giffing.wicket.spring.boot.example.web.html.modal.YesNoModal; -import static org.hamcrest.MatcherAssert.assertThat; - @Transactional @Rollback public class CustomerListIntTest extends WicketBaseIntTest { - - @Autowired - private CustomerRepositoryService service; - - @Test - @SuppressWarnings({ "rawtypes", "unchecked" }) - public void assert_start_customer_list_page(){ - getTester().startPage(CustomerListPage.class); - getTester().assertRenderedPage(CustomerListPage.class); - getTester().assertComponent("filterForm:table", DataTable.class); - - DataTable dataTable = (DataTable) getTester().getComponentFromLastRenderedPage("filterForm:table"); - assertThat(dataTable.getItemCount(), equalTo(5L)); - //id, username, firstname, lastname, active, actions - assertThat(dataTable.getColumns().size(), equalTo(6)); - //get third row - Item item3 = (Item) getTester().getComponentFromLastRenderedPage("filterForm:table:body:rows:3"); - assertThat(item3.getModelObject().getId(), equalTo(3L)); - assertThat(item3.getModelObject().getUsername(), equalTo("adalgrim")); - - Item item5 = (Item) getTester().getComponentFromLastRenderedPage("filterForm:table:body:rows:5"); - assertThat(item5.getModelObject().getId(), equalTo(5L)); - assertThat(item5.getModelObject().getUsername(), equalTo("tuk")); - } - - @Test - public void assert_delete_customer_method_called_once(){ - getTester().startPage(CustomerListPage.class); - getTester().assertRenderedPage(CustomerListPage.class); - - DataTable dataTable = (DataTable) getTester().getComponentFromLastRenderedPage("filterForm:table"); - assertThat(dataTable.getItemCount(), equalTo(5L)); - - getTester().clickLink(getTableCell(5, 6) + "items:1:item:link"); - getTester().assertComponent("defaultModal", YesNoModal.class); - getTester().clickLink("defaultModal:content:yes", true); - - assertThat(dataTable.getItemCount(), equalTo(4L)); - - } - - private String getTableCell(int row, int cell){ - return "filterForm:table:body:rows:" + row + ":cells:" + cell + ":cell:"; - } + + @Test + @SuppressWarnings({ "rawtypes", "unchecked" }) + public void assert_start_customer_list_page() { + getTester().startPage(CustomerListPage.class); + getTester().assertRenderedPage(CustomerListPage.class); + getTester().assertComponent("filterForm:table", DataTable.class); + + DataTable dataTable = (DataTable) getTester().getComponentFromLastRenderedPage( + "filterForm:table"); + assertThat(dataTable.getItemCount(), equalTo(5L)); + //id, username, firstname, lastname, active, actions + assertThat(dataTable.getColumns().size(), equalTo(6)); + //get third row + Item item3 = (Item) getTester().getComponentFromLastRenderedPage("filterForm:table:body:rows:3"); + assertThat(item3.getModelObject().getId(), equalTo(3L)); + assertThat(item3.getModelObject().getUsername(), equalTo("adalgrim")); + + Item item5 = (Item) getTester().getComponentFromLastRenderedPage("filterForm:table:body:rows:5"); + assertThat(item5.getModelObject().getId(), equalTo(5L)); + assertThat(item5.getModelObject().getUsername(), equalTo("tuk")); + } + + @Test + public void assert_delete_customer_method_called_once() { + getTester().startPage(CustomerListPage.class); + getTester().assertRenderedPage(CustomerListPage.class); + + @SuppressWarnings("unchecked") + DataTable dataTable = (DataTable) getTester().getComponentFromLastRenderedPage( + "filterForm:table"); + assertThat(dataTable.getItemCount(), equalTo(5L)); + + getTester().clickLink(getTableCell(5, 6) + "items:1:item:link"); + getTester().assertComponent("defaultModal", YesNoModal.class); + getTester().clickLink("defaultModal:overlay:dialog:content:yes", true); + + assertThat(dataTable.getItemCount(), equalTo(4L)); + + } + + private String getTableCell(int row, int cell) { + return "filterForm:table:body:rows:" + row + ":cells:" + cell + ":cell:"; + } } diff --git a/wicket-spring-boot-starter-example/src/test/java/com/giffing/wicket/spring/boot/example/web/pages/customers/CustomerListPageTest.java b/wicket-spring-boot-starter-example/src/test/java/com/giffing/wicket/spring/boot/example/web/pages/customers/CustomerListPageTest.java index 6515e3bd..caf746b5 100644 --- a/wicket-spring-boot-starter-example/src/test/java/com/giffing/wicket/spring/boot/example/web/pages/customers/CustomerListPageTest.java +++ b/wicket-spring-boot-starter-example/src/test/java/com/giffing/wicket/spring/boot/example/web/pages/customers/CustomerListPageTest.java @@ -1,6 +1,7 @@ package com.giffing.wicket.spring.boot.example.web.pages.customers; import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -9,7 +10,6 @@ import org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable; import org.apache.wicket.markup.repeater.Item; -import static org.hamcrest.MatcherAssert.assertThat; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.Mockito; @@ -90,7 +90,7 @@ public void assert_delete_customer_method_called_once(){ getTester().clickLink(getTableCell(5, 6) + "items:1:item:link"); getTester().assertComponent("defaultModal", YesNoModal.class); - getTester().clickLink("defaultModal:content:yes", true); + getTester().clickLink("defaultModal:overlay:dialog:content:yes", true); verify(repository, times(1)).delete(Mockito.anyLong()); verify(repository, times(1)).delete(5L); @@ -111,7 +111,7 @@ public static List createCustomers(long count) { public static Customer createCustomer(long i) { Customer customer = new Customer(); - customer.setId(Long.valueOf(i)); + customer.setId(i); customer.setUsername("username" + i); customer.setFirstname("firstname" + i); customer.setLastname("lastname" + i); diff --git a/wicket-spring-boot-starter-example/src/test/java/test/com/giffing/wicket/spring/boot/example/web/WicketWebApplicationConfig.java b/wicket-spring-boot-starter-example/src/test/java/test/com/giffing/wicket/spring/boot/example/web/WicketWebApplicationConfig.java index c981b193..146428ac 100644 --- a/wicket-spring-boot-starter-example/src/test/java/test/com/giffing/wicket/spring/boot/example/web/WicketWebApplicationConfig.java +++ b/wicket-spring-boot-starter-example/src/test/java/test/com/giffing/wicket/spring/boot/example/web/WicketWebApplicationConfig.java @@ -9,7 +9,6 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; import org.springframework.context.annotation.ComponentScan; -import org.springframework.session.jdbc.config.annotation.web.http.EnableJdbcHttpSession; import org.springframework.transaction.annotation.EnableTransactionManagement; import com.giffing.wicket.spring.boot.example.WicketApplication; @@ -52,7 +51,4 @@ protected Class getWebSessionClass() return SecureWebSession.class; } - - - } diff --git a/wicket-spring-boot-starter-example/src/test/resources/application.yml b/wicket-spring-boot-starter-example/src/test/resources/application.yml index 2cd30b83..6aa78caf 100644 --- a/wicket-spring-boot-starter-example/src/test/resources/application.yml +++ b/wicket-spring-boot-starter-example/src/test/resources/application.yml @@ -10,4 +10,7 @@ wicket: stuff: serializer: fast2: - enabled: false \ No newline at end of file + enabled: false + core: + csrf: + enabled: false diff --git a/wicket-spring-boot-starter/src/main/java/com/giffing/wicket/spring/boot/starter/WicketAutoConfiguration.java b/wicket-spring-boot-starter/src/main/java/com/giffing/wicket/spring/boot/starter/WicketAutoConfiguration.java index 2489d5a2..1866fd24 100644 --- a/wicket-spring-boot-starter/src/main/java/com/giffing/wicket/spring/boot/starter/WicketAutoConfiguration.java +++ b/wicket-spring-boot-starter/src/main/java/com/giffing/wicket/spring/boot/starter/WicketAutoConfiguration.java @@ -5,7 +5,6 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; -import com.giffing.wicket.spring.boot.starter.app.classscanner.ClassCandidateScanner; import com.giffing.wicket.spring.boot.starter.app.classscanner.ClassCandidateScannerConfiguration; import com.giffing.wicket.spring.boot.starter.app.verifier.WicketDependencyVersionChecker; import com.giffing.wicket.spring.boot.starter.configuration.CustomAnnotationBeanNameGenerator; @@ -15,7 +14,7 @@ /** * The main starter configuration class which will be called by spring. - * The class is configured in META-INF/spring.factories + * The class is configured in META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports * * @author Marc Giffing * diff --git a/wicket-spring-boot-starter/src/main/java/com/giffing/wicket/spring/boot/starter/app/verifier/WicketDependencyVersionChecker.java b/wicket-spring-boot-starter/src/main/java/com/giffing/wicket/spring/boot/starter/app/verifier/WicketDependencyVersionChecker.java index 41b1364e..a98d4239 100644 --- a/wicket-spring-boot-starter/src/main/java/com/giffing/wicket/spring/boot/starter/app/verifier/WicketDependencyVersionChecker.java +++ b/wicket-spring-boot-starter/src/main/java/com/giffing/wicket/spring/boot/starter/app/verifier/WicketDependencyVersionChecker.java @@ -5,7 +5,7 @@ import java.util.List; import java.util.Properties; -import javax.annotation.PostConstruct; +import jakarta.annotation.PostConstruct; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/wicket-spring-boot-starter/src/main/java/com/giffing/wicket/spring/boot/starter/configuration/extensions/core/csrf/CsrfAttacksPreventionConfig.java b/wicket-spring-boot-starter/src/main/java/com/giffing/wicket/spring/boot/starter/configuration/extensions/core/csrf/CsrfAttacksPreventionConfig.java index b3152290..50221755 100644 --- a/wicket-spring-boot-starter/src/main/java/com/giffing/wicket/spring/boot/starter/configuration/extensions/core/csrf/CsrfAttacksPreventionConfig.java +++ b/wicket-spring-boot-starter/src/main/java/com/giffing/wicket/spring/boot/starter/configuration/extensions/core/csrf/CsrfAttacksPreventionConfig.java @@ -1,6 +1,8 @@ package com.giffing.wicket.spring.boot.starter.configuration.extensions.core.csrf; -import org.apache.wicket.protocol.http.CsrfPreventionRequestCycleListener; +import org.apache.wicket.protocol.http.FetchMetadataResourceIsolationPolicy; +import org.apache.wicket.protocol.http.OriginResourceIsolationPolicy; +import org.apache.wicket.protocol.http.ResourceIsolationRequestCycleListener; import org.apache.wicket.protocol.http.WebApplication; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; @@ -28,7 +30,7 @@ */ @ApplicationInitExtension @ConditionalOnProperty(prefix = CsrfAttacksPreventionProperties.PROPERTY_PREFIX, value = "enabled", matchIfMissing = true) -@ConditionalOnClass(value = org.apache.wicket.protocol.http.CsrfPreventionRequestCycleListener.class) +@ConditionalOnClass(value = org.apache.wicket.protocol.http.ResourceIsolationRequestCycleListener.class) @EnableConfigurationProperties({ CsrfAttacksPreventionProperties.class }) public class CsrfAttacksPreventionConfig implements WicketApplicationInitConfiguration{ @@ -40,15 +42,17 @@ public class CsrfAttacksPreventionConfig implements WicketApplicationInitConfigu @Override public void init(WebApplication webApplication) { - CsrfPreventionRequestCycleListener listener = new CsrfPreventionRequestCycleListener(); - listener.setConflictingOriginAction(props.getConflictingOriginAction()); + OriginResourceIsolationPolicy originResourceIsolationPolicy = new OriginResourceIsolationPolicy(); + props.getAcceptedOrigins().forEach(originResourceIsolationPolicy::addAcceptedOrigin); + + ResourceIsolationRequestCycleListener listener = new ResourceIsolationRequestCycleListener( + new FetchMetadataResourceIsolationPolicy(), + originResourceIsolationPolicy); + listener.setUnknownOutcomeAction(props.gtUnknownOutcomeAction()); + listener.setDisallowedOutcomeAction(props.getDisallowedOutcomeAction()); listener.setErrorCode(props.getErrorCode()); listener.setErrorMessage(props.getErrorMessage()); - listener.setNoOriginAction(props.getNoOriginAction()); - for (String acceptedOrigin : props.getAcceptedOrigins()) { - listener.addAcceptedOrigin(acceptedOrigin); - } - webApplication.getRequestCycleListeners().add(listener); + webApplication.getRequestCycleListeners().add(listener); wicketEndpointRepository.add(new WicketAutoConfig.Builder(this.getClass()) .withDetail("properties", props) diff --git a/wicket-spring-boot-starter/src/main/java/com/giffing/wicket/spring/boot/starter/configuration/extensions/core/csrf/CsrfAttacksPreventionProperties.java b/wicket-spring-boot-starter/src/main/java/com/giffing/wicket/spring/boot/starter/configuration/extensions/core/csrf/CsrfAttacksPreventionProperties.java index e6781481..0f43e2f2 100644 --- a/wicket-spring-boot-starter/src/main/java/com/giffing/wicket/spring/boot/starter/configuration/extensions/core/csrf/CsrfAttacksPreventionProperties.java +++ b/wicket-spring-boot-starter/src/main/java/com/giffing/wicket/spring/boot/starter/configuration/extensions/core/csrf/CsrfAttacksPreventionProperties.java @@ -3,7 +3,7 @@ import java.util.ArrayList; import java.util.List; -import org.apache.wicket.protocol.http.CsrfPreventionRequestCycleListener.CsrfAction; +import org.apache.wicket.protocol.http.ResourceIsolationRequestCycleListener.CsrfAction; import org.springframework.boot.context.properties.ConfigurationProperties; @ConfigurationProperties(prefix = CsrfAttacksPreventionProperties.PROPERTY_PREFIX) @@ -12,20 +12,22 @@ public class CsrfAttacksPreventionProperties { public static final String PROPERTY_PREFIX = "wicket.core.csrf"; /** - * Action to perform when no Origin header is present in the request. + * Action to perform when a request is disallowed by a resource isolation policy. + * Default is {@link CsrfAction#ABORT}. */ - private CsrfAction noOriginAction = CsrfAction.ALLOW; + private CsrfAction disallowedOutcomeAction = CsrfAction.ABORT; /** - * Action to perform when a conflicting Origin header is found. + * Action to perform when none of the resource isolation policies can come to an outcome. + * Default is {@link CsrfAction#ABORT}. */ - private CsrfAction conflictingOriginAction = CsrfAction.ABORT; + private CsrfAction unknownOutcomeAction = CsrfAction.ABORT; /** * The error code to report when the action to take for a CSRF request is * {@link CsrfAction#ABORT}. Default {@code 400 BAD REQUEST}. */ - private int errorCode = javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST; + private int errorCode = jakarta.servlet.http.HttpServletResponse.SC_BAD_REQUEST; /** * The error message to report when the action to take for a CSRF request is {@code ERROR}. @@ -52,20 +54,20 @@ public void setEnabled(boolean enabled) { this.enabled = enabled; } - public CsrfAction getNoOriginAction() { - return noOriginAction; + public CsrfAction getDisallowedOutcomeAction() { + return disallowedOutcomeAction; } - public void setNoOriginAction(CsrfAction noOriginAction) { - this.noOriginAction = noOriginAction; + public void setDisallowedOutcomeAction(CsrfAction disallowedOutcomeAction) { + this.disallowedOutcomeAction = disallowedOutcomeAction; } - public CsrfAction getConflictingOriginAction() { - return conflictingOriginAction; + public CsrfAction gtUnknownOutcomeAction() { + return unknownOutcomeAction; } - public void setConflictingOriginAction(CsrfAction conflictingOriginAction) { - this.conflictingOriginAction = conflictingOriginAction; + public void setUnknownOutcomeAction(CsrfAction unknownOutcomeAction) { + this.unknownOutcomeAction = unknownOutcomeAction; } public int getErrorCode() { diff --git a/wicket-spring-boot-starter/src/main/java/com/giffing/wicket/spring/boot/starter/configuration/extensions/external/spring/security/SpringSecurityConfig.java b/wicket-spring-boot-starter/src/main/java/com/giffing/wicket/spring/boot/starter/configuration/extensions/external/spring/security/SpringSecurityConfig.java index b5820139..1c2346bc 100644 --- a/wicket-spring-boot-starter/src/main/java/com/giffing/wicket/spring/boot/starter/configuration/extensions/external/spring/security/SpringSecurityConfig.java +++ b/wicket-spring-boot-starter/src/main/java/com/giffing/wicket/spring/boot/starter/configuration/extensions/external/spring/security/SpringSecurityConfig.java @@ -1,6 +1,5 @@ package com.giffing.wicket.spring.boot.starter.configuration.extensions.external.spring.security; -import org.apache.wicket.authroles.authentication.AbstractAuthenticatedWebSession; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; @@ -17,13 +16,12 @@ @ConditionalOnClass(value = { org.apache.wicket.authroles.authentication.AbstractAuthenticatedWebSession.class, org.springframework.security.core.Authentication.class, - org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter.class + org.springframework.security.web.SecurityFilterChain.class }) @EnableConfigurationProperties({ SpringSecurityProperties.class }) @ConditionalOnMissingBean(WicketBootWebApplication.class) public class SpringSecurityConfig { - @Bean public WicketBootSecuredWebApplication wicketBootWebApplication() { return new WicketBootSecuredWebApplication(); @@ -31,14 +29,6 @@ public WicketBootSecuredWebApplication wicketBootWebApplication() { @Bean public AuthenticatedWebSessionConfig authenticatedWebSessionConfig(){ - return new AuthenticatedWebSessionConfig() { - - @Override - public Class getAuthenticatedWebSessionClass() { - return SecureWebSession.class; - } - }; + return () -> SecureWebSession.class; } - - } diff --git a/wicket-spring-boot-starter/src/main/java/com/giffing/wicket/spring/boot/starter/web/WicketWebInitializerProperties.java b/wicket-spring-boot-starter/src/main/java/com/giffing/wicket/spring/boot/starter/web/WicketWebInitializerProperties.java index e6a1bd9e..8252abac 100644 --- a/wicket-spring-boot-starter/src/main/java/com/giffing/wicket/spring/boot/starter/web/WicketWebInitializerProperties.java +++ b/wicket-spring-boot-starter/src/main/java/com/giffing/wicket/spring/boot/starter/web/WicketWebInitializerProperties.java @@ -1,11 +1,10 @@ package com.giffing.wicket.spring.boot.starter.web; -import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; -import javax.servlet.DispatcherType; +import jakarta.servlet.DispatcherType; import org.springframework.boot.context.properties.ConfigurationProperties; @@ -19,7 +18,7 @@ public class WicketWebInitializerProperties { // Adds possibility to add init parameters dynamically private Map initParameters = new HashMap<>(); - private List dispatcherTypes = Arrays.asList( DispatcherType.REQUEST, DispatcherType.ERROR, DispatcherType.ASYNC ); + private List dispatcherTypes = List.of( DispatcherType.REQUEST, DispatcherType.ERROR, DispatcherType.ASYNC ); private boolean filterMatchAfter; diff --git a/wicket-spring-boot-starter/src/main/java/com/giffing/wicket/spring/boot/starter/web/config/WicketWebInitializerAutoConfig.java b/wicket-spring-boot-starter/src/main/java/com/giffing/wicket/spring/boot/starter/web/config/WicketWebInitializerAutoConfig.java index 9b49bd58..02c5819b 100644 --- a/wicket-spring-boot-starter/src/main/java/com/giffing/wicket/spring/boot/starter/web/config/WicketWebInitializerAutoConfig.java +++ b/wicket-spring-boot-starter/src/main/java/com/giffing/wicket/spring/boot/starter/web/config/WicketWebInitializerAutoConfig.java @@ -3,7 +3,6 @@ import org.apache.wicket.Application; import org.apache.wicket.protocol.ws.javax.JavaxWebSocketFilter; import org.apache.wicket.protocol.ws.javax.WicketServerEndpointConfig; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; diff --git a/wicket-spring-boot-starter/src/main/java/com/giffing/wicket/spring/boot/starter/web/servlet/websocket/DummyWicketSessionResolver.java b/wicket-spring-boot-starter/src/main/java/com/giffing/wicket/spring/boot/starter/web/servlet/websocket/DummyWicketSessionResolver.java index a4dd5388..cef83916 100644 --- a/wicket-spring-boot-starter/src/main/java/com/giffing/wicket/spring/boot/starter/web/servlet/websocket/DummyWicketSessionResolver.java +++ b/wicket-spring-boot-starter/src/main/java/com/giffing/wicket/spring/boot/starter/web/servlet/websocket/DummyWicketSessionResolver.java @@ -1,13 +1,12 @@ package com.giffing.wicket.spring.boot.starter.web.servlet.websocket; -import java.util.Arrays; import java.util.List; public class DummyWicketSessionResolver implements WicketSessionResolver { @Override public List resolve(Object value) { - return Arrays.asList(); + return List.of(); } } diff --git a/wicket-spring-boot-starter/src/main/java/com/giffing/wicket/spring/boot/starter/web/servlet/websocket/WicketServerEndpointConfigRegister.java b/wicket-spring-boot-starter/src/main/java/com/giffing/wicket/spring/boot/starter/web/servlet/websocket/WicketServerEndpointConfigRegister.java index 2dae8ddd..f8b4dd34 100644 --- a/wicket-spring-boot-starter/src/main/java/com/giffing/wicket/spring/boot/starter/web/servlet/websocket/WicketServerEndpointConfigRegister.java +++ b/wicket-spring-boot-starter/src/main/java/com/giffing/wicket/spring/boot/starter/web/servlet/websocket/WicketServerEndpointConfigRegister.java @@ -1,11 +1,11 @@ package com.giffing.wicket.spring.boot.starter.web.servlet.websocket; -import javax.servlet.ServletContext; -import javax.servlet.ServletContextEvent; -import javax.servlet.ServletContextListener; -import javax.websocket.DeploymentException; -import javax.websocket.Endpoint; -import javax.websocket.server.ServerContainer; +import jakarta.servlet.ServletContext; +import jakarta.servlet.ServletContextEvent; +import jakarta.servlet.ServletContextListener; +import jakarta.websocket.DeploymentException; +import jakarta.websocket.Endpoint; +import jakarta.websocket.server.ServerContainer; import org.apache.wicket.protocol.ws.javax.WicketServerEndpointConfig; diff --git a/wicket-spring-boot-starter/src/main/resources/META-INF/spring.factories b/wicket-spring-boot-starter/src/main/resources/META-INF/spring.factories index 01c36617..f343bdfa 100644 --- a/wicket-spring-boot-starter/src/main/resources/META-INF/spring.factories +++ b/wicket-spring-boot-starter/src/main/resources/META-INF/spring.factories @@ -1,6 +1,3 @@ -# AutoConfigurations -org.springframework.boot.autoconfigure.EnableAutoConfiguration=com.giffing.wicket.spring.boot.starter.WicketAutoConfiguration - org.springframework.boot.env.EnvironmentPostProcessor=com.giffing.wicket.spring.boot.starter.configuration.extensions.external.development.springboot.devtools.WicketDevToolsPropertyDefaultsPostProcessor -org.springframework.boot.diagnostics.FailureAnalyzer=com.giffing.wicket.spring.boot.starter.app.verifier.WicketDependencyVersionCheckerFailureAnalyzer \ No newline at end of file +org.springframework.boot.diagnostics.FailureAnalyzer=com.giffing.wicket.spring.boot.starter.app.verifier.WicketDependencyVersionCheckerFailureAnalyzer diff --git a/wicket-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/wicket-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 00000000..bd3fab22 --- /dev/null +++ b/wicket-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +com.giffing.wicket.spring.boot.starter.WicketAutoConfiguration From 9ea913df09f86dd6fd9c93df7a19a9a1721d0c54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francesco=20Chicchiricc=C3=B2?= Date: Sat, 7 Jan 2023 17:31:17 +0100 Subject: [PATCH 03/14] Fixing Spring Secuity Session persistence across requests --- .../web/security/WicketWebSecurityAdapterConfig.java | 2 +- .../wicket/spring/boot/example/web/WicketBaseIntTest.java | 8 +------- .../boot/starter/app/WicketBootSecuredWebApplication.java | 3 +-- .../external/spring/security/SecureWebSession.java | 6 +----- 4 files changed, 4 insertions(+), 15 deletions(-) diff --git a/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/web/security/WicketWebSecurityAdapterConfig.java b/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/web/security/WicketWebSecurityAdapterConfig.java index 423bebae..a6d79df4 100644 --- a/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/web/security/WicketWebSecurityAdapterConfig.java +++ b/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/web/security/WicketWebSecurityAdapterConfig.java @@ -4,7 +4,6 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.security.authentication.AuthenticationManager; -import org.springframework.security.authentication.ProviderManager; import org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; @@ -41,6 +40,7 @@ public AuthenticationManager authenticationManager(AuthenticationConfiguration a @Bean public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { http + .securityContext(ctx -> ctx.requireExplicitSave(false)) .csrf().disable() .authorizeHttpRequests().requestMatchers("/**").permitAll() .and().logout().permitAll(); diff --git a/wicket-spring-boot-starter-example/src/test/java/com/giffing/wicket/spring/boot/example/web/WicketBaseIntTest.java b/wicket-spring-boot-starter-example/src/test/java/com/giffing/wicket/spring/boot/example/web/WicketBaseIntTest.java index 92afa897..934da472 100644 --- a/wicket-spring-boot-starter-example/src/test/java/com/giffing/wicket/spring/boot/example/web/WicketBaseIntTest.java +++ b/wicket-spring-boot-starter-example/src/test/java/com/giffing/wicket/spring/boot/example/web/WicketBaseIntTest.java @@ -4,14 +4,12 @@ import org.apache.wicket.util.tester.FormTester; import org.apache.wicket.util.tester.WicketTester; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; import org.mockito.Mockito; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Primary; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import com.giffing.wicket.spring.boot.example.WicketApplication; import com.giffing.wicket.spring.boot.example.web.pages.login.LoginPage; @@ -26,9 +24,7 @@ * */ @SpringBootTest(classes = WicketApplication.class) -@EnableWebSecurity -@Disabled -public class WicketBaseIntTest { +public abstract class WicketBaseIntTest { private static final String USERNAME = "admin"; private static final String PASSWORD = "admin"; @@ -47,8 +43,6 @@ public WebSocketMessageBroadcaster webSocketMessageBroadcaster() { } } - - @BeforeEach public void setUp() { tester = new WicketTester(wicketApplication, new WicketMockServletContext(wicketApplication, null)); diff --git a/wicket-spring-boot-starter/src/main/java/com/giffing/wicket/spring/boot/starter/app/WicketBootSecuredWebApplication.java b/wicket-spring-boot-starter/src/main/java/com/giffing/wicket/spring/boot/starter/app/WicketBootSecuredWebApplication.java index 9fcdcc14..488f0d45 100644 --- a/wicket-spring-boot-starter/src/main/java/com/giffing/wicket/spring/boot/starter/app/WicketBootSecuredWebApplication.java +++ b/wicket-spring-boot-starter/src/main/java/com/giffing/wicket/spring/boot/starter/app/WicketBootSecuredWebApplication.java @@ -44,8 +44,7 @@ */ public class WicketBootSecuredWebApplication extends AuthenticatedWebApplication implements WicketBootWebApplication { - private final static Logger logger = LoggerFactory - .getLogger(WicketBootStandardWebApplication.class); + private final static Logger logger = LoggerFactory.getLogger(WicketBootStandardWebApplication.class); @Autowired private ApplicationContext applicationContext; diff --git a/wicket-spring-boot-starter/src/main/java/com/giffing/wicket/spring/boot/starter/configuration/extensions/external/spring/security/SecureWebSession.java b/wicket-spring-boot-starter/src/main/java/com/giffing/wicket/spring/boot/starter/configuration/extensions/external/spring/security/SecureWebSession.java index 720817d3..b75b5808 100644 --- a/wicket-spring-boot-starter/src/main/java/com/giffing/wicket/spring/boot/starter/configuration/extensions/external/spring/security/SecureWebSession.java +++ b/wicket-spring-boot-starter/src/main/java/com/giffing/wicket/spring/boot/starter/configuration/extensions/external/spring/security/SecureWebSession.java @@ -12,7 +12,6 @@ import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.core.Authentication; import org.springframework.security.core.AuthenticationException; -import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.web.context.HttpSessionSecurityContextRepository; @@ -32,7 +31,6 @@ public class SecureWebSession extends AuthenticatedWebSession implements Seriali @SpringBean(name = "authenticationManager") private AuthenticationManager authenticationManager; - public SecureWebSession(Request request) { super(request); Injector.get().inject(this); @@ -62,9 +60,7 @@ public Roles getRoles() { Roles roles = new Roles(); if (isSignedIn()) { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); - for (GrantedAuthority authority : authentication.getAuthorities()) { - roles.add(authority.getAuthority()); - } + authentication.getAuthorities().forEach(authority -> roles.add(authority.getAuthority())); } return roles; } From 8e99e902dddc366f8aa4f93e106a2559e55542ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francesco=20Chicchiricc=C3=B2?= Date: Sun, 8 Jan 2023 06:50:46 +0100 Subject: [PATCH 04/14] Fix formatting --- .../web/security/WicketWebSecurityAdapterConfig.java | 11 +++++------ .../core/csrf/CsrfAttacksPreventionProperties.java | 4 ++-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/web/security/WicketWebSecurityAdapterConfig.java b/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/web/security/WicketWebSecurityAdapterConfig.java index a6d79df4..278a2be1 100644 --- a/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/web/security/WicketWebSecurityAdapterConfig.java +++ b/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/web/security/WicketWebSecurityAdapterConfig.java @@ -30,12 +30,11 @@ public class WicketWebSecurityAdapterConfig { @ConditionalOnMissingBean - @Bean - public AuthenticationManager authenticationManager(AuthenticationConfiguration authenticationConfiguration) - throws Exception { - return authenticationConfiguration.getAuthenticationManager(); - } - + @Bean + public AuthenticationManager authenticationManager(AuthenticationConfiguration authenticationConfiguration) throws Exception { + return authenticationConfiguration.getAuthenticationManager(); + } + @ConditionalOnMissingBean @Bean public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { diff --git a/wicket-spring-boot-starter/src/main/java/com/giffing/wicket/spring/boot/starter/configuration/extensions/core/csrf/CsrfAttacksPreventionProperties.java b/wicket-spring-boot-starter/src/main/java/com/giffing/wicket/spring/boot/starter/configuration/extensions/core/csrf/CsrfAttacksPreventionProperties.java index 0f43e2f2..98437016 100644 --- a/wicket-spring-boot-starter/src/main/java/com/giffing/wicket/spring/boot/starter/configuration/extensions/core/csrf/CsrfAttacksPreventionProperties.java +++ b/wicket-spring-boot-starter/src/main/java/com/giffing/wicket/spring/boot/starter/configuration/extensions/core/csrf/CsrfAttacksPreventionProperties.java @@ -13,13 +13,13 @@ public class CsrfAttacksPreventionProperties { /** * Action to perform when a request is disallowed by a resource isolation policy. - * Default is {@link CsrfAction#ABORT}. + * Default is {@link CsrfAction#ABORT}. */ private CsrfAction disallowedOutcomeAction = CsrfAction.ABORT; /** * Action to perform when none of the resource isolation policies can come to an outcome. - * Default is {@link CsrfAction#ABORT}. + * Default is {@link CsrfAction#ABORT}. */ private CsrfAction unknownOutcomeAction = CsrfAction.ABORT; From ef8f478e65546d8b2d4306eaf8ac3595bc1b6b16 Mon Sep 17 00:00:00 2001 From: Marc Giffing Date: Thu, 12 Jan 2023 20:39:29 +0100 Subject: [PATCH 05/14] fix wrong javadoc reference --- .../extensions/core/csrf/CsrfAttacksPreventionConfig.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wicket-spring-boot-starter/src/main/java/com/giffing/wicket/spring/boot/starter/configuration/extensions/core/csrf/CsrfAttacksPreventionConfig.java b/wicket-spring-boot-starter/src/main/java/com/giffing/wicket/spring/boot/starter/configuration/extensions/core/csrf/CsrfAttacksPreventionConfig.java index 50221755..698980ad 100644 --- a/wicket-spring-boot-starter/src/main/java/com/giffing/wicket/spring/boot/starter/configuration/extensions/core/csrf/CsrfAttacksPreventionConfig.java +++ b/wicket-spring-boot-starter/src/main/java/com/giffing/wicket/spring/boot/starter/configuration/extensions/core/csrf/CsrfAttacksPreventionConfig.java @@ -18,11 +18,11 @@ /** * Enables CSRF protection if the following condition matches. * - * 1. The {@link CsrfPreventionRequestCycleListener} class is in the classpath. + * 1. The {@link ResourceIsolationRequestCycleListener} class is in the classpath. * * 2. The property {@link CsrfAttacksPreventionProperties#PROPERTY_PREFIX}.enabled has to be true (default = true) * - * The protection should be enabled by default cause the {@link CsrfPreventionRequestCycleListener} is located + * The protection should be enabled by default cause the {@link ResourceIsolationRequestCycleListener} is located * in Wickets core project. * * @author Marc Giffing From 5b6793f95a204845db7cd21235a9363e36d660bb Mon Sep 17 00:00:00 2001 From: Marc Giffing Date: Thu, 12 Jan 2023 20:42:42 +0100 Subject: [PATCH 06/14] removed distribution management from wicket-spring-boot-starter --- wicket-spring-boot-starter/pom.xml | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/wicket-spring-boot-starter/pom.xml b/wicket-spring-boot-starter/pom.xml index 5dc97ef7..9221e6c6 100644 --- a/wicket-spring-boot-starter/pom.xml +++ b/wicket-spring-boot-starter/pom.xml @@ -187,18 +187,6 @@ - - - apache.snapshots - Apache Development Snapshot Repository - https://repository.apache.org/content/repositories/snapshots/ - - - ossrh - https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/ - - - From 8c3bc29d2b03c103d727a2707bf6c50a60240c03 Mon Sep 17 00:00:00 2001 From: Marc Giffing Date: Tue, 27 Jun 2023 20:58:43 +0200 Subject: [PATCH 07/14] upgrade dependencies spring-boot-starter-parent -> 3.0.8 wicket -> 10.0.0-M1 wicket-webjars -> 3.0.7 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 738a5ab3..d5a7f2f7 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ org.springframework.boot spring-boot-starter-parent - 3.0.1 + 3.0.8 @@ -54,7 +54,7 @@ UTF-8 17 1.8.0 - 10.0.0-M1-SNAPSHOT + 10.0.0-M1 10.0.0-SNAPSHOT @@ -158,7 +158,7 @@ de.agilecoders.wicket.webjars wicket-webjars - 3.0.6 + 3.0.7 From f3a239d0d023621eb6539571a253aa2eeeeb4d43 Mon Sep 17 00:00:00 2001 From: Marc Giffing Date: Sun, 16 Jul 2023 20:14:44 +0200 Subject: [PATCH 08/14] upgrade dependencies wicketstuff -> 10.0.0-M1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d5a7f2f7..e7f0240d 100644 --- a/pom.xml +++ b/pom.xml @@ -55,7 +55,7 @@ 17 1.8.0 10.0.0-M1 - 10.0.0-SNAPSHOT + 10.0.0-M1 From f08bd0344a9bc1852653dd326c1304d03a0d6252 Mon Sep 17 00:00:00 2001 From: Marc Giffing Date: Sun, 16 Jul 2023 20:20:29 +0200 Subject: [PATCH 09/14] prepare release 4.0.0-M1 --- pom.xml | 2 +- wicket-spring-boot-context/pom.xml | 2 +- wicket-spring-boot-starter-example/pom.xml | 2 +- wicket-spring-boot-starter/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index e7f0240d..9c327a8b 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 com.giffing.wicket.spring.boot.starter wicket-spring-boot-starter-parent - 4.0.0-SNAPSHOT + 4.0.0-M1 pom Wicket Spring Boot Starter Parent diff --git a/wicket-spring-boot-context/pom.xml b/wicket-spring-boot-context/pom.xml index 8f91de92..af4ee98f 100644 --- a/wicket-spring-boot-context/pom.xml +++ b/wicket-spring-boot-context/pom.xml @@ -4,7 +4,7 @@ com.giffing.wicket.spring.boot.starter wicket-spring-boot-starter-parent - 4.0.0-SNAPSHOT + 4.0.0-M1 wicket-spring-boot-context diff --git a/wicket-spring-boot-starter-example/pom.xml b/wicket-spring-boot-starter-example/pom.xml index 6129a38b..bc70a92e 100644 --- a/wicket-spring-boot-starter-example/pom.xml +++ b/wicket-spring-boot-starter-example/pom.xml @@ -5,7 +5,7 @@ com.giffing.wicket.spring.boot.starter wicket-spring-boot-starter-parent - 4.0.0-SNAPSHOT + 4.0.0-M1 .. diff --git a/wicket-spring-boot-starter/pom.xml b/wicket-spring-boot-starter/pom.xml index 9221e6c6..1152c202 100644 --- a/wicket-spring-boot-starter/pom.xml +++ b/wicket-spring-boot-starter/pom.xml @@ -4,7 +4,7 @@ com.giffing.wicket.spring.boot.starter wicket-spring-boot-starter-parent - 4.0.0-SNAPSHOT + 4.0.0-M1 .. From f2fd78bb2882b365e4372d3f50b36170787314a7 Mon Sep 17 00:00:00 2001 From: Marc Giffing Date: Sun, 16 Jul 2023 20:30:14 +0200 Subject: [PATCH 10/14] upgrade plugins maven-gpg-plugin -> 3.0.1 nexus-staging-maven-plugin -> 1.6.13 --- pom.xml | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/pom.xml b/pom.xml index 9c327a8b..a324f331 100644 --- a/pom.xml +++ b/pom.xml @@ -240,7 +240,7 @@ org.apache.maven.plugins maven-gpg-plugin - 1.6 + 3.0.1 sign-artifacts @@ -294,20 +294,11 @@ - - - - org.apache.maven.plugins - maven-release-plugin - 2.5.3 - - - org.sonatype.plugins nexus-staging-maven-plugin - 1.6.8 + 1.6.13 true ossrh From 22ea715c9e3616d6b7658cc3b1b08478b1dafe7e Mon Sep 17 00:00:00 2001 From: Marc Giffing Date: Sun, 16 Jul 2023 20:33:49 +0200 Subject: [PATCH 11/14] prepare release --- wicket-spring-boot-starter/pom.xml | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/wicket-spring-boot-starter/pom.xml b/wicket-spring-boot-starter/pom.xml index 1152c202..f441c029 100644 --- a/wicket-spring-boot-starter/pom.xml +++ b/wicket-spring-boot-starter/pom.xml @@ -188,20 +188,6 @@ - - - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.8 - true - - ossrh - https://s01.oss.sonatype.org/ - true - - - - src/main/resources From 77e0f1827ba1dadd9218b7f252b410983dbd83f2 Mon Sep 17 00:00:00 2001 From: Marc Giffing Date: Fri, 22 Mar 2024 19:58:24 +0100 Subject: [PATCH 12/14] Upgrade to Spring Boot 3.2 and Wicket 10 and Java 17 #196 --- pom.xml | 13 ++- wicket-spring-boot-context/pom.xml | 2 +- wicket-spring-boot-starter-example/pom.xml | 13 ++- .../SpringSecurityWicketSessionResolver.java | 11 +- .../WicketWebSecurityAdapterConfig.java | 109 +++++++++--------- .../boot/example/web/WicketBaseIntTest.java | 9 +- wicket-spring-boot-starter/pom.xml | 2 +- 7 files changed, 87 insertions(+), 72 deletions(-) diff --git a/pom.xml b/pom.xml index a324f331..59c3ca0d 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 com.giffing.wicket.spring.boot.starter wicket-spring-boot-starter-parent - 4.0.0-M1 + 4.0.0 pom Wicket Spring Boot Starter Parent @@ -22,7 +22,7 @@ org.springframework.boot spring-boot-starter-parent - 3.0.8 + 3.2.4 @@ -54,8 +54,8 @@ UTF-8 17 1.8.0 - 10.0.0-M1 - 10.0.0-M1 + 10.0.0 + 10.0.0 @@ -203,6 +203,11 @@ wicket-source 9.0.0 + + org.apache.wicket + wicket-tester + ${wicket.version} + org.wicketstuff diff --git a/wicket-spring-boot-context/pom.xml b/wicket-spring-boot-context/pom.xml index af4ee98f..c575df0d 100644 --- a/wicket-spring-boot-context/pom.xml +++ b/wicket-spring-boot-context/pom.xml @@ -4,7 +4,7 @@ com.giffing.wicket.spring.boot.starter wicket-spring-boot-starter-parent - 4.0.0-M1 + 4.0.0 wicket-spring-boot-context diff --git a/wicket-spring-boot-starter-example/pom.xml b/wicket-spring-boot-starter-example/pom.xml index bc70a92e..10817e06 100644 --- a/wicket-spring-boot-starter-example/pom.xml +++ b/wicket-spring-boot-starter-example/pom.xml @@ -5,7 +5,7 @@ com.giffing.wicket.spring.boot.starter wicket-spring-boot-starter-parent - 4.0.0-M1 + 4.0.0 .. @@ -73,6 +73,10 @@ de.agilecoders.wicket.webjars wicket-webjars + + jakarta.xml.bind + jakarta.xml.bind-api + org.wicketstuff wicketstuff-serializer-fast2 @@ -85,7 +89,7 @@ de.agilecoders.wicket jquery-selectors - 3.0.4 + 4.0.2 org.liquibase @@ -109,6 +113,11 @@ spring-boot-starter-test test + + org.apache.wicket + wicket-tester + test + org.hibernate.orm diff --git a/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/web/security/SpringSecurityWicketSessionResolver.java b/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/web/security/SpringSecurityWicketSessionResolver.java index 0d7a0ef1..21338b7c 100644 --- a/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/web/security/SpringSecurityWicketSessionResolver.java +++ b/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/web/security/SpringSecurityWicketSessionResolver.java @@ -1,14 +1,13 @@ package com.giffing.wicket.spring.boot.example.web.security; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - +import com.giffing.wicket.spring.boot.starter.web.servlet.websocket.WicketSessionResolver; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.session.FindByIndexNameSessionRepository; import org.springframework.session.Session; -import com.giffing.wicket.spring.boot.starter.web.servlet.websocket.WicketSessionResolver; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; public class SpringSecurityWicketSessionResolver implements WicketSessionResolver { @@ -18,7 +17,7 @@ public class SpringSecurityWicketSessionResolver implements WicketSessionResolve @Override public List resolve(Object identifier) { Map findByPrincipalName = sessions.findByPrincipalName(identifier.toString()); - return findByPrincipalName.keySet().stream().collect(Collectors.toList()); + return new ArrayList<>(findByPrincipalName.keySet()); } } diff --git a/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/web/security/WicketWebSecurityAdapterConfig.java b/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/web/security/WicketWebSecurityAdapterConfig.java index 278a2be1..97d49c45 100644 --- a/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/web/security/WicketWebSecurityAdapterConfig.java +++ b/wicket-spring-boot-starter-example/src/main/java/com/giffing/wicket/spring/boot/example/web/security/WicketWebSecurityAdapterConfig.java @@ -7,6 +7,9 @@ import org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration; 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.configurers.AbstractHttpConfigurer; +import org.springframework.security.config.annotation.web.configurers.HeadersConfigurer; +import org.springframework.security.config.annotation.web.configurers.LogoutConfigurer; import org.springframework.security.core.userdetails.User; import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; @@ -19,67 +22,67 @@ /** * Default Spring Boot Wicket security getting started configuration. Its only * active if there is not other {@link SecurityFilterChain} bean is present. - * + *

* Holds hard coded users which should only be used to get started - * - * @author Marc Giffing * + * @author Marc Giffing */ @Configuration @EnableWebSecurity public class WicketWebSecurityAdapterConfig { - @ConditionalOnMissingBean - @Bean - public AuthenticationManager authenticationManager(AuthenticationConfiguration authenticationConfiguration) throws Exception { - return authenticationConfiguration.getAuthenticationManager(); - } - - @ConditionalOnMissingBean - @Bean - public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { - http - .securityContext(ctx -> ctx.requireExplicitSave(false)) - .csrf().disable() - .authorizeHttpRequests().requestMatchers("/**").permitAll() - .and().logout().permitAll(); - http.headers().frameOptions().disable(); - return http.build(); - } - - @Bean - public static BCryptPasswordEncoder passwordEncoder() { - return new BCryptPasswordEncoder(); - } + @ConditionalOnMissingBean + @Bean + public AuthenticationManager authenticationManager(AuthenticationConfiguration authenticationConfiguration) throws Exception { + return authenticationConfiguration.getAuthenticationManager(); + } + + @ConditionalOnMissingBean + @Bean + public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { + return http + .securityContext(ctx -> ctx.requireExplicitSave(false)) + .csrf(AbstractHttpConfigurer::disable) + .authorizeHttpRequests(authorizeHttpRequests -> + authorizeHttpRequests.requestMatchers("/**").permitAll()) + .logout(LogoutConfigurer::permitAll) + .headers(headers -> headers.frameOptions(HeadersConfigurer.FrameOptionsConfig::disable)) + .build(); + } + + @Bean + public static BCryptPasswordEncoder passwordEncoder() { + return new BCryptPasswordEncoder(); + } + + @Bean + //TODO Add Wicket Issue - problem with semicolon in wicket websocket url. Allow semicolon. + public HttpFirewall allowUrlEncodedSlashHttpFirewall() { + StrictHttpFirewall fw = new StrictHttpFirewall(); + fw.setAllowSemicolon(true); + return fw; + } - @Bean - //TODO Add Wicket Issue - problem with semicolon in wicket websocket url. Allow semicolon. - public HttpFirewall allowUrlEncodedSlashHttpFirewall() { - StrictHttpFirewall fw = new StrictHttpFirewall(); - fw.setAllowSemicolon(true); - return fw; - } + @ConditionalOnMissingBean + @Bean + public UserDetailsService userDetailsService(final PasswordEncoder passwordEncoder) { + InMemoryUserDetailsManager manager = new InMemoryUserDetailsManager(); + manager.createUser( + User.withUsername("admin") + .password(passwordEncoder.encode("admin")) + .authorities("USER", "ADMIN") + .build()); + manager.createUser( + User.withUsername("customer") + .password(passwordEncoder.encode("customer")) + .authorities("USER", "ADMIN") + .build()); + return manager; + } - @ConditionalOnMissingBean - @Bean - public UserDetailsService userDetailsService(final PasswordEncoder passwordEncoder) { - InMemoryUserDetailsManager manager = new InMemoryUserDetailsManager(); - manager.createUser( - User.withUsername("admin") - .password(passwordEncoder.encode("admin")) - .authorities("USER", "ADMIN") - .build()); - manager.createUser( - User.withUsername("customer") - .password(passwordEncoder.encode("customer")) - .authorities("USER", "ADMIN") - .build()); - return manager; - } - - //@Bean - //public WicketSessionResolver springSecurityWicketSessionResolver() { - // return new SpringSecurityWicketSessionResolver(); - //} + //@Bean + //public WicketSessionResolver springSecurityWicketSessionResolver() { + // return new SpringSecurityWicketSessionResolver(); + //} } diff --git a/wicket-spring-boot-starter-example/src/test/java/com/giffing/wicket/spring/boot/example/web/WicketBaseIntTest.java b/wicket-spring-boot-starter-example/src/test/java/com/giffing/wicket/spring/boot/example/web/WicketBaseIntTest.java index 934da472..c7af303c 100644 --- a/wicket-spring-boot-starter-example/src/test/java/com/giffing/wicket/spring/boot/example/web/WicketBaseIntTest.java +++ b/wicket-spring-boot-starter-example/src/test/java/com/giffing/wicket/spring/boot/example/web/WicketBaseIntTest.java @@ -1,5 +1,9 @@ package com.giffing.wicket.spring.boot.example.web; +import com.giffing.wicket.spring.boot.example.WicketApplication; +import com.giffing.wicket.spring.boot.example.web.pages.login.LoginPage; +import com.giffing.wicket.spring.boot.starter.configuration.extensions.external.spring.security.SecureWebSession; +import com.giffing.wicket.spring.boot.starter.web.servlet.websocket.WebSocketMessageBroadcaster; import org.apache.wicket.protocol.http.WebApplication; import org.apache.wicket.util.tester.FormTester; import org.apache.wicket.util.tester.WicketTester; @@ -11,11 +15,6 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Primary; -import com.giffing.wicket.spring.boot.example.WicketApplication; -import com.giffing.wicket.spring.boot.example.web.pages.login.LoginPage; -import com.giffing.wicket.spring.boot.starter.configuration.extensions.external.spring.security.SecureWebSession; -import com.giffing.wicket.spring.boot.starter.web.servlet.websocket.WebSocketMessageBroadcaster; - /** * Test class for initialize Wicket & Spring Boot only in the web package. All * external spring beans have to be mocked. diff --git a/wicket-spring-boot-starter/pom.xml b/wicket-spring-boot-starter/pom.xml index f441c029..80ffb650 100644 --- a/wicket-spring-boot-starter/pom.xml +++ b/wicket-spring-boot-starter/pom.xml @@ -4,7 +4,7 @@ com.giffing.wicket.spring.boot.starter wicket-spring-boot-starter-parent - 4.0.0-M1 + 4.0.0 .. From e929d52712d730fc7376dd09d49dcd5bd2257b45 Mon Sep 17 00:00:00 2001 From: Marc Giffing Date: Fri, 22 Mar 2024 20:00:57 +0100 Subject: [PATCH 13/14] Upgrade to Spring Boot 3.2 and Wicket 10 and Java 17 #196 --- README.adoc | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/README.adoc b/README.adoc index 10e21f99..94b48ead 100644 --- a/README.adoc +++ b/README.adoc @@ -2,11 +2,7 @@ Current release version: -* 3.1.x - http://wicket.apache.org/[Wicket 9.x] with Spring Boot 2.6.1 - Branch master -* 3.0.x - http://wicket.apache.org/[Wicket 9.x] with Spring Boot 2.1 - Branch master (deprecated) -* 2.1.x - http://wicket.apache.org/[Wicket 8.x] with Spring Boot 2 - Branch wicket-8 -* 2.0.x - http://wicket.apache.org/[Wicket 8.x] with Spring Boot 1 - Branch wicket-8 -* 1.x.x - http://wicket.apache.org/[Wicket 7.x] with Spring Boot 1 - Branch wicket-7 +* 4.0.x - http://wicket.apache.org/[Wicket 10.x] with Spring Boot 3.2.x - Branch master NOTE: http://search.maven.org/#search|ga|1|com.giffing.wicket.spring.boot From e5c96a52da548a0a189e8f38230461095ab1e876 Mon Sep 17 00:00:00 2001 From: MarcGiffing Date: Fri, 22 Mar 2024 20:12:09 +0100 Subject: [PATCH 14/14] Update maven.yml --- .github/workflows/maven.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 55b6b20d..1816002d 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -21,10 +21,10 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Set up JDK 11 + - name: Set up JDK 17 uses: actions/setup-java@v3 with: - java-version: '11' + java-version: '17' distribution: 'temurin' cache: maven - name: Build with Maven