chiark / gitweb /
wip, transaction fixup
[cgi-auth-flexible.git] / test.cgi
1 #!/usr/bin/perl -w
2
3 use strict;
4 use warnings;
5 use CGI;
6 use CGI::Auth::Hybrid;
7
8 my $dump = "$ENV{'CAHTEST_HOME'}/dump";
9
10 my $verifier = CGI::Auth::Hybrid->new_verifier(
11    assocdb_path => "$dump/assoc.db",
12    username_password_ok => sub { my ($c,$r,$u,$p)=@_; return $p eq 'sesame'; },
13 );
14
15 END { $verifier->disconnect() if $verifier; }
16
17 my $q = CGI->new;
18
19 my $authreq = $verifier->new_request($q);
20
21 $authreq->check_ok() or return;
22
23 my $cookie = $authreq->secret_cookie();
24 my $url = url();
25 my $hiddenhtml = $authreq->secret_hidden_html();
26
27 print <<END;
28 Content-Type: text/html
29 Set-Cookie: $cookie
30
31 <html><head><title>TITLE</title></head>
32 <body><h1>H1</h1>
33 <h1>again</h1>
34
35 <form method="POST" action="$url">
36 $hiddenhtml
37 END