Basic Authentication
- Basic authentication provides a username and password. These are written to the authentication module processes on a single line, separated by a space:
- The authentication module process reads username, password pairs on stdin and returns either "OK" or "ERR" on stdout for each input line.
- The following simple perl script demonstrates how the authentication module works. This script allows any user named "Dirk" (without checking the password) and allows any user that uses the password "Sekrit":
#!/usr/bin/perl -w
$|=1; # no buffering, important!
while (<>) {
chop;
($u,$p) = split;
$ans = &check($u,$p);
print "$ans\n";
}
sub check {
local($u,$p) = @_;
return 'ERR' unless (defined $p && defined $u);
return 'OK' if ('Dirk' eq $u);
return 'OK' if ('Sekrit' eq $p);
return 'ERR';
}