Overview

some demo code for ur/web, demonstrating user authentication/sessions.
 - 30th december 2009 - daniel patterson (http://dbpatterson.com)

to build, first make the c libraries:
$ gcc -I/usr/local/include/urweb -g -c -o librandom-static.o random.c
$ gcc -I/usr/local/include/urweb -g -c -o libhash-static.o hash.c

$ ar rcs librandom-static.a librandom-static.o
$ ar rcs libhash-static.a libhash-static.o

(with the path to where urweb is located substituted if necessary).

then compile the two modules with urweb:
$ urweb hash
$ urweb random

and then compile the main program (shown here to use sqlite):
$ urweb -dbms sqlite -db userpass.db userpass

and then to run it, first populate the database:
$ sqlite3 userpass.db < userpass.sql

and if you want it to be useful, grab a sha512 hash of some example password, and insert it into the db, here is an example:
$ sqlite3 userpass.db
...
sqlite> insert into uw_Userpass_u (uw_user, uw_password) values ("name", "3627909a29c31381a071ec27f7c9ca97726182aed29a7ddd2e54353322cfb30abb9e3a6df2ac2c20fe23436311d678564d0c8d305930575f60e2d3d048184d79");

(that is the hash for the password 12345)

then run it:
$ ./userpass.exe

and visit in your webbrowser http://localhost:8080/Userpass/main

and you should be able to log in with the credentials you set up in the database, with a session set up via cookie, backed by the uw_Userpass_s table in the database. 

TODO: salt the passwords.