Commit Graph
46 Commits
Author SHA1 Message Date
Nic Boet 6fe673ee9c feat: record the cause given to the monitors alarm API
monitors/alarm/command:on now takes an optional cause (query or POST data)
and passes it to zmu --cause, so the event records it in place of
"Forced Web". Without a cause nothing changes.

The cause is stored as the event's Cause and in its Notes, so alarmCause()
keeps it to plain text: letters, digits, spaces and plain punctuation, cut
to the 31 bytes zmu stores on a character boundary, falling back to the
default when nothing is left. The value is quoted with escapeshellarg()
for the zmu command line.

Test: tests/php/test_monitor_alarm_cause.php

fixes #5348
2026-10-25 20:58:53 -05:00
Nic Boet cb4c5f5314 feat: ask for a new password when an account logs in with the default one refs #5287
db/zm_create.sql seeds the admin account with the password the user
guide documents (admin), so with authentication on a new install is
still open to anyone who reads the guide.

Refuse that password as a credential and have the web login replace it:

- validateUser() returns false with "This account uses the password
  admin, which ZoneMinder does not accept. Log in to the web interface
  to set a new one." when the password is right but is admin. The API (login.json and
  user=/pass= on any request) answers 401 with that message; the
  user=/pass= web parameters are refused the same way.
- On the login page (action=login) the same login shows a form that
  asks for the current password again and a new one, with a nonce kept
  in the session so another site can't submit it for the user. The new
  password must be set, confirmed and not the default. The account is
  logged in only once it has been replaced; the change is audited.
  That POST skips reCAPTCHA when it carries the form's nonce: the form
  follows a login that passed it, and doesn't render the widget.
  With ZM_AUTH_RELAY=plain the session keeps the new password.
- zmLoadUser() refuses the default password, so zms, zmu and the RTSP
  server don't accept it in user/password parameters either.

The check is on the password typed, so it needs no schema change, covers
existing installs whose admin still has the default password, and
follows the account if it is renamed. A password set to the default
again later is caught the same way. Sessions, tokens and auth hashes
issued before the upgrade keep working until they expire; with
ZM_AUTH_TYPE=remote the web server's login is not affected.

The FAQ now says to force authentication on in conf.d: since 4d7609d36
the daemons apply zm.conf and conf.d values over the database too.

