You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add documentation for HTMX-aware AuthenticationEntryPoint
- CHANGELOG.md: Add [Unreleased] entry for the new feature
- README.md: Add HTMX Support section under Security Features with
override instructions; update features list and table of contents
- CLAUDE.md: Add HtmxAwareAuthenticationEntryPoint to Security section
and AuthenticationEntryPoint override to Extension Points
Copy file name to clipboardExpand all lines: CHANGELOG.md
+11Lines changed: 11 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,14 @@
1
+
## [Unreleased]
2
+
### Features
3
+
- HTMX-aware AuthenticationEntryPoint for session expiry handling (#294)
4
+
- When HTMX requests (identified by `HX-Request: true` header) hit an expired session, the framework now returns a 401 JSON response with an `HX-Redirect` header instead of the default 302 redirect that causes HTMX to swap login page HTML into fragment targets.
5
+
- New classes:
6
+
-`HtmxAwareAuthenticationEntryPoint` — detects HTMX requests and returns 401 + JSON + `HX-Redirect`; delegates to wrapped entry point for standard browser requests
7
+
-`HtmxAwareAuthenticationEntryPointConfiguration` — registers the entry point via `@ConditionalOnMissingBean(AuthenticationEntryPoint.class)`
8
+
-`WebSecurityConfig` now always configures `exceptionHandling()` with the injected entry point (previously only configured when OAuth2 was enabled)
9
+
- Consumer override: define any `AuthenticationEntryPoint` bean to replace the default
10
+
- 100% backward-compatible: non-HTMX browser requests get the same 302 redirect as before
@@ -83,6 +84,7 @@ Check out the [Spring User Framework Demo Application](https://github.com/devond
83
84
- Audit event framework for recording and logging security events, customizable to store audit events in a database or publish them via a REST API.
84
85
- Role and Privilege setup service to define roles, associated privileges, and role inheritance hierarchy using `application.yml`.
85
86
- Configurable Account Lockout after too many failed login attempts
87
+
- HTMX-aware session expiry handling — returns 401 JSON instead of 302 redirect for HTMX requests, preventing broken UI fragments
86
88
87
89
-**Advanced Security**
88
90
- Role and privilege-based authorization
@@ -504,6 +506,29 @@ user:
504
506
flushRate: 10000
505
507
```
506
508
509
+
### HTMX Support
510
+
511
+
When HTMX-powered pages make requests (polling, fragment loading, etc.) and the user's session expires, Spring Security's default 302 redirect causes HTMX to swap the full login page HTML into each target element, breaking the UI.
512
+
513
+
The framework automatically detects HTMX requests (via the `HX-Request` header) and returns a proper 401 response instead:
0 commit comments