IBM®
Skip to main content
    Country/region [select]      Terms of use
 
 
     Home      Products      Services & solutions      Support & downloads      My account     
  IBM Wikis > PHP: Zend for i5/OS > ... > 03-03-00 Configuring Zend Core for i5!OS > 03-03-01 Basic Authentication Example
PHP: Zend for i5/OS Log In | Sign Up   View a printable version of the current page.
03-03-01 Basic Authentication Example
Added by Tony Cairns, last edited by Mike Schwartz on Mar 07, 2007  (view change)
Labels: 
(None)

Show/Hide Navigation Tree
Navigation Tree

TOC Previous Next

Basic Authentication Configuration

Here is a basic authentication Apache configuration via a minor modification to the default ZENDCORE:89 configuration. The Apache directive Location / will force basic authentication for any user attempting to use http port 89 (no change to PASE Apache is required). We recommend you use Apache directive ProxyPreserveHost On for environment variables passed to PASE Apache.

ProxyPreserveHost On
<Directory />
   Order Deny,Allow
   Deny From all
</Directory>
<Directory /www/zendcore/htdocs>
   Order Allow,Deny
   Allow From all
</Directory>
<Location />
    AuthType Basic
    AuthName "Authentication Domain Goes Here"
    Require valid-user
    PasswdFile %%SYSTEM%%
    ProfileToken On
    Allow from all
</Location>
ProxyPass / http://127.0.0.1:8000/
ProxyPassReverse / http://127.0.0.1:8000/

The following PHP program can be used with the above Apache configuration to examine the userid and password passed.

<?php
  if (!isset($_SERVER['PHP_AUTH_USER'])) {
    header('WWW-Authenticate: Basic realm="My Realm"');
    header('HTTP/1.0 401 Unauthorized');
    echo 'Text to send if user hits Cancel button';
    exit;
  } else {
    echo "<p>Hello {$_SERVER['PHP_AUTH_USER']}.</p>";
    echo "<p>You entered {$_SERVER['PHP_AUTH_PW']} as your password.</p>";
  }
?>
output:
Hello ranger.
You entered "secret" as your password.
Status of this page

Not reviewed, Not edited.

TOC Previous Next

Top 5 contributors
to this page
UserEdits
Mike Schwartz 3
Tony Cairns 2
The postings on this site solely reflect the personal views of the authors and do not necessarily represent the views, positions, strategies or opinions of IBM or IBM management.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.2.10 Build:#528 Nov 29, 2006)
    About IBM Privacy Contact