...
| No Format |
|---|
htdocs/site1/index.cfm
htdocs/site1/secure_pdfs/.htaccess
htdocs/site1/secure_pdfs/private.pdf
htdocs/site2/.htaccess
|
In the above example the "secure_pdfs/.htaccess" file contains:
| No Format |
|---|
AuthName Cornell AuthType All AuthBasicAuthoritative off require permit cit.coldfusion.support |
The "index.cfm" contains:
| No Format |
|---|
<cfoutput>
#REMOTE_USER#
</cfoutput>
<cfif REMOTE_USER EQ "emc256">
Hello you are Eric
<cfelse>
You are not authorized
</cfif>
|
When accessing the non-SSL portion of the site you'll only see:
| No Format |
|---|
You are not authorized
|
When I access the SSL portion I see:
| No Format |
|---|
emc256 Hello you are Eric
|
When you access the SSL portion you see:
| No Format |
|---|
You are not authorized
|
By placing the authentication/authorization decision in your application code it ensures that you do not inadvertently expose privileged information.
In this example this also allows you to have "site1....cornell.edu that is "public" and "site2...cornell.edu" that is restricted like below. Be careful not to place a top-level ".htaccess" file.
4. Suggested layout for a restricted site
If all your access is going to require authentication it is still a best practice to utilize application based authorization, but you have further options if you want to restrict all your sites. If you want to restrict all your sites you can place a top-level ".htaccess" file in your htdocs directory.
| No Format |
|---|
htdocs/.htaccess htdocs/site1/index.cfm htdocs/site2/index.cfm |
In the above example the ".htaccess" file contains:
| No Format |
|---|
AuthName Cornell
AuthType All
AuthBasicAuthoritative off
require permit cit.coldfusion.support
|
Unlike in the previous example both site1/site2 will inherit the permission that is set in the top-level restricted directory. You can only further restrict sub-directories using CU WebAuth. So it is not possible to limit the entire site to "staff" and then try and make a sub-directory accessible by "students"!