|
Authentication: Introduction | Preparation | Directories | Secure Directories | Groups | Single Files | Secure Single Files |
| Basic Authentication |
Authentication Groups
For small organisations maintainability becomes time consuming and can quickly get out of control. An ideal solution is to use a groups file the following page introduces the general concept.
You have a number of directories where certain individuals can have access to all these for example administrators. Certain directories are restricted to directors and managers while critical material is accessible only by the managing.
The above is a little contrived but gives four grounps ceo, directors, managers and admins. For this example I will use the password list from the introduction page:
root:root John:john123 Dave Smith:dave123 Mike:mike123 Jane:jane123 Dawn:dawn123 Ruth Smith:ruth123
Single member groups are useful because it avoids hard coding specific names in the htaccess file.
| ceo | directors | managers | admins |
| John:john123 | Dave Smith:dave123 | Mike:mike123 | root:root |
| Ruth Smith:ruth123 | Jane:jane123 | ||
| Dawn:dawn123 |
Note 1: Delete the first entry root:root (everyone knows this) I use it only for testing
A groups file consists of separate lines for each group. Each line starts with a group name followed by a colon and a space-separated list of users in that group. If the list of users is large start a new line, use the same group name followed by a colon and continue with the list of names for that group.
The groups file is named .htgroup (if you wish use a different name)
Create the following file UniServer\udrive\htpasswd\www\.htgroup
Add the following groups:
ceo:John directors:"Dave Smith" "Ruth Smith" managers:Mike Jane Dawn admin:root
Note 1: Enclose names with spaces in quotes.
Apache needs to find the group file hence add the path as shown:
AuthGroupFile /htpasswd/www/.htgroup
The require line changes to Require group:
Require group "group name 1" "group name 2
Modified .htaccess files are shown below:
SSLOptions +StrictRequire
SSLRequireSSL
SSLRequire %{HTTP_HOST} eq "localhost"
ErrorDocument 403 https://localhost/john/
AuthName "Uniform Server - Server Access"
AuthType Basic
AuthUserFile /htpasswd/www/.htpasswd
AuthGroupFile /htpasswd/www/.htgroup
Require group ceo
SSLOptions +StrictRequire
SSLRequireSSL
SSLRequire %{HTTP_HOST} eq "localhost"
ErrorDocument 403 https://localhost/dave_smith/
AuthName "Uniform Server - Server Access"
AuthType Basic
AuthUserFile /htpasswd/www/.htpasswd
AuthGroupFile /htpasswd/www/.htgroup
Require group ceo directors
SSLOptions +StrictRequire
SSLRequireSSL
SSLRequire %{HTTP_HOST} eq "localhost"
ErrorDocument 403 https://localhost/dawn/
AuthName "Uniform Server - Server Access"
AuthType Basic
AuthUserFile /htpasswd/www/.htpasswd
AuthGroupFile /htpasswd/www/.htgroup
Require group managers
SSLOptions +StrictRequire
SSLRequireSSL
SSLRequire %{HTTP_HOST} eq "localhost"
ErrorDocument 403 https://localhost/ruth_smith/
AuthName "Uniform Server - Server Access"
AuthType Basic
AuthUserFile /htpasswd/www/.htpasswd
AuthGroupFile /htpasswd/www/.htgroup
Require group ceo directors
If you moved the servers see Multi-Servers remember to add the correct port numbers.
SSLOptions +StrictRequire
SSLRequireSSL
SSLRequire %{HTTP_HOST} eq "localhost:444"
ErrorDocument 403 https://localhost:444/dave_smith/
AuthName "Uniform Server - Server Access"
AuthType Basic
AuthUserFile /htpasswd/www/.htpasswd
AuthGroupFile /htpasswd/www/.htgroup
Require group ceo directors
Note: The above applies to all the .htaccess files.
Run the servers and check folders are accessible.
One final test which demonstrates the power of groups.
Add the root admin to the groups as shown:
ceo:John root directors:"Dave Smith" "Ruth Smith" root managers:Mike Jane Dawn root admin:root
Restart the browser log in to any user, use name/password root root.
That wraps it up for password protecting folders. Apache’s Basic Authentication offers a very flexible solution, using groups extends this flexibility into a manageable system even for medium sized companies.
Occasionally you may want to protect only a single file and not a complete folder this is covered on the next page.
| | Ric |