Forum Moderators: phranque
I'm basically trying to perform the following scenario:
> Have restricted web page
> Check if user is authorised to view page (check.pl)
>> If successful, show page to user (original request)
>> If failed, show error page to user (intranet-deny.cgi)
I've played around with lots of alternatives to try and make this work. I have come up with the below. The way I read the following is:
> If url contains the keyword "Restricted"
> Parse url through to checkAuth
--- check.pl checks if logged in user has 'READ' access
--- if they do redirect them back to the same url
--- if they dont, redirect them to error page
Appreciate your input to try and get this working.
= httpd.conf ========================
RewriteMap checkAuth prg:/usr/app/scripts/check.pl
RewriteCond %{REQUEST_URI} /Restricted\+.*$
RewriteRule ^(.*)$ ${checkAuth:%{$1}} [L]
= check.pl ==========================
#!/usr/bin/perl
require "../web-common.pl";
$¦ = 1;
while (<STDIN>) {
if (!($userauth->authUser($_[0],'READ')) {
#return "Not Authorised";
return "https://ilisten/intranet-deny.cgi\n";
}
else {
#return "Authorised";
return "https://ilisten/$_\n";
}
}
[edited by: jdMorgan at 12:38 pm (utc) on Oct. 9, 2007]
[edit reason] Disabled smilies in code [/edit]
RewriteRule (.*Restricted.*) ${checkAuth:$1} [L]
Also, remember to completely flush your browser cache after any change to the code on your server.
Jim