This commit is contained in:
Zzzz
2026-04-28 22:08:36 +08:00
parent d1f32b9d52
commit a37d37945b
7 changed files with 118 additions and 130 deletions
+10 -11
View File
@@ -36,9 +36,8 @@ rendering.
- Request fields consumed by `LoginServlet`: `username`, `password`, and
optional `redirect`.
- Presentation-only login controls may submit auxiliary fields such as
`loginRole` and `rememberUsername`; these must not participate in
authentication or authorization unless the Servlet/service contract is
deliberately changed.
`rememberUsername`; these must not participate in authentication or
authorization unless the Servlet/service contract is deliberately changed.
- Login JSP request attributes: `errorMessage`, `username`, and `redirect`.
- Dashboard/role JSP session attributes: `authenticatedUser`, `userRole`, and
`userPermissions`.
@@ -52,9 +51,9 @@ rendering.
attribute or session attribute.
- `redirect` must be a same-application path beginning with one `/`; invalid
values are ignored.
- `loginRole` is only a login-intent hint in the JSP. The authenticated role is
determined by the `users.role_code` row returned through `AuthService`, not by
a client-side radio selection.
- Login pages must not include a client-side role selector. The authenticated
role is determined by the `users.role_code` row returned through
`AuthService`, not by client-submitted form state.
- Remember-me behavior may persist only the username in browser storage. It must
never persist passwords, password hashes, redirects, permission state, or
extend the server session.
@@ -78,12 +77,12 @@ rendering.
- Good: failed login keeps the escaped username and never redisplays the
password.
- Good: selecting a role radio option or checking remember-me does not change
the server-side authentication decision.
- Good: checking remember-me does not change the server-side authentication
decision.
- Base: dashboard reads `sessionScope.authenticatedUser.displayName` and
`sessionScope.userRole` only for display/navigation.
- Bad: JSP, JavaScript, or Servlet code trusts `loginRole` to grant a role or
stores the password in browser storage.
- Bad: JSP, JavaScript, or Servlet code trusts a client-submitted role field to
grant a role or stores the password in browser storage.
### 6. Tests Required
@@ -102,7 +101,7 @@ rendering.
```jsp
<%-- JSP checks request.getParameter("password") or runs SQL directly. --%>
<%-- JavaScript stores the password or LoginServlet trusts loginRole. --%>
<%-- JavaScript stores the password or LoginServlet trusts a submitted role. --%>
```
#### Correct