NicolasBernaerts / debian-scripts

Various installation & administration scripts for Debian server
130 stars 54 forks source link

Zoneminder Camera Wall #18

Closed raymonvdm closed 2 years ago

raymonvdm commented 4 years ago

I just found this project but it looks like i cannot get it to pass the API authentication. The account seems to be fine and is working when testing on my desktop using

https://hostname/zm/api/monitors.json

I also tried testing on the command line of the server using

curl -d "username=camerawall&password=s3cr3t&action=login&view=console" -c cookies.txt https://hostname/zm/index.php

But the following is not authenticated

curl -b cookies.txt https://hostname/zm/api/monitors.json

It does not matter if i use http or https

The server is running Ubuntu 18.04.4 and ZoneMinder 1.34.9

greg-fischer commented 4 years ago

I can't get the auth to work either. The second curl request for monitors.json always returns success = false and "Not Authenticated".

Just to note though, I did also see that on line 82 with the preg_match_all to find the session cookie its not finding it on my server response. The variable saved for $arrZMCookie is looking at the wrong Set-Cookie header. I have 3 in my response. I changed from this line: $arrCamCookie['session'] = $arrZMCookie[1][0]; To use this instead: $arrCamCookie['session'] = $arrZMCookie[1][2];

That's not a good fix, but I could at least see the cookie info saved in $arrCamCookie['session'].

But this doesn't fix it. The next curl request for monitors.json still always comes back with no auth. I'm trying to learn more about the API on ZM. Looks like they prefer JWT's for auth now, but do still support the old method.

greg-fischer commented 4 years ago

Also note that on my server ZM was setup with cgi-bin at a different path for some reason: https://myhost.../cgi-bin-zm/

I noticed on other help docs that's not standard, except in zmNinja it was added that way and its working set with that path.

My server is CentOS 8 - ZM 1.34.9

NicolasBernaerts commented 4 years ago

Hello Greg, What are your ZM options ? Here are mine : OPT_USE_AUTH : ticked AUTH_TYPE : builtin AUTH_RELAY : hashed AUTH_HASH_LOGINS : ticked OPT_USE_API : ticked

greg-fischer commented 4 years ago

I have all those options selected as you do. I tried running through the debugger a bit but then I thought I'd just build my own grid/wall, which I hacked together quick for my work and that's working well for now. Sorry that does't help you with your program though. I'll look at my servers , maybe I still have the directory for this and I can do a couple quick tests for you.

Oh but one thing maybe of note. When I was running through the debugger I don't think I had it running on the same server as ZM. It may be a CORS problem I was hitting. I'm only realizing now because I ran into that with my grid when I ran off a local node.js server or remote apache.

szakacs-g commented 4 years ago

Cannot get it to pass the API authentication. Works great if OPT_USE_AUTH is unchecked

The server is running Ubuntu 20.04 and ZoneMinder 1.34.19

When using Google Chrome I see an inspect error : -

Uncaught TypeError: Cannot read property 'complete' of null at updateImage

Any ideas ?

ovargasp commented 4 years ago

I just found this project today while looking for a very lightweight client to access zm.

followed installation instructions, it works as a charm, but then I ran into a few issues: first missing packages on my server php installation (php logs helped here), second there was a problem with code on camera-wall.php, it didn't called other scripts properly, (path incomplete... again php logs), finally some zm tweeks:

  1. Had disabled the API, so I needed to re enable it,
  2. Already have a user, just checked it has API access enabled,
  3. revoked and updated token for de API (preventing an authentication problem with old tokens due disabling API)

after all that just opened the page and it worked.

I'm not using authentication on zm because I use a VPN to connect to server. the only option I have ticked is OPT_USE_API, everything else is zm default.

runnig zm on ubuntu server 18.04, zm version 1.35.10

Hope this helps anyone.

NicolasBernaerts commented 2 years ago

Thanks for the feedback