This project is a C program that will allow you to authenticate your users via basic auth using a TOTP One Time Password (the same system that Google uses for their OTP).
When the prompt comes up from the browser the user will enter their regular username but for the password they will enter their 6 digit TOTP and their password:
ie
123456password
mod_auth_external will invoke the program and it will perform the necessary lookups. It is written in C to use as least amount of resources as possible (as shelling out can be expensive).
If you are really concerned about performance - it would be easy enough to copy all the code into mod_auth_external source and use an internal function. The problem with that as it appears is that if the program segfaults, from the documentation, it will take the entire httpd with it.
Since this is just a program you could use it for other things such as in shell scripts.
If you use OTP with basic auth - a user will need to relogin every 30 seconds