JsonAuthenticationEntryPoint
7/8/26Less than 1 minute
JsonAuthenticationEntryPoint
Info
Spring Security AuthenticationEntryPoint that returns a unified JSON error response for unauthenticated or expired-token requests (HTTP 401).
Overview
Handles AuthenticationException thrown when a request lacks valid authentication. Supports custom error messages and codes via request attributes set by upstream filters (e.g. JwtAuthenticationEntryPoint).
Response Format
{
"code": 401,
"message": "未登录或token已过期"
}| Field | Type | Default | Customizable Via |
|---|---|---|---|
code | int | 401 | request.getAttribute("auth_error_code") |
message | String | 未登录或token已过期 | request.getAttribute("auth_error_message") |
HTTP Status: 401 Unauthorized
Request Attributes
| Attribute | Type | Description |
|---|---|---|
auth_error_code | Integer | Custom business error code (defaults to 401) |
auth_error_message | String | Custom error message (defaults to "未登录或token已过期") |
Dependencies
ObjectMapper-- JSON serialization
Changelog
7/8/26, 5:52 AM
View All Changelog
9f290-on

