Commit Graph

72 Commits

Author SHA1 Message Date
Girish Ramakrishnan
01d0c738bc replace debug() with our custom logger
mostly we want trace() and log(). trace() can be enabled whenever
we want by flipping a flag and restarting box
2026-03-12 23:08:35 +05:30
Girish Ramakrishnan
36aa641cb9 migrate to "export default"
also, set no-use-before-define in linter
2026-02-14 15:43:24 +01:00
Girish Ramakrishnan
96dc79cfe6 Migrate codebase from CommonJS to ES Modules
- Convert all require()/module.exports to import/export across 260+ files
- Add "type": "module" to package.json to enable ESM by default
- Add migrations/package.json with "type": "commonjs" to keep db-migrate compatible
- Convert eslint.config.js to ESM with sourceType: "module"
- Replace __dirname/__filename with import.meta.dirname/import.meta.filename
- Replace require.main === module with process.argv[1] === import.meta.filename
- Remove 'use strict' directives (implicit in ESM)
- Convert dynamic require() in switch statements to static import lookup maps
  (dns.js, domains.js, backupformats.js, backupsites.js, network.js)
- Extract self-referencing exports.CONSTANT patterns into standalone const
  declarations (apps.js, services.js, locks.js, users.js, mail.js, etc.)
- Lazify SERVICES object in services.js to avoid circular dependency TDZ issues
- Add clearMailQueue() to mailer.js for ESM-safe queue clearing in tests
- Add _setMockApp() to ldapserver.js for ESM-safe test mocking
- Add _setMockResolve() wrapper to dig.js for ESM-safe DNS mocking in tests
- Convert backupupload.js to use dynamic imports so --check exits before
  loading the module graph (which requires BOX_ENV)
- Update check-install to use ESM import for infra_version.js
- Convert scripts/ (hotfix, release, remote_hotfix.js, find-unused-translations)
- All 1315 tests passing

Migration stats (AI-assisted using Cursor with Claude):
- Wall clock time: ~3-4 hours
- Assistant completions: ~80-100
- Estimated token usage: ~1-2M tokens

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-14 15:11:45 +01:00
Girish Ramakrishnan
12e073e8cf use node: prefix for requires
mostly because code is being autogenerated by all the AI stuff using
this prefix. it's also used in the stack trace.
2025-08-14 12:55:35 +05:30
Johannes Zellner
cc3dc1636b Ensure proxyauth has a fallback icon for apps without icons 2025-07-21 16:26:22 +02:00
Johannes Zellner
545ac689b1 Remove unused require 2025-07-21 16:22:20 +02:00
Johannes Zellner
3754021ae8 Make the proxyauth login visually distinctive from oidc login 2025-07-16 18:20:43 +02:00
Johannes Zellner
d1dcbd97b7 Build proxyauth entrypoint as a single inlined html file 2025-07-16 17:45:33 +02:00
Johannes Zellner
30c0690e90 Bring back proxyauth proceed-to-login view 2025-07-16 17:45:33 +02:00
Girish Ramakrishnan
9eee7b2582 proxyauth: fix client id 2025-07-13 15:53:46 +02:00
Girish Ramakrishnan
04de621e37 Fix crash when req.query handling
https://expressjs.com/en/5x/api.html#req.query

"As req.query’s shape is based on user-controlled input, all properties and values in this object
are untrusted and should be validated before trusting"