Tests: tests/php/test_default_password.php (the helpers, and that the
seeded hash is the documented default), tests/zm_user_default_password.cpp.
2026-10-16 10:10:25 -05:00
Isaac Connor 9c96ba3d28 Fix references to StartTime => StartDateTime and EndTime 2025-09-05 11:45:49 -04:00
Alejandro Criado-Pérez a5d83e61b4 Corrections on rst files 2023-08-13 01:20:29 +02:00
Isaac Connor 7f38ec1999 Update API entries replacing Function concept 2022-09-19 13:46:29 -04:00
Patrick f81e7b5b48 add area definition to zone creation via API 2020-02-24 21:04:40 -07:00
Patrick 6abc91c11d fix spelling 2020-02-15 13:52:35 -07:00
Pliable Pixels b4a8790555 Update api.rst
https://github.com/ZoneMinder/zoneminder/issues/2764#issuecomment-559451717
2019-11-28 10:39:49 -05:00
Pliable Pixels 1a72b5b9fe add note on API wrapper 2019-11-17 15:56:41 -05:00
Pliable Pixels 4ae1df2a8c mention that you can't use payloads with GET 2019-11-01 10:09:32 -04:00
Pliable Pixels 88ba1eb8ab api formatting fixes 2019-10-26 08:25:26 -04:00
Pliable Pixels 4b0a1f0be5 api some tiny formatting 2019-10-25 14:41:56 -04:00
Isaac Connor 84492f29b1 Fix token auth sessions (#2676)
* If token is present do token based auth and do not do anything with session

* update HostController.  Use config constants, don't use sessions

* Remove Session from the components list

* spacing

* Remove Session from App Components list.

* Move APIEnabled check to the api from auth.php

* Rework auth.  login using username and password only occurs on login action now.  Including auth.php should not touch the session.  auth_hash logins no longer touch the session.  replace userLogin with a function called validateUser which matches the semantics of validateToken.

* remove debugging

* Add session storage if stateful query param is on, but only for LEGACY_API_AUTH

* fix mUser to username, etc.

* shuffle lines

* use  instead of session when generating auth hash.

* Add docs regarding the use of cookies and stateful query param

* Only open/close session if we are clearing a session var

* Use zm_session_start instead of session_start

* Should use zm_session_start instead of session_start

* document that zm_session_start should be called previously to session_regenerate_id

* Don't actually write out the session when generating auth hashes.  Means they should never actually persist.

* More backticking of SQL

* add .. to fix #2686

* Use material icons for sort because they look nicer

* fix typo

* have to add authhash to session on login

* restore username&password login for all urls

* fix

* fixes
2019-08-20 09:46:53 -04:00
Pliable Pixels ddd02ec10d clean up of API, remove redundant sections 2019-05-19 07:29:27 -04:00
Pliable Pixels 036d47545f small API fixes 2019-05-18 19:35:13 -04:00
Pliable Pixels a07da01f0c reworked API document for new changes in 2.0 2019-05-15 13:57:51 -04:00
Pliable Pixels ace1134df1 further reading 2018-11-01 14:40:31 -04:00
Pliable Pixels 86a086c216 server json api typo 2018-11-01 14:13:22 -04:00
Pliable Pixels 14c30eac76 typo 2018-11-01 14:08:09 -04:00
Pliable Pixels 536d9226e0 ptz - clarify this is meta-data 2018-11-01 14:07:53 -04:00
Pliable Pixels 46cd2fc3ff relocate monitor_status to the right place 2018-11-01 14:04:51 -04:00
Pliable Pixels cd8d609e84 initial multi-server/storage changes 2018-11-01 14:00:09 -04:00
Pliable Pixels 2953ff4db4 header level fix 2018-11-01 13:40:07 -04:00
Pliable Pixels 37b2da59ce added streaming interface docs 2018-11-01 13:30:08 -04:00
Matt N 0d1f8aaf03 Document /api/monitors/daemonStatus/ 2018-10-28 17:15:39 -07:00
Pliable Pixels fc4a84011b added note on auth hash logins (#2237)
* added note on auth hash logins

* code inline escape fix
2018-10-06 15:38:30 -04:00
Pliable Pixels 0e2fdf4a1c fixed path for login/logout api 2018-09-14 11:48:22 -04:00
Pliable Pixels d45ca8880a documentation for new login/logout APIs (#2163) 2018-07-17 13:24:47 -04:00
Mike R 3dc157732a Issue 1963: Remove spaces from example api calls. 2018-03-03 00:58:35 -05:00
Eric Relson b822deeb8c Minor API doc error fixes 2016-08-02 10:08:08 -07:00
Pliable Pixels dc916bba2c case typo 2016-07-23 08:04:46 -04:00
Pliable Pixels 45a62dc8d8 Added example of configs API edit 2016-07-23 08:03:15 -04:00
arjunrc e0c5b2a78f added consoleEvents API 2016-05-19 15:15:48 -04:00
arjunrc 13feb96811 added alarm apis 2016-05-19 15:06:41 -04:00
Andrew Bauer f13dddb719 Update api.rst 2015-09-22 09:26:09 -05:00
Pliable Pixels 08e04afcd2 fixed security instructions with curl 2015-09-22 07:39:27 -04:00
Pliable Pixels 2232b6b68b Updated API to add security notes 2015-08-16 15:05:15 -04:00
PliablePixels f77d0eda22 content updates 2015-08-15 11:56:08 -04:00
PliablePixels 35580cf787 Fixed heading hierarchy of API so they all don't show in master TOC 2015-08-14 08:56:28 -04:00
Pliable Pixels 71665a3315 Added updated API information
Reflected new APIs, corrected and updated examples
2015-06-14 11:21:00 -04:00
Pliable Pixels 3ef916f49c Update api.rst 2015-06-14 10:51:28 -04:00
SteveGilvarry 9795967298 Initial attempt to migrate wiki to readthedocs 2014-07-13 22:25:30 +10:00
Kyle Johnson e18c4b593d Added api doc for adding a zone 2014-04-25 19:52:08 +00:00
Kyle Johnson 0d906d4ec9 Added api doc for adding a monitor 2014-04-25 19:29:57 +00:00
Kyle Johnson e65e17093f Added api doc for editing configs 2014-04-25 19:19:56 +00:00
Kyle Johnson 8dd7d3e934 Initial commit of documentation for the API 2014-04-25 19:13:32 +00:00