Repository navigation
Commit 098f230
committed
sec(api/auth): return opaque 401 in login catch-all instead of err.Error() (closes #937)
The login() catch-all error path was forwarding raw service errors verbatim
via NewClientError(401, err.Error()), potentially exposing internal account
state (e.g. lock status, user IDs, timestamps) to unauthenticated callers.
Replace it with the opaque hardcoded string "invalid credentials" so all
non-sentinel auth failures (wrong password, account not found, locked, etc.)
collapse to the same response, regardless of what the service returns.
The typed-sentinel arms above (ErrMFARequired -> "mfa_required",
ErrInvalidMFACode -> "invalid_mfa_code") are unchanged.
Adds TestHandler_login_OpaqueError_HidesInternalMessage as a regression test
that pins the service returning a distinctive internal message and asserts
the 401 body is "invalid credentials" with no internal detail leaking through.
Salvaged from closed #886.1 parent c00445c commit 098f230
2 files changed
Lines changed: 41 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
54 | 57 | | |
55 | 58 | | |
56 | 59 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
104 | 141 | | |
105 | 142 | | |
106 | 143 | | |
| |||
0 commit comments