The lib-auth.php script is the right start. But you should know that there are some significant changes goin into this for the 1.2.6 release. Some may make your life easire in the long run, for instance, all references to the administrators Database Table are now in the library.
But of course, if you wish your changes to work on 1.2.5 you will not have these changes. Then you should just review the changes in the SVN to be sure you do not take a path that will be incompatible.