Forum Moderators: coopster

Message Too Old, No Replies

AARGH! Authenticating RSS Feeds!

I can't get my feeds to honor logins!

         

cmarshall

1:55 pm on Nov 6, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Folks,

This is driving me nuts (actually, it's more of a short putt *<:o)

I have a feed that I really want to provide to the correct people.

Here's the teensy bit of code I use to extract the login and password:


header('WWW-Authenticate');
$login = $_SERVER['PHP_AUTH_USER'];
$password = $_SERVER['PHP_AUTH_PW'];

If this is passed, I use the login and password to log into the system, and open the gate to the feed.

I get an alert, asking for the password (GRR. It won't honor my RSS reader's embedded login and password).

I know that I'm doing SOMETHING wrong, because it isn't getting the right information and logging me in.

I can find almost zero information on the Web for the feed side. There's all kinds of stuff for the reader side, but that don't do me much good.

I'm sure the solution is absurdly simple. Any pointers to the correct M for me to RTFM would be appreciated.

coopster

1:36 pm on Nov 12, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



It's not entirely clear where your issue is, not to me at least. Here is the manual page that you may be looking for though ...

HTTP authentication with PHP [php.net]

mcibor

10:18 pm on Nov 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



As you might have read Coop's suggestion, you don't check if it isn't already sent, but send it always.

Try this out

if (!isset($_SERVER['PHP_AUTH_USER']))
{
header('WWW-Authenticate: Basic realm="My Realm"');
header('HTTP/1.0 401 Unauthorized');
echo 'You are not authorized to view this page.
exit;
}
$login = $_SERVER['PHP_AUTH_USER'];
$password = $_SERVER['PHP_AUTH_PW'];

//validate user
if(!$valid)
{
header('WWW-Authenticate: Basic realm="My Realm"');
header('HTTP/1.0 401 Unauthorized');
echo 'Login or password incorrect. You are not authorized to view this page.
exit;
}

This should work for you.

Regards
Michal

cmarshall

2:11 pm on Nov 19, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks. I did get it going, using code very similar to what mcibor suggested.

I still can't get it to honor the login/password I set in the reader, but this does put up an alert and makes them log in.

Methinks this is still fairly green stuff.