-1

I've found questions like this:

Why are $_SERVER["PHP_AUTH_USER"] and $_SERVER["PHP_AUTH_PW"] not set?

Usually the question is why are PHP_AUTH_USER and PHP_AUTH_PW not set. And the explanation is usually:

As of PHP 4.3.0, in order to prevent someone from writing a script which reveals the password for a page that was authenticated through a traditional external mechanism, the PHP_AUTH variables will not be set if external authentication is enabled for that particular page and safe mode is enabled. Regardless, REMOTE_USER can be used to identify the externally-authenticated user. So, you can use $_SERVER['REMOTE_USER'].

...

PHP uses the presence of an AuthType directive to determine whether external authentication is in effect.

Note, however, that the above does not prevent someone who controls a non-authenticated URL from stealing passwords from authenticated URLs on the same server.

The thing is that I have tried an example with external authentication, and the PHP_AUTH variables are actually set. I'm using PHP 7.4.3, so I suspect this explanation applies no more, because the first part has been removed from the current documentation. However you can still read the latter part:

Note: Configuration Note
PHP uses the presence of an AuthType directive to determine whether external authentication is in effect.

Note, however, that the above does not prevent someone who controls a non-authenticated URL from stealing passwords from authenticated URLs on the same server.

So I'm confused. It seems these variables are set regardless of AuthType directives, but I really would like to confirm that point.

Thanks.

EDIT: (solution)

Thanks to the answer by @symcbean, I realized that in order to have the PHP_AUTH variables not set, safe mode had to be on. And after a bit of research, that safe mode option is removed from PHP. That's why this part was removed from the docs, and so here is the answer:

PHP_AUTH variables will always be set, even in case of external authentication.

Pep
  • 625
  • 4
  • 19

1 Answers1

1

I have tried an example with external authentication, and the PHP_AUTH variables are actually set

But you didn't show is the code. Did you read the source documentation you quoted here:

will not be set if external authentication is enabled for that particular page and safe mode is enabled

symcbean
  • 47,736
  • 6
  • 59
  • 94
  • Oh, I see. Thanks a lot to make me realize (and sorry). – Pep Oct 31 '21 at 21:59
  • I've been researching that safe mode option, and it looks it's a deprecated thing. So at the end of the day, I assume that the right answer is: **yeah, currently those PHP_AUTH will always be set no matter what**. – Pep Oct 31 '21 at 22:36