Search code examples
apachemod-rewritecgifastcgibasic-authentication

read basic auth user/pass with CGI script?


I´m facing a problem right now with apache basic auth and my CGi script.

Does anyone know if it is possible to read the user/pass from the basic auth with a CGi script?

What I want to accomblish is that the user logs in via apache basic auth and starts a CGI stript. The CGI script get the user/pass from the basic auth login and does something else with it (starting a child process).

Is it possible to get the user/pass from a CGI script? Or can I do this with some fancy rewrite rule or pass it with the CGI call?

I hope that someone can answer this because I dont really know a alot about apache/rewrite rules and even if it is possible.

Thanks!


Solution

  • I found a solution... not perfect but I´m getting close.

    Its possible to write a external authenticator for Apache using mod_authn_external.

    See: https://code.google.com/p/mod-auth-external/

    The basic auth credential get passed (piped or ENV vars) to the script/prog and then its possible to do some magic.

    I want to authenticate with perl and PAM, but PAM is not working yet, refer to my question here:

    https://stackoverflow.com/questions/21629123/get-authen-pam-working-with-perl-apache

    Hope this helps someone...