Reply
pass username/password from a script into http basic authentication
Old 04-20-2008, 11:23 PM pass username/password from a script into http basic authentication
Junior Talker

Posts: 3
Name: Anon Hanon
I am protecting a series of pdf files with http basic authenication using a htaccess file. Currently I have users click a link that links to a perl script in a password protected directory. This forces them to login and then the perl script redirects them to the correct pdf file based on their username. All of the pdf files are username.pdf.

What I really want is them to type in their username and password into a html form and this form to pass the values to some script that could redirect them and send username and password data to htaccess so that they are automatically authenicated. Is this possible?

I know how to write a perl script to redirect them based off a html form inputted username but I do not know how to pass the values to http authentication.

Thanks.

Last edited by PleaseDontBugMe : 04-20-2008 at 11:25 PM. Reason: clarify that I know how to redirect based on the username
PleaseDontBugMe is offline
Reply With Quote
View Public Profile
 
Sponsored Links (We share ad revenue):
 
Old 04-23-2008, 10:39 AM Re: pass username/password from a script into http basic authentication
willcode4beer's Avatar
Webmaster Talker

Posts: 525
Name: Paul Davis
Location: San Francisco
just a thought but, why not have the perl script just write the file back to the user (avoid the whole htaccess bit altogether)

OTOH, if you do want to continue down this path....
have the perl 302 redirect send them to the htaccess controlled file like this:
__________________
Paul Davis
willCode4Beer.com (coding for all the right reasons)
willcode4beer is offline
Reply With Quote
View Public Profile
 
Old 04-26-2008, 03:06 PM Re: pass username/password from a script into http basic authentication
Ultra Talker

Posts: 408
How about this:

Code:
RewriteRule (.*\.pdf)$ auth.cgi?pdf=$1
Then auth.cgi would check to see if the user is logged in, and if so, it would send the PDF headers and output the document.
Lucas3677 is offline
Reply With Quote
View Public Profile Visit Lucas3677's homepage!
 
Old 04-29-2008, 09:44 AM Re: pass username/password from a script into http basic authentication
addonchat's Avatar
Skilled Talker

Posts: 97
Name: Chris Duerr
Quote:
Originally Posted by willcode4beer View Post
just a thought but, why not have the perl script just write the file back to the user (avoid the whole htaccess bit altogether)
+1

Put the PDF files in an unaccessible directory, then just spit the file out:
Code:
#!/usr/bin/perl

print "Content-type: application/pdf\n\n";
open(FILE, "somefile.pdf") or die ("Cannot open file");
@data = <FILE>;
close(FILE);
foreach $line (@data) { print $line; }
__________________
Chris Duerr
AddonChat Java Chat Software
http://www.addonchat.com/ - Affiliate Program
addonchat is offline
Reply With Quote
View Public Profile
 
Old 04-29-2008, 10:47 AM Re: pass username/password from a script into http basic authentication
tripy's Avatar
Fetchez la vache!

Latest Blog Post:
Pretty pretty please….
Posts: 1,689
Name: Thierry
Location: In the void
Whoohoo, hey, look at that !
Comprehensible Perl code !

A true wonder of the world...
Tried to add TP, but could not. I have to "spread some more" before, but I needed to say that
__________________
Listen to the ducky: "This is awesome!!!"

tripy is online now
Reply With Quote
View Public Profile
 
Old 04-29-2008, 11:01 AM Re: pass username/password from a script into http basic authentication
addonchat's Avatar
Skilled Talker

Posts: 97
Name: Chris Duerr
lol I try.
__________________
Chris Duerr
AddonChat Java Chat Software
http://www.addonchat.com/ - Affiliate Program
addonchat is offline
Reply With Quote
View Public Profile
 
Old 04-30-2008, 10:36 PM Re: pass username/password from a script into http basic authentication
Junior Talker

Posts: 3
Name: Anon Hanon
Is there anyway to do something similar in PHP?
PleaseDontBugMe is offline
Reply With Quote
View Public Profile
 
Old 04-30-2008, 11:15 PM Re: pass username/password from a script into http basic authentication
addonchat's Avatar
Skilled Talker

Posts: 97
Name: Chris Duerr
PHP Code:
<?php

   header
("Content-type: application/pdf");   
   echo 
file_get_contents("somefile.pdf");

?>
__________________
Chris Duerr
AddonChat Java Chat Software
http://www.addonchat.com/ - Affiliate Program
addonchat is offline
Reply With Quote
View Public Profile
 
Old 05-01-2008, 12:38 AM Re: pass username/password from a script into http basic authentication
Junior Talker

Posts: 3
Name: Anon Hanon
Thank you to all of you. I cannot thank you enough. I have searched the web and have not found a solution until you guys answered my question.
PleaseDontBugMe is offline
Reply With Quote
View Public Profile
 
Sponsored Links (We share ad revenue):
 
Reply     « Reply to pass username/password from a script into http basic authentication
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML


Page generated in 0.19496 seconds with 14 queries