PHP_AUTH_USER with Foundry?


#1

Hi, a question just to make sure I am not missing anything.
Does Foundry offer some user security, handling $_SERVER[‘PHP_AUTH_USER’] (I would need/use in a Windows domain intranet environment)?
I know Vibralogix Sitelok, but that is “standalone”, e.g. meant for a internet website, not an intranet Win domain logic.
Any thoughts?
Thanks, Igor


#2

Sorry, just minutes after I posted I got something to work.
The logic must be set first on the webpage, before DOCTYPE.
Thanks anyway.

BUT, another question:
How can I best show/hide parts on a page evaluating PHP_AUTH_USER, e.g. user x may see a part, but user y may not?
How do I enclose stack elements in such a logic to been seen or hidden?

Cheers, Igor


#3

That would not be something Foundry handles. You can use other stacks or plugins to handle that, but the framework itself is not going to deal with that.


#4

Thanks Adam, that’s what I thought.
Got it worked out, though.
So, if anyone is interested, here it goes:

<!-- this goes top page, prefix, just before DOCTYPE -->
<?php
	if (!isset($_SERVER['PHP_AUTH_USER'])) { 
	    header('WWW-Authenticate: Basic realm="SomeRealm"' );
	    header('HTTP/1.0 401 Unauthorized');
	    echo "No access";
	    exit;
	}
?>

<!-- how to display/hide a contained stack based on PHP_AUTH_USER -->
<!-- with Joe Workmans HTML Enclosure stack -->
<!-- but should work fine also with standard text/HTML/text stacks -->
<?php
	if (($_SERVER['PHP_AUTH_USER']) == 'myUserName') { 
		echo '<div class="someclass" style="display:inline">';
	} 
	else { 
		echo '<h3>Auth_user -if set- its value is ['.$_SERVER['AUTH_USER'].']</h3>'; 
		echo '<div class="someclass" style="display:none">';
	}
?>
 --- then put a stack inside the stack drop zone ---
<?php
	echo '</div>';
?>

Of course, this is absolute basic php, no particular logic besides checking if the user accessing is me. The idea is to further develop this to work for my group…
Cheers, Igor