Take a look at Apache::MVC (part of Maypole) for a way of handling this kind of thing in mod_perl (actually, it's mostly platform independent). I've only used it in small test applications, but looks like a reasonably clean and extensible design to me. There's a whole section in the docs on authentication.