Commit Graph
18 Commits
Author SHA1 Message Date
Isaac Connor 40129a5564 refactor: replace the auth_hash/auth_relay globals with one ZMAuth credential
The page kept two copies of the same secret: auth_relay, the query fragment
every AJAX call is authenticated with, and auth_hash, the bare hash stamped
into stream <img> URLs. Different responses updated different copies, so
they could drift, and a drifted auth_hash produced stream URLs that zms
rejects.

ZMAuth stores only the relay and derives the hash from it, so the two cannot
disagree. Its helpers cover the four shapes the call sites used:

  zmAuth.hash          derived, '' under the plain/none relay forms
  zmAuth.update(data)  absorb the auth fields of any response
  zmAuth.appendTo(url) authenticate a url, no-op when auth is off
  zmAuth.applyTo(src)  point a stream url at the current credential

appendTo also removes the `x ? '&'+x : ''` guard repeated at every call
site, some of which had omitted it and emitted a dangling '?'.

Migrates all call sites across web/js and the classic skin, and drops both
globals from skin.js.php.

Tests: tests/js/auth-helpers.test.js, 44 passing.
2026-08-09 10:29:46 -04:00
Isaac Connor e330b0988b fix: honor explicit port argument in urlToApi single-server case
The single-server branch added in 0950131b2 ignored the optional port
argument and always used location.host. Mirror the multi-server branch
by preferring port > location.host.
2026-05-08 10:24:45 -04:00
Isaac Connor 0950131b2a fix: urlToApi falls back to location.host in single-server case
When ZM_SERVER_ID is unset, Servers[0] is a synthetic default whose
Hostname/Port come from PHP fallbacks (HTTP_HOST, HTTP_X_FORWARDED_PORT,
ZM_BASE_URL) which can disagree with the host:port the browser is
actually using. That caused montagereview XHR to land on the wrong
physical server (e.g. default :443 of a hostname where ZM lives on :81).

For Servers without an Id, derive host:port from location.host so XHR
follows the same connection as the UI. Multi-server entries with a real
Id keep using their configured Hostname/Port.
2026-05-08 10:10:20 -04:00
Isaac ConnorandClaude Opus 4.6 1374735db1 fix: include port in Server URL methods for port-forwarded setups
When accessing ZoneMinder through port forwarding, API requests were
made without the forwarded port, causing NS_ERROR_NET_TIMEOUT. The
url(), urlToZMS(), urlToJanus(), and urlToApi() methods now fall back
to this.Port then location.port when no explicit port is passed.

fixes #4675

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 17:46:19 -05:00
Isaac Connor e9a3500087 Fix eslint 2025-11-06 11:18:24 -05:00
Isaac Connor b7c4e52d99 If Server has a port specified, use it in the api url 2025-11-04 10:30:39 -05:00
Isaac Connor a31887634a Inlcude port in url to janus 2023-05-11 10:23:04 -04:00
Isaac Connor 2a2c192562 Add urlToJanus function to Server class 2023-05-11 10:13:04 -04:00
iconnor@connortechnology.com 4979d299a6 Cleanup code style 2023-02-25 12:40:54 -05:00
iconnor@connortechnology.com cbabf9d5ce Add getFromApi 2023-02-25 12:40:41 -05:00
Isaac Connor 292f3a0cc2 Remove reference to zm.connortechnology.com 2023-01-13 12:48:26 -05:00
Isaac Connor 2e6f465055 eslint doesn't like function names that start with a capital 2023-01-12 09:38:13 -05:00
Isaac Connor 0f2afdcff7 Fix eslint and use const on port 2022-11-30 13:42:17 -05:00
Isaac Connor cdfe38cc31 Add UrltoZMS and UrltoAPI methods to Server js class 2022-11-30 13:19:02 -05:00
Matt N a1a42345e3 More eslint fixes; eslint in php; add eslint to travis (#2419)
* Add eslint to travis.yml

* Update eslint package versions and apply new indent rules

* Enable the brace-style and block-style eslint rules

* Enable the 'curly' eslint rule

* Enable the 'keyword-spacing' eslint rule

* Enable the 'key-spacing' eslint rule

* Enable the 'object-curly-spacing' eslint rule

* Enable the 'no-new-object' eslint rule

* Only disable the no-caller eslint rule in the one affected file

* Enable the 'no-unused-vars' eslint rule for local variables

* Add linting of JS in .php files
2019-01-19 10:32:40 -05:00
Matt N deaf651aad Fix eslint violations (#2416)
* Add more JS libraries to eslintignore

* eslint . --fix

Automatic fixes only

* frame.js: eslint fixes

* events.js: manual eslint fixes

* skin.js: manual eslint fixes

* watch.js: manual eslint fixes

* Remove some tabs used for indentation in JS

* state.js: Fix new-cap eslint violation

* Disable guard-for-in eslint rule to get everything passing
2019-01-18 10:00:55 -05:00
Isaac Connor 27d4ba9e5f use output of babeljs.io to provide code that works on older browsers. The nice class notation is ES6 upwards.. Safari on IOS9 doesn't like it 2018-12-03 15:16:47 -05:00
Isaac Connor ebe55cf6a4 Include new Server.js 2018-07-09 14:10:06 -04:00