does that server have the ability to act as an LDAP server? If so, then look into auth_ldap, it's a very easy way to set up authentication, and since the apache server is doing the authentication, you don't have to program anything except some pretty error pages for if they fail, or a pretty log in screen in an unprotected area if you want.