DreamT has asked for the wisdom of the Perl Monks concerning the following question:

Hi,
Is it possible to emulate Apache's authentication layer, i.e. the functionality that is described here, in a Perl (CGI) script?
  • Comment on Perl-CGI - Emulating Apache authentication?

Replies are listed 'Best First'.
Re: Perl-CGI - Emulating Apache authentication?
by rnewsham (Curate) on Mar 08, 2013 at 10:18 UTC

    You could of course create a cgi based login system in a popup but I don't believe that is what you asking for.

    As far as I am aware there is no way to emulate the apache auth functionality. It seems like a waste of effort to duplicate functionality when you can just use it as it is. If you want to manage the users and passwords from perl you can use Apache::Htpasswd to manipulate the .htpasswd file.

      I want to control the behaviour (enabling/disabling) of the authentication based on dynamic variables in the Perl code, that's why I really can't use it as it is.
      I guess I can use mod_perl in some way, but the environment for this specific task is very strict - I really can't install mod_perl in the target environment.

        I think you really just need to create a cookie based login session system. If you have reasons for not wanting to store users in a database then you can still use a .htpasswd file for storing users. I think App::Authentication::Htpasswd should allow you to do that.

Re: Perl-CGI - Emulating Apache authentication? (Catalyst, Plack, Mojolicious, Dancer...)
by Anonymous Monk on Mar 09, 2013 at 00:40 UTC