Jump to content


Photo

$_SERVER["REMOTE_USER"] blank.. but not really?


  • Please log in to reply
9 replies to this topic

#1 jgauthier

jgauthier

    Newbie

  • New Members
  • Pip
  • 4 posts

Posted 02 December 2013 - 02:13 PM

I have a PHP application behind apache.  Apache was using NTML authentication and serving the page from the local host.

I've changed things around, and moved the authentication to an external apache server using SAML2.

The new apache system is also functioning as a reverse proxy for the application.

 

Once I got all the auth pieces working, but my app complains there is no user being passed.

Interesting.  So, I whip up this simple page:

<?php
phpinfo();

foreach (getallheaders() as $name => $value) {
        echo "$name: $value\n";
}

print "User name: \"".$_SERVER["REMOTE_USER"]."\"";
?>

phpinfo() and the foreach both reveal that HTTP_USER is being set.

However, the explicit call for REMOTE_USER comes up blank!

 

The application is open source, so I can see they are calling $_SERVER["REMOTE_USER"].

I have another application that is closed source, but exhibits the same symptoms. It shows me the variables, but the authorization mechanism cannot seem to process the user.

 

This very well may not be a PHP issue at all, but since I can reproduce it within PHP, I figured I would start here to dig deeper into how this works, and where the fault may be.

 

Thanks!


Edited by jgauthier, 02 December 2013 - 02:20 PM.


#2 dalecosp

dalecosp

    Advanced Member

  • Members
  • PipPipPip
  • 285 posts
  • LocationJoplin, MO

Posted 02 December 2013 - 04:17 PM

Does $_SERVER['REDIRECT_REMOTE_USER'] get populated?


"God doesn't play dice" --- Albert Einstein
"Perl is hardly a paragon of beautiful syntax." --- Weedpacket

#3 jgauthier

jgauthier

    Newbie

  • New Members
  • Pip
  • 4 posts

Posted 02 December 2013 - 04:29 PM

I don't see any reference to it in the output.

 

But I can add it in httpd.conf:

RequestHeader set REDIRECT_REMOTE_USER %{REMOTE_USER}s


Edited by jgauthier, 02 December 2013 - 04:30 PM.


#4 requinix

requinix

    Playful Member

  • Moderators
  • 5,744 posts
  • LocationWA

Posted 02 December 2013 - 05:39 PM

Could it be that the new Apache configuration isn't setting the REMOTE_USER?

#5 Ch0cu3r

Ch0cu3r

    Advanced Member

  • Moderators
  • 1,713 posts

Posted 02 December 2013 - 06:16 PM

 

 

phpinfo() and the foreach both reveal that HTTP_USER is being set.
However, the explicit call for REMOTE_USER comes up blank!

 

Then shouldn't you be using $_SERVER["HTTP_USER"] instead of $_SERVER["REMOTE_USER"]?

  



#6 jgauthier

jgauthier

    Newbie

  • New Members
  • Pip
  • 4 posts

Posted 03 December 2013 - 04:27 PM

That's a typo in my message. I am using  REMOTE-USER. Which appears to be correct when I look at all the headers, but empty when I call it explicitly.

I am pretty sure this is an apache config issue, but I am stumped with it.



#7 requinix

requinix

    Playful Member

  • Moderators
  • 5,744 posts
  • LocationWA

Posted 03 December 2013 - 05:11 PM

REMOTE-USER is not correct. It should be REMOTE_USER or maybe HTTP_USER.

#8 jgauthier

jgauthier

    Newbie

  • New Members
  • Pip
  • 4 posts

Posted 04 December 2013 - 10:29 AM

I have set REMOTE_USER, the same thing occurs.



#9 jazzman1

jazzman1

    Advanced Member

  • Gurus
  • 2,250 posts
  • LocationMississauga, Canada

Posted 04 December 2013 - 12:55 PM

Are you able to apply some debugging steps? Any errors? This would be a good start for us. 



#10 dalecosp

dalecosp

    Advanced Member

  • Members
  • PipPipPip
  • 285 posts
  • LocationJoplin, MO

Posted 04 December 2013 - 01:00 PM

I'm tending to think the key to this is in the original post ...

 

 

 

reverse proxy


... unfortunately, all I've ever done with proxies is cache and deny access to pr0n sites.

edit: And Woah!  Gotta love English ... "cache site pages and deny access to..."


Edited by dalecosp, 04 December 2013 - 01:01 PM.

"God doesn't play dice" --- Albert Einstein
"Perl is hardly a paragon of beautiful syntax." --- Weedpacket




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com