For almost every language there should be a Framework! You can bundle / combine the functionality of these frameworks to suit your needs!
In pseudo code:
if(IsUserValidViaOpenId() || IsUserValidByOwnAuthDB()) ... user auth successful
java, Acegi/ Spring Security (, - ). openID userdb!