3

Just to give a background, our web application involves connecting to a network camera stream. Now the camera has an option for security, so we set up a password for its 'root' account. So whenever we connect to the web page, we see this prompt:

screenshot of the pop-up alert

I need an automatic authentication script or code, preferably Javascript, to solve this problem. I was trying to use XMLHttpObject.open() because the last two parameters that it asks is for username and password, and thought it might work but it's not working.

This is the code:

var xmlHttp = new XMLHttpRequest(); 
xmlHttp.open( "POST", "http://192.168.16.140/video.mjpg", true, "root", "password");
xmlHttp.send( null );

I also think this info might help you guys figure out what I wanted. I've created a C application prior to this web application that uses libcurl to connect to the said camera. Using

curl_easy_setopt(preset, CURLOPT_USERPWD, "username:password");

along with the other stuffs there I was able to connect to the camera and retrieve a screenshot. I want something similar to this, but preferably in Javascript form. I also want to understand how the libcurl command works.

I hope I can resolve this real soon and if there ever was a quick google search fix for this then I guess I'm not that much of a google ninja.

IBG
  • 465
  • 12
  • 34
  • possible duplicate of [Pure Javascript code for HTTP Basic Authentication?](http://stackoverflow.com/questions/491914/pure-javascript-code-for-http-basic-authentication) ...unless you're going to actually show the `XHR.open()` code that you tried, and explain what about it didn't work. – Matt Ball Nov 07 '11 at 04:32
  • not working for me, and also not duplicate I think. I'll post an edit to the question. – IBG Nov 09 '11 at 01:25
  • Root password readable for everyone in a textfile? – Andreas Nov 09 '11 at 05:59
  • yeah. It doesn't matter though, because the camera itself can't be accessed anyway, or so they say. The logic's not clear enough to me, they just want me to find a way to get rid of that dialog box. – IBG Nov 09 '11 at 08:02

1 Answers1

1

I solved the problem, but I think this is not it. It is very unsafe. What I did was add the authentication to the URL:

http://user:pass@ipaddress/video.mjpg

On the src parameter of the img tag that I created. If anyone has an alternative solution please do give some. Thank you very much.

IBG
  • 465
  • 12
  • 34