Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WWW-Authenticate

Status
Not open for further replies.

alvk

Programmer
Jul 24, 2000
2
FR
I want to use the HTTP header in order to obtain username and password.<br><br>With CFHeader, I've succeeded in lauching the browser popup for loggin in. But, HOW can I retrieve the username and password entered by the user ?<br><br>In PHP, there are two global variables to do that, what's up with ColdFusion ???<br><br>Thanks in advance,<br>Anne.
 
CFauthenticate<br>The CFauthenticate tag authenticates a user, setting a security context for the application. See the descriptions of the functions Isauthenticated and authenticatedContext.<br><br>Syntax<br>&lt;CFauthenticate SECURITYCONTEXT=&quot;context&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;USERNAME=&quot;user ID&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;PASSWORD=&quot;password&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;SETCOOKIE=&quot;yes/no&quot; <br>&nbsp;&nbsp;&nbsp;&nbsp;THROWONFAILURE=&quot;yes/no&quot;&gt;<br>SECURITYCONTEXT<br>Required. Security context with which the specified user is authenticated. This context must have been previously defined in the security system.<br><br>USERNAME<br>Required. User to be authenticated.<br><br>PASSWORD<br>Required. Password for the user.<br><br>SETCOOKIE<br>Optional. Default is Yes. Indicates whether ColdFusion sets a cookie to contain authentication information. This cookie is encrypted and its contents include user name, security context, browser remote address, and the HTTP user agent.<br><br>THROWONFAILURE<br>Optional. Default is Yes. Indicates whether ColdFusion throws an exception (of type SECURITY) if authentication fails.<br><br>Usage<br>Code this tag in the Application.cfm file to set a security context for your application. <br><br>Call the Isauthenticated function to determine if the user has been authenticated. If you specify No for SETCOOKIE, you must call CFauthenticate for every page in the application (perhaps in an Application.cfm file).<br><br>If you specify THROWONFAILURE=Yes, you can enclose CFauthenticate in a CFTRY/CFCATCH block to handle possible exceptions programmatically.<br><br>Example<br>&lt;!--- This example shows the use of CFauthenticate<br>in an Application.cfm file ---&gt;<br>&lt;CFIF NOT Isauthenticated()&gt;<br>&nbsp;&nbsp;&lt;CFTRY&gt;<br>&nbsp;&nbsp;&lt;CFauthenticate SECURITYCONTEXT=&quot;Allaire&quot; USERNAME=#user#<br>&nbsp;&nbsp;&nbsp;&nbsp;PASSWORD=#pwd#&gt;<br>&nbsp;&nbsp;&lt;CFCATCH TYPE=&quot;Security&quot;&gt;<br>&nbsp;&nbsp;&nbsp;&lt;!--- the message to display ---&gt;<br>&nbsp;&nbsp;&nbsp;&lt;H3&gt;Authentication error&lt;/H3&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;CFOUTPUT&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;!--- Display the message. Alternatively, you might place<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;code here to define the user to the security domain. ---&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;P&gt;#CFCATCH.message#<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;/CFOUTPUT&gt;<br>&nbsp;&nbsp;&lt;/CFCATCH&gt;<br>&nbsp;&nbsp;&lt;/CFTRY&gt;<br>&lt;/CFIF&gt;<br>&lt;CFAPPLICATION NAME=&quot;Personnel&quot;&gt;<br>...<br> <p>Russ Michaels<br><a href=mailto:russ@satachi.com>russ@satachi.com</a><br><a href= Internet Development</a><br>For my personal book recommendations visit <br>
 
I'm afraid that CFAuthenticate is not the answer for my problem. Maybe I haven't understood how to use it with the browser popup window and not an html form for entering username and password.<br><br>In the example you gave, you have to pass username and password to the CFAuthenticate tag. I want them to be entered in the &quot;browser popup window&quot; as it happens when you send the header with status 401 and can I access to these elements just known by the browser ?<br><br>For people who know PHP, I'm looking for equivalent to variables PHP_AUTH_USER and PHP_AUTH_PWD.<br><br>Anne.
 
#CGI.AUTH_USER# and<br>#CGI.AUTH_PASSWORD#...<br><br>Check your docs for all the rest of the &quot;CGI&quot; variables...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top