通过C程序进行Web认证
首先,目标不是安全性也不是用户友好性。 (意味着没有视觉垃圾,没有密码编码/超级安全的东西)
服务器端我想要尽可能简单的东西。只是一种对大约 5 个用户进行身份验证的方法,但在他们进行身份验证时知道他们是谁。一旦他们通过身份验证,我将向他们提供一个文件(我还没有决定什么,.txt 或 xml 或其他什么),他们将无法执行任何其他操作。
因此,从程序的角度来看,我需要连接到我的服务器,以某种方式进行身份验证,获取文件,然后断开连接。用户仅通过简单的用户/密码组合与程序交互。其余的都是自动的。我正在寻找 libcurl 进行连接+身份验证+下载,但我想听到建议,因为从此列表中: libcurl 竞争对手,似乎有很多可用的报价。
我认为它与我执行 sudo aptitude install 时的情况相同,但 sudo 部分将在服务器上运行(如果这有意义的话)。
所以我的问题是,如何制作一个带有身份验证的页面(请注意,它不必有任何视觉输出),然后让程序下载文件。我如何连接到它?
First of all, the goals are not security nor user-friendliness. (Meaning no visual crap and no password encoding/ mega security stuff)
Server-side I want the simplest thing possible. Just a way to authenticate some ~5 users but knowing who they are when they do. Once they are authenticated I'll serve them a file (I haven't decided yet what, .txt or xml or something) and they won't be able to do anything else.
So from the program standpoint, I need to connect to my server, authenticate somehow, get a file, and disconnect. The user only interacts with the program with a simple user/pass combo. The rest is automatic. I was looking to libcurl for the connection+authentication+download, but I would like to hear suggestions because from this list: libcurl competitors, there seems to be much offer available.
I think of it as the same as when I do sudo aptitude install
, but the sudo part would go on the server if that makes any sense.
So my question is, how can I make a page with an authentication (note that it doesn't have to have any visual output) which then lets the program download a file. And how do I connect to it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
最简单的事情可能是对文件路径保密,并通过向人们提供链接来对他们进行身份验证。
Simplest thing possible would be to keep the path to the files secret and authenticating people by giving them the link.
您可能会发现HTTP 基本身份验证上的此页面很有用。您可以推出自己的 HTTP 服务器或配置现有的 httpd。然后,您可以编写一个简单的 shell 脚本,调用curl 来验证和下载页面。
You might find this page on HTTP Basic authentication useful. You can either roll your own HTTP server or configure an existing httpd. Then, you can write a simple shell script that calls out to curl to authenticate and download the page.
如果您的用户可以在服务器上拥有帐户,一种方法是使用
scp
命令。系统将提示他们输入密码。您可以将其包装在 shell 脚本中,或者使用system
或等效方法从 C 程序中调用它。编辑:然后您可以考虑通过
.htaccess
和.htpsswd
来保护目录。我不知道它可以通过 libcurl 或任何其他 C 库访问。If your users can have accounts on the server, a way would be to use the
scp
command. They will be prompted for their password. You can wrap it in a shell script or call it from a C program usingsystem
or equivalent.Edit: Then you may look into protecting a directory by a
.htaccess
and a.htpsswd
. I don't know it is accessible throughlibcurl
or any other C library though.