Fix broken login flow in shiro-basic example (#545)

The example was unusable: every request redirected to Shiro's default
loginUrl of /login.jsp, which does not exist here, producing an infinite
redirect loop. shiro.ini defined only [users] and [roles], so no filter
chain was configured and Shiro protected every path including the login
page and the form it posts to. Because shiroFilter is mapped for FORWARD
as well as REQUEST, the JSPs the Struts actions forward to were caught
too, so listing only the actions would not have been enough.

Adds a [main] section pointing authc at the login action, and a [urls]
chain leaving the login path anonymous while protecting the rest.

Separately, the container rewrote redirect URLs as ...;jsessionid=... on
a visitor's first request, and Jetty 11 rejects its own rewritten URI
with HTTP 400 Invalid request. Restricting session tracking to cookies
stops the rewriting.

Verified in a browser and over HTTP: login as lonestarr renders the
welcome page with roles and permissions resolved, logout returns to the
login page, and welcome.action is no longer reachable afterwards.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2 files changed
tree: 29076e0bf7b89148d72ace57bb71b3ce779fa19b
  1. .github/
  2. .mvn/
  3. action-chaining/
  4. annotations/
  5. basic-struts/
  6. bean-validation/
  7. blank/
  8. coding-actions/
  9. control-tags/
  10. crud/
  11. debugging-struts/
  12. docs/
  13. dynamic-href/
  14. exception-handling/
  15. exclude-parameters/
  16. expression-cache/
  17. file-upload/
  18. form-processing/
  19. form-tags/
  20. form-validation/
  21. form-xml-validation/
  22. helloworld/
  23. http-session/
  24. interceptors/
  25. jasperreports/
  26. jfreechart/
  27. json/
  28. json-customize/
  29. mailreader2/
  30. message-resource/
  31. message-store/
  32. preparable-interface/
  33. quarkus/
  34. rest-angular/
  35. restful2actionmapper/
  36. shiro-basic/
  37. sitemesh3/
  38. spring-struts/
  39. src/
  40. struts-parameter/
  41. text-provider/
  42. themes/
  43. themes-override/
  44. tiles/
  45. type-conversion/
  46. unit-testing/
  47. unknown-handler/
  48. using-tags/
  49. validation-messages/
  50. wildcard-method-selection/
  51. wildcard-regex/
  52. .asf.yaml
  53. .gitignore
  54. mvnw
  55. mvnw.cmd
  56. pom.xml
  57. README.md
README.md

Struts Examples

Build Status @ ASF Build Status @ GH Actions License

This Maven multi-module project contains all the Apache Struts example applications that are part of the Apache Struts Getting Started tutorials at https://struts.apache.org.

To build all the example applications run the Maven command:

mvn -e clean package

In the project's root folder, Maven will build each module and create a .war file in the target sub-folder of each module.

You can then copy the .war files to your Servlet container (e.g. Tomcat, Jetty, GlassFish, etc).

Some modules have a README file with instructions and the URL to view that application.

Older versions

The examples use the latest Struts version. For older versions, see the Releases page.