diff --git a/README.md b/README.md index a3dbea1..6bc75f5 100644 --- a/README.md +++ b/README.md @@ -112,3 +112,8 @@ force ### Developer/deployer note. Because of caching, updated installations may not render properly. Manually request the "/main.xtml" resource and that should flush out stale info being used by "/main.jsf". + +Followup: Excess payloads were being added to the welcome page +that caused HTTP "400" errors fetching resources. A fix has +been made, although the ultimate solution will probably be more +JSF-friendly. diff --git a/pom.xml b/pom.xml index f59d9bb..42f6ef6 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ com.mousetech.gourmet gourmetj - 0.2.0 + 0.2.1 jar GourmetJ diff --git a/src/main/java/com/mousetech/gourmetj/SpringPrimeFacesApplication.java b/src/main/java/com/mousetech/gourmetj/SpringPrimeFacesApplication.java index 41e72e0..5db90e5 100644 --- a/src/main/java/com/mousetech/gourmetj/SpringPrimeFacesApplication.java +++ b/src/main/java/com/mousetech/gourmetj/SpringPrimeFacesApplication.java @@ -23,6 +23,7 @@ public class SpringPrimeFacesApplication { final String errorPage = "/error/error.html"; final String error404Page = "/error/error404.html"; + final String error400Page = "/error/error400.jsp"; final String expiredPage = "/main.xhtml"; public static void main(String[] args) { @@ -62,8 +63,10 @@ public class SpringPrimeFacesApplication { registry.addErrorPages(new ErrorPage( HttpStatus.INTERNAL_SERVER_ERROR, errorPage)); - } - + registry.addErrorPages(new ErrorPage( + HttpStatus.BAD_REQUEST, + error400Page)); + } }; } } diff --git a/src/main/java/com/mousetech/gourmetj/SpringSecurityConfig.java b/src/main/java/com/mousetech/gourmetj/SpringSecurityConfig.java index 63e83af..0962e36 100644 --- a/src/main/java/com/mousetech/gourmetj/SpringSecurityConfig.java +++ b/src/main/java/com/mousetech/gourmetj/SpringSecurityConfig.java @@ -105,7 +105,10 @@ public class SpringSecurityConfig { http .csrf(AbstractHttpConfigurer::disable) .cors(AbstractHttpConfigurer::disable) - .formLogin(Customizer.withDefaults()) + .formLogin(formLogin -> + formLogin + .loginPage("/login.xhtml") + .permitAll()) .authorizeHttpRequests((authorize)-> authorize .dispatcherTypeMatchers(DispatcherType.FORWARD, DispatcherType.ERROR).permitAll() .anyRequest().authenticated() @@ -121,10 +124,11 @@ public class SpringSecurityConfig { @Bean public WebSecurityCustomizer webSecurityCustomizer() { return (web) -> web.ignoring().requestMatchers( - "/javax.faces.resource/**", + "/jakarta.faces.resource/**", + "/index.xhtml", "/", "/index.jsf", - "/index.xhtml", + "/login", "/main.jsf", "/img/**", "/recipeDetails.jsf", diff --git a/src/main/java/com/mousetech/gourmetj/WelcomePageRedirect.java b/src/main/java/com/mousetech/gourmetj/WelcomePageRedirect.java index 6f09231..2390ea6 100644 --- a/src/main/java/com/mousetech/gourmetj/WelcomePageRedirect.java +++ b/src/main/java/com/mousetech/gourmetj/WelcomePageRedirect.java @@ -11,7 +11,7 @@ public class WelcomePageRedirect implements WebMvcConfigurer { @Override public void addViewControllers(ViewControllerRegistry registry) { registry.addViewController("/") - .setViewName("forward:/index.xhtml"); + .setViewName("forward:/index.html"); registry.setOrder(Ordered.HIGHEST_PRECEDENCE); } } diff --git a/src/main/resources/META-INF/resources/error/error400.jsp b/src/main/resources/META-INF/resources/error/error400.jsp new file mode 100644 index 0000000..43deba4 --- /dev/null +++ b/src/main/resources/META-INF/resources/error/error400.jsp @@ -0,0 +1,12 @@ +<%@ page language="java" contentType="text/html; charset=US-ASCII" + pageEncoding="US-ASCII" isErrorPage="true"%> + + + + +Error 400 Page - Bad request + + +Error: exception.getMessage()
+ + \ No newline at end of file diff --git a/src/main/resources/META-INF/resources/index.html b/src/main/resources/META-INF/resources/index.html new file mode 100644 index 0000000..daa0588 --- /dev/null +++ b/src/main/resources/META-INF/resources/index.html @@ -0,0 +1,24 @@ + + + +Gourmet Recipe Manager + +

Gourmet Recipe Manager

+

This is an implementation of Thomas Hinkle's + Gourmet Recipe Manager, originally a desktop + application but now available as a Java Web + application.

+

+ Go to Main Page

+
+

Copyright © 2021, 2024 Tim Holloway. All Rights Reserved. +

This is an open-source application under the + Common Development and Distribution License (CDDL). +

+
+ \ No newline at end of file diff --git a/src/main/resources/META-INF/resources/index.xhtml b/src/main/resources/META-INF/resources/index.xhtml deleted file mode 100644 index 7af4593..0000000 --- a/src/main/resources/META-INF/resources/index.xhtml +++ /dev/null @@ -1,26 +0,0 @@ - - - - Gourmet Recipe Manager - - - -

This is an implementation of Thomas Hinkle's - Gourmet Recipe Manager, originally a desktop - application but now available as a Java Web - application.

- Go to Main Page -
-
- -
-
-
\ No newline at end of file diff --git a/src/main/resources/META-INF/resources/login.xhtml b/src/main/resources/META-INF/resources/login.xhtml new file mode 100644 index 0000000..56b6a35 --- /dev/null +++ b/src/main/resources/META-INF/resources/login.xhtml @@ -0,0 +1,31 @@ + + + + + + Login + + + + + + + +

Please login

+ + + + + + + +
+ +
+
+