使用Javascript自动验证? [英] Automatic authentication using Javascript?
问题描述
为了给出背景知识,我们的Web应用程序涉及连接到网络摄像机流。
现在相机有安全选项,所以我们为其root帐户设置了密码。因此,每当我们连接到网页时,我们都会看到此提示:
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:
我需要一个自动验证脚本或代码,最好是Javascript来解决这个问题。
我试图使用XMLHttpObject.open(),因为它要求的最后两个参数是用户名和密码,并且认为它可能有用,但它不起作用。
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.
这是代码:
var xmlHttp = new XMLHttpRequest();
xmlHttp.open( "POST", "http://192.168.16.140/video.mjpg", true, "root", "password");
xmlHttp.send( null );
我也认为这些信息可能会帮助你找出我想要的东西。
我在此Web应用程序之前创建了一个C应用程序,它使用libcurl连接到所述摄像机。使用
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");
以及我能够连接到相机并检索屏幕截图的其他内容。我想要类似于此的东西,但最好是以Javascript形式。我也想了解libcurl命令是如何工作的。
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.
推荐答案
我解决了这个问题,但我认为不是这样。
这是非常不安全的。
我所做的是将身份验证添加到URL:
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
在我创建的img标签的src参数上。
如果有人有替代解决方案,请给一些。
非常感谢。
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.
这篇关于使用Javascript自动验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!