A variation of the code above for group based page-by-page authentification can be found here
In case you get a parser error while using this plugin, try changing the echo command at the bottom like this:
Also for installation, instead of adding line include("extensions/accessControl.php"); to your LocalSettings.php as specified by the author use
Note: This extension is to restrict read access to a page. This is not for restricting edit access.
A new extension has been forked from this one, which now restricts edit access also, including group-based authentication.