The techniques we’ve seen so far can protect statically served files and would work for the static version of the docbase viewer we developed in Chapter 7. What about the other viewer that relies on a server-side script to dish out pages dynamically? In that case you’d need to protect the directory from which the script runs or perhaps the script itself. Here’s a CGI URL that produces a record from the ProductAnalysis docbase:
In Apache you can protect that script like this:
<Directory /web/cgi-bin/Docbase> AuthType Basic AuthDBMUserFile /secure/subscribers require user valid-user </Directory>
Since Apache’s notion of access control is directory oriented,
though, this setup restricts access to all the docbases accessible by
/cgi-bin/Docbase scripts. If you need a
more granular approach, you can instead do this:
The problem with this method is that you’ll need to locate a copy of doc-view.pl, or at least a wrapper that would refer to a common instance of doc-view.pl, in each docbase’s CGI subdirectory.