diff --git a/pom.xml b/pom.xml index bb8d235..835d0aa 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ org.springframework.boot spring-boot-starter-parent - 3.0.0-M4 + 3.2.0-M3 @@ -47,11 +47,6 @@ spring-boot-starter-thymeleaf - - org.thymeleaf.extras - thymeleaf-extras-java8time - - org.webjars webjars-locator-core @@ -85,13 +80,6 @@ - - org.webjars - jquery - 3.6.1 - runtime - - org.webjars bootstrap @@ -109,20 +97,20 @@ io.github.wimdeblauwe htmx-spring-boot-thymeleaf - 2.0.0-M1 + 3.1.0 org.webjars.npm htmx.org - 1.8.2 + 1.9.6 runtime org.webjars.npm hyperscript.org - 0.9.7 + 0.9.11 runtime diff --git a/src/main/java/guestbook/Application.java b/src/main/java/guestbook/Application.java index b7d8e0c..2d0c2c0 100644 --- a/src/main/java/guestbook/Application.java +++ b/src/main/java/guestbook/Application.java @@ -22,7 +22,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; +import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.web.SecurityFilterChain; import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; @@ -75,7 +75,7 @@ CommandLineRunner init(GuestbookRepository guestbook) { * {@link WebMvcConfigurer} interface. */ @Configuration - @EnableGlobalMethodSecurity(prePostEnabled = true) + @EnableMethodSecurity(prePostEnabled = true) static class SecurityConfiguration implements WebMvcConfigurer { /* @@ -92,12 +92,11 @@ public void addViewControllers(ViewControllerRegistry registry) { @Bean public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { - http.csrf().disable(); - // Allow all requests on the URI level, configure form login. - http.authorizeRequests().anyRequest().permitAll() // - .and().formLogin() // - .and().logout().logoutSuccessUrl("/").clearAuthentication(true); + http.csrf(it -> it.disable()) + .authorizeHttpRequests(it -> it.anyRequest().permitAll()) + .formLogin(it -> {}) + .logout(it -> it.logoutSuccessUrl("/").clearAuthentication(true)); return http.build(); } diff --git a/src/main/java/guestbook/GuestbookController.java b/src/main/java/guestbook/GuestbookController.java index f2df447..b22cd41 100644 --- a/src/main/java/guestbook/GuestbookController.java +++ b/src/main/java/guestbook/GuestbookController.java @@ -15,8 +15,8 @@ */ package guestbook; -import io.github.wimdeblauwe.hsbt.mvc.HtmxResponse; -import io.github.wimdeblauwe.hsbt.mvc.HxRequest; +import io.github.wimdeblauwe.htmx.spring.boot.mvc.HtmxResponse; +import io.github.wimdeblauwe.htmx.spring.boot.mvc.HxRequest; import jakarta.validation.Valid; import java.util.Optional; @@ -149,9 +149,10 @@ HtmxResponse addEntry(@Valid GuestbookForm form, Model model) { model.addAttribute("entry", guestbook.save(form.toNewEntry())); model.addAttribute("index", guestbook.count()); - return new HtmxResponse() - .addTemplate("guestbook :: entry") - .addTrigger("eventAdded"); + return new HtmxResponse.Builder() + .view("guestbook :: entry") + .trigger("eventAdded") + .build(); } /** @@ -173,8 +174,9 @@ HtmxResponse removeEntryHtmx(@PathVariable Optional entry, Model model.addAttribute("entries", guestbook.findAll()); - return new HtmxResponse() - .addTemplate("guestbook :: entries"); + return new HtmxResponse.Builder() + .view("guestbook :: entries") + .build(); }).orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND)); } diff --git a/src/main/java/guestbook/GuestbookForm.java b/src/main/java/guestbook/GuestbookForm.java index 7ad5f67..cbc42b0 100644 --- a/src/main/java/guestbook/GuestbookForm.java +++ b/src/main/java/guestbook/GuestbookForm.java @@ -22,7 +22,8 @@ * particularly designed to also be able to capture invalid input, so that the raw form data can be bound and validated * against business constraints using code and / or annotations. *

- * Note how the fields are annotated with the {@link NotBlank} annotation, which tells Spring how to validate the values. + * Note how the fields are annotated with the {@link NotBlank} annotation, which tells Spring how to validate the + * values. * * @author Oliver Drotbohm * @see GuestbookController#addEntry(GuestbookForm, org.springframework.validation.Errors, org.springframework.ui.Model)