Authentication: Preparation

From The Uniform Server Wiki
Jump to navigation Jump to search
Basic Authentication

Preparation

To explore directory authentication we require a few folders to work with. This page provides details for setting up a working structure including htaccess files I have purposefully kept the files as small as possible. We are not interested in great works of art hence the minimalist approach.

Structure

We are going to set-up a folder structure for the following users John, Dave Smith, Dawn and Ruth Smith as follows:

John

  • Create a new folder UniServer\udrive\www\john
  • Copy file UniServer\udrive\www\.htaccess to folder john
  • Edit .htaccess delete all lines above the authentication block.
  • Edit the four lines as shown:
AuthName "Uniform Server - Server Access"
AuthType Basic
AuthUserFile /htpasswd/www/.htpasswd
Require user John

Create a new text file index.html in folder john add the following text:

<html><head><title>John</title></head>
<body><h1>John</h1>
<p><a href="http://localhost/../">Home</a></p>
<p><a href="http://localhost/../john/">John</a></p>
<p><a href="http://localhost/../dave_smith/">Dave Smith</a></p>
<p><a href="http://localhost/../dawn/"">Dawn</a></p>
<p><a href="http://localhost/../ruth_smith/">Ruth Smith</a></p>
</body></html>

Top

Dave Smith

  • Create a new folder UniServer\udrive\www\dave_smith
  • Copy file UniServer\udrive\www\.htaccess to folder dave_smith
  • Edit .htaccess delete all lines above the authentication block.
  • Edit the four lines as shown:
AuthName "Uniform Server - Server Access"
AuthType Basic
AuthUserFile /htpasswd/www/.htpasswd
Require user "Dave Smith"

Create a new text file index.html in folder dave_smith add the following text:

<html><head><title>Dave Smith</title></head>
<body><h1>Dave Smith</h1>
<p><a href="http://localhost/../">Home</a></p>
<p><a href="http://localhost/../john/">John</a></p>
<p><a href="http://localhost/../dave_smith/">Dave Smith</a></p>
<p><a href="http://localhost/../dawn/">Dawn</a></p>
<p><a href="http://localhost/../ruth_smith/">Ruth Smith</a></p>
</body></html>

Top

Dawn

  • Create a new folder UniServer\udrive\www\dawn
  • Copy file UniServer\udrive\www\.htaccess to folder dawn
  • Edit .htaccess delete all lines above the authentication block.
  • Edit the four lines as shown:
AuthName "Uniform Server - Server Access"
AuthType Basic
AuthUserFile /htpasswd/www/.htpasswd
Require user Dawn

Create a new text file index.html in folder dawn add the following text:

<html><head><title>Dawn</title></head>
<body><h1>Dawn</h1>
<p><a href="http://localhost/../">Home</a></p>
<p><a href="http://localhost/../john/">John</a></p>
<p><a href="http://localhost/../dave_smith/">Dave Smith</a></p>
<p><a href="http://localhost/../dawn/">Dawn</a></p>
<p><a href="http://localhost/../ruth_smith/">Ruth Smith</a></p></body></html>


Ruth Smith

  • Create a new folder UniServer\udrive\www\ruth_smith
  • Copy file UniServer\udrive\www\.htaccess to folder ruth_smith
  • Edit .htaccess delete all lines above the authentication block.
  • Edit the four lines as shown:
AuthName "Uniform Server - Server Access"
AuthType Basic
AuthUserFile /htpasswd/www/.htpasswd
Require user "Ruth Smith"

Create a new text file index.html in folder dave_smith add the following text:

<html><head><title>Ruth Smith</title></head>
<body><h1>Ruth Smith</h1>
<p><a href="http://localhost/../">Home</a></p>
<p><a href="http://localhost/../john/">John</a></p>
<p><a href="http://localhost/../dave_smith/">Dave Smith</a></p>
<p><a href="http://localhost/../dawn/">Dawn</a></p>
<p><a href="http://localhost/../ruth_smith/">Ruth Smith</a></p>
</body></html>

Top

Root folder www

On the previous page we created a private server this restriction needs to be removed edit file UniServer\udrive\www\.htaccess comment the four authentication lines as shown.

#AuthName "Uniform Server - Server Access"
#AuthType Basic
#AuthUserFile /htpasswd/www/.htpasswd
#Require user John  "Dave Smith"

Create a new text file index.html in folder UniServer\udrive\www add the following text:

<html><head><title>Server</title></head>
<body>
<p><a href="http://localhost/john/"">John</a></p>
<p><a href="http://localhost/dave_smith/">Dave Smith</a></p>
<p><a href="http://localhost/dawn/">Dawn</a></p>
<p><a href="http://localhost/ruth_smith/">Ruth Smith</a></p>
</body></html>

Displays a page with links saves some typing during testing.

Note: Moved Servers

If you moved the servers see Multi-Servers remember to add the correct port numbers.

  • Suppose the server was moved to ports Apache 81 Apache SSL 444 the index.html file will look like this:
<html><head><title>Server</title></head>
<body>
<p><a href="http://localhost:81/john/"">John</a></p>
<p><a href="http://localhost:81/dave_smith/">Dave Smith</a></p>
<p><a href="http://localhost:81/dawn/">Dawn</a></p>
<p><a href="http://localhost:81/ruth_smith/">Ruth Smith</a></p>
</body></html>

Top

Summary

The above folder structure is adequate for exploring authentication directives mentioned on the introduction page.

On the next page we explore the above structure and directory access.

Top


Ric