vascop
vascop

Reputation: 5212

Web authentication through C program

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?

Upvotes: 0

Views: 621

Answers (3)

Simon
Simon

Reputation: 32893

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 using system or equivalent.

Edit: Then you may look into protecting a directory by a .htaccess and a .htpsswd. I don't know it is accessible through libcurl or any other C library though.

Upvotes: 0

Grav
Grav

Reputation: 1714

Simplest thing possible would be to keep the path to the files secret and authenticating people by giving them the link.

Upvotes: 2

Conrad Meyer
Conrad Meyer

Reputation: 2887

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.

Upvotes: 0

Related Questions