In essence, req.query.xx can be an array OR an array of strings.
2025-07-13 13:21:38 +02:00
Girish Ramakrishnan
bba48f455e use @connect-lastmile 2025-07-10 11:00:31 +02:00
Girish Ramakrishnan
fd61a0bfbf proxyauth: oidc server returns username now
See 846986987d
2025-07-09 18:07:05 +02:00
Girish Ramakrishnan
2b30f5591c docker: allow requests via libpod and skopeo 2025-06-14 09:17:46 +02:00
Girish Ramakrishnan
b60681e9bd oidc: refactor the StorageAdapter 2025-06-13 02:05:01 +02:00
Girish Ramakrishnan
1ca8eeeb50 split oidc into server and clients 2025-06-11 22:26:23 +02:00
Johannes Zellner
d5a8731850 replace proxy auth page with direct oidc redirect 2025-04-29 12:18:22 +02:00
Girish Ramakrishnan
b5721fe6f3 inline basic-auth module 2025-02-15 16:56:40 +01:00
Johannes Zellner
7438576bb1 Move proxyauth page to vite 2025-01-06 14:35:50 +01:00
Girish Ramakrishnan
bcf497b460 translation.js -> translations.js
kept confusing my why i can't find this file! this is in line
with the rest of our code
2024-07-05 12:45:27 +02:00
Girish Ramakrishnan
bf51a60986 change args of translation.translate 2024-07-05 12:42:33 +02:00
Johannes Zellner
62e322c451 proxyauth: stash path and query for further use in the session 2024-06-11 18:59:19 +02:00
Johannes Zellner
255fb0cac0 proxyauth: show intermediate login button page 2024-04-16 13:43:12 +02:00
Johannes Zellner
c3be0018fe proxyauth: send user to oidc login instead of /login 2024-04-16 11:29:00 +02:00
Johannes Zellner
1008ec4fa1 proxyauth: remove basic auth login form 2024-04-15 18:52:07 +02:00
Johannes Zellner
21d7438bbe proxyauth: user OpenID instead of basic auth 2024-04-15 15:59:16 +02:00
Girish Ramakrishnan
5b7667fa4d external ldap: ensure dashboard login does totp check 2024-01-08 11:55:35 +01:00
Girish Ramakrishnan
053f81a53e externalldap: add tests 2024-01-07 22:04:22 +01:00
Girish Ramakrishnan
20a4136eb5 remove morgan
morgan breaks our log output parsing. debug() puts a timestamp in
the front.
2023-09-07 17:08:05 +05:30
Girish Ramakrishnan
eee49a8291 move dashboard setting into dashboard.js 2023-08-11 21:04:10 +05:30
Girish Ramakrishnan
67ee82abb9 remove settings.dashboardOrigin 2023-08-04 22:10:14 +05:30
Girish Ramakrishnan
e86a613d86 proxyauth: typo in basic auth validation 2023-03-14 11:35:24 +01:00
Girish Ramakrishnan
53e9eccf72 unify totp check
the totp check is done in several places causing errors like 3552232e99

* ldap (addon)
* accesscontrol (dashboard)
* proxyauth
* directoryserver (exposed ldap)
* externalldap (the connector)

The code also makes externalldap auto-create work now across all the cases where there is a username
2023-03-12 16:01:12 +01:00
Girish Ramakrishnan
5fc92240bb proxyauth: ensure ascii in x-remote-name 2023-01-30 12:45:24 +01:00
Girish Ramakrishnan
3dcd4f9da3 typo 2023-01-23 10:20:19 +01:00
Johannes Zellner
3552232e99 Support 2fa for proxy auth 2023-01-19 13:42:51 +01:00
Girish Ramakrishnan
d4555886f4 add note on the reason for the flag 2022-08-25 16:36:57 +02:00
Girish Ramakrishnan
a584fad278 proxyAuth: add supportsBearerAuth flag
required for firefly-iii
2022-08-25 16:12:42 +02:00
Girish Ramakrishnan
01b36bb37e proxyAuth: make the POST to /logout redirect
for firefly-III
2022-05-03 18:19:22 -07:00
Girish Ramakrishnan
3d28833c35 proxyAuth: use default fallback icon when no appstore icon or custom icon 2022-04-26 19:43:22 -07:00
Girish Ramakrishnan
c63709312d proxyAuth: set X-Remote-User, X-Remote-Email headers
Apps like firefly-iii support https://datatracker.ietf.org/doc/html/rfc3875#section-4.1.10
2022-04-25 22:24:41 -07:00
Girish Ramakrishnan
150f89ae43 proxyauth: on invalid token, redirect user
https://forum.cloudron.io/topic/6425/403-in-proxyauth-apps-after-server-migration
2022-02-01 17:58:05 -08:00
Girish Ramakrishnan
aeef815bf7 proxyAuth: persist the secret token 2022-02-01 17:35:21 -08:00
Johannes Zellner
2ae77a5ab7 Provide dashboardOrigin to proxy auth for stylesheet sourcing 2021-11-03 22:12:30 +01:00
Girish Ramakrishnan
62174c5328 proxyauth: only log failed requests by default 2021-10-25 09:41:12 -07:00
Girish Ramakrishnan
f44fa2cf47 apps: hasAccessTo -> canAccess 2021-09-21 10:13:06 -07:00
Girish Ramakrishnan
7709e155e0 more async'ification 2021-09-07 11:21:06 -07:00
Girish Ramakrishnan
77f5cb183b merge appdb.js into apps.js 2021-08-23 15:35:38 -07:00
Girish Ramakrishnan
37c2b5d739 proxyauth: fix crash 2021-08-22 16:19:22 -07:00
Girish Ramakrishnan
85e3e4b955 Accomodate redhat client
Patch from @jk at https://forum.cloudron.io/topic/4383/cannot-install-apps-from-docker-registry-because-authentication-fails
2021-08-13 09:36:06 -07:00