]> git.ipfire.org Git - thirdparty/squid.git/blob - doc/Programming-Guide/BasicAuthentication.dox
ee1e9a8a00d4ff1698b9cf040021764ee7f51a5e
[thirdparty/squid.git] / doc / Programming-Guide / BasicAuthentication.dox
1 /*
2 * Copyright (C) 1996-2014 The Squid Software Foundation and contributors
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
9 /**
10 \defgroup AuthAPIBasic Basic Authentication
11 \ingroup AuthAPI
12
13 \par
14 Basic authentication provides a username and password. These
15 are written to the authentication module processes on a single
16 line, separated by a space:
17 \code
18 <USERNAME> <PASSWORD>
19 \endcode
20
21 \par
22 The authentication module process reads username, password pairs
23 on stdin and returns either "OK" or "ERR" on stdout for
24 each input line.
25
26 \par
27 The following simple perl script demonstrates how the
28 authentication module works. This script allows any
29 user named "Dirk" (without checking the password)
30 and allows any user that uses the password "Sekrit":
31
32 \code
33 #!/usr/bin/perl -w
34 $|=1; # no buffering, important!
35 while (<>) {
36 chop;
37 ($u,$p) = split;
38 $ans = &amp;check($u,$p);
39 print "$ans\n";
40 }
41
42 sub check {
43 local($u,$p) = @_;
44 return 'ERR' unless (defined $p &amp;&amp; defined $u);
45 return 'OK' if ('Dirk' eq $u);
46 return 'OK' if ('Sekrit' eq $p);
47 return 'ERR';
48 }
49 \endcode
50
51 */