![MACROMEDIA COLDFUSION 4.5-DEVELOPING WEB Скачать руководство пользователя страница 297](http://html1.mh-extra.com/html/macromedia/coldfusion-4-5-developing-web/coldfusion-4-5-developing-web_develop-manual_3286369297.webp)
Chapter 17: Application Security
271
If a user passes the authentication test, ColdFusion passes a cookie to carry the
user’s authentication state to subsequent application pages governed by this
Application.cfm
page.
•
Next, only authenticated users are able to access the requested application
page, for selecting and updating customer orders in a database. This page
checks to see which resources the authenticated user is authorized to see and
use.
Authenticating users in Application.cfm
This example code for an
Application.cfm
page checks first to see whether the
current user is authenticated by checking to see if a login form was submitted. If the
username and password can be authenticated for the current security context, the user
passes through and the requested page is served.
If the
Application.cfm
page does not receive the user’s login information from the
previous page, it prompts the user to provide a username and password. The user’s
response is checked against the list of valid users defined for the current security
context.
If the user passes the authentication step too, the requested page appears. We use the
CGI variables script_name and query_string keep track of the page originally
requested. This way, once users are authenticated, we can serve the page they
originally requested.
All pages governed by this
Application.cfm
page — those in the same directory as
Application.cfm
and in its sub-tree — will invoke this authentication test.
Note
To use this code in your own
Application.cfm
page, change the
application name and security context name to match your application
and security names.
Example: Application.cfm
<CFAPPLICATION NAME="Orders">
<CFIF not IsAuthenticated()>
<!--- The user is not authenticated --->
<CFSET showLogin = "No">
<CFIF IsDefined("form.username") and
IsDefined("form.password")>
<!--- The login form was submitted --->
<CFTRY>
<CFAUTHENTICATE SecurityContext="Orders"
username="#form.username#"
password="#form.password#"
setCookie="YES">
<CFCATCH TYPE="security">
Содержание COLDFUSION 4.5-DEVELOPING WEB
Страница 1: ...Allaire Corporation Developing Web Applications with ColdFusion ColdFusion 4 5...
Страница 14: ...xiv Developing Web Applications with ColdFusion...
Страница 26: ...xxvi Developing Web Applications with ColdFusion...
Страница 34: ...8 Developing Web Applications with ColdFusion...
Страница 70: ...44 Developing Web Applications with ColdFusion...
Страница 84: ...58 Developing Web Applications with ColdFusion...
Страница 114: ...88 Developing Web Applications with ColdFusion...
Страница 148: ...122 Developing Web Applications with ColdFusion...
Страница 174: ...148 Developing Web Applications with ColdFusion...
Страница 208: ...182 Developing Web Applications with ColdFusion...
Страница 244: ...218 Developing Web Applications with ColdFusion...
Страница 274: ...248 Developing Web Applications with ColdFusion...
Страница 288: ...262 Developing Web Applications with ColdFusion...
Страница 300: ...274 Developing Web Applications with ColdFusion...
Страница 350: ...324 Developing Web Applications with ColdFusion...
Страница 362: ...336 Developing Web Applications with ColdFusion...