Commit 4495a46
fix(settings): expose plugin ep_* config blocks to CJS require (#8110)
Plugins read their own configuration from a top-level `ep_*` block in
settings.json via `require('ep_etherpad-lite/node/utils/Settings')`. The
CJS-compatibility shim added in #7421 installs accessor properties on
`module.exports` for `Object.keys(settings)` — but it ran exactly once, at
module-evaluation time, and `ep_*` blocks are only merged onto the settings
object later, by the `reloadSettings()` call at the bottom of that same
module. No accessor was ever defined for them, so every plugin config block
was invisible to the require() path; the value was reachable only under
`.default`.
Consequence: every plugin that reads `settings.ep_<name>` silently ran on its
built-in defaults. The reported symptom is ep_hash_auth, whose `hash_dir`
reverted to `/var/etherpad/users`, so every hash lookup failed, the
`authenticate` hook returned false, core's basic-auth fallback found no
`password` on the settings.json user, and admin login answered 401.
Note the `authenticate` hook itself was never the problem — /admin-auth/ is
handled by webaccess.checkAccess like any other path and does call the hook.
Extract the shim into `syncCjsExports()` and re-run it at the end of
`reloadSettings()`, so keys that only exist because the operator put them in
settings.json get accessors as soon as they are loaded.
Reported by @tris-ots.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013WTrZxkTJhiH1p7RuAx3NJ1 parent d4d7a61 commit 4495a46
3 files changed
Lines changed: 60 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
911 | 911 | | |
912 | 912 | | |
913 | 913 | | |
914 | | - | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
915 | 923 | | |
916 | 924 | | |
917 | | - | |
918 | | - | |
919 | | - | |
920 | | - | |
921 | | - | |
922 | | - | |
923 | | - | |
924 | | - | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
925 | 932 | | |
926 | | - | |
| 933 | + | |
| 934 | + | |
927 | 935 | | |
928 | 936 | | |
929 | 937 | | |
| |||
1454 | 1462 | | |
1455 | 1463 | | |
1456 | 1464 | | |
| 1465 | + | |
| 1466 | + | |
| 1467 | + | |
| 1468 | + | |
| 1469 | + | |
1457 | 1470 | | |
1458 | 1471 | | |
1459 | 1472 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
7 | 9 | | |
8 | 10 | | |
9 | 11 | | |
| |||
146 | 148 | | |
147 | 149 | | |
148 | 150 | | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
149 | 185 | | |
150 | 186 | | |
151 | 187 | | |
| |||
0 commit comments