So this weekend, Bruce Phillips pointed out on my last Flex Homework post that he only needed to run the CFLOGIN tag once in his Flex application. My code was running it for every hit in the onRequestStart method.
So this really bugged me because it was my understanding that ColdFusion had to run the CFLOGIN tag during a request to "enable" Roles Based Security. I knew that ColdFusion would skip the stuff inside - but from what I had remembered, CF had to actually encounter the tag to use Roles Based Security for the test. But when I tested what Bruce had done in his Flex app, it worked as he had said. I was truly perplexed. Then I did a test:1 <cfapplication name="goobercflogin" sessionManagement="true">
2
3 <cflogin>
4 <cfloginuser name="ray2" password="ray" roles="admin">
5 </cflogin>
6 <cfoutput>#getAuthUser()#</cfoutput>
7
8 <cfif isUserInRole("admin")>
9 <p>
10 yes, admin role
11 </p>
12 </cfif>
I ran this - and then ran it again with the cflogin block commented out - and it worked just fine. Bruce was definitely right. But then I tried this:
2
3 <cflogin>
4 <cfloginuser name="ray2" password="ray" roles="admin">
5 </cflogin>
6 <cfoutput>#getAuthUser()#</cfoutput>
7
8 <cfif isUserInRole("admin")>
9 <p>
10 yes, admin role
11 </p>
12 </cfif>
1 <cfapplication name="goobercflogin2" sessionManagement="true" loginStorage="session">
2
3 <cflogin>
4 <cfloginuser name="ray2" password="ray" roles="admin">
5 </cflogin>
6
7
8 <cfoutput>#getAuthUser()#</cfoutput>
9
10 <cfif isUserInRole("admin")>
11 <p>
12 yes, admin role
13 </p>
14 </cfif>
Notice the loginStorage? That tells ColdFusion to use the session scope for the authentication. Now in theory, this should ONLY change the storage method for the authentication information. But when you comment out CFLOGIN, you no longer get a value for getAuthUser and the roles check failed.
I'll wrap with one final word: Ugh.
2
3 <cflogin>
4 <cfloginuser name="ray2" password="ray" roles="admin">
5 </cflogin>
6
7
8 <cfoutput>#getAuthUser()#</cfoutput>
9
10 <cfif isUserInRole("admin")>
11 <p>
12 yes, admin role
13 </p>
14 </cfif>
Comment 1 written by Mark Fuqua on 27 November 2006, at 6:01 PM
Comment 2 written by Joe Rinehart on 27 November 2006, at 7:35 PM
I've been dealing with this problem in Web Services for a while...the solution I used works well in Flex. I blogged it here:
http://www.firemoss.com/blog/index.cfm?mode=entry&...
Comment 3 written by Raymond Camden on 27 November 2006, at 8:59 PM
Comment 4 written by Meep on 28 November 2006, at 9:16 AM
Just curious to everyone heres opinion on the matter since as I said I don't have a long CF background so I feel like its hard to discern things in the environment I'm in.
Comment 5 written by Raymond Camden on 28 November 2006, at 9:56 AM
Comment 6 written by TJ Downes on 28 November 2006, at 11:01 AM
Unfortunately over the last few months I discovered a couple of things which have changed my mind about CFLOGIN.
First and foremost, CFLOGIN runs on every request. In a high-traffic environment this could cost you significanty.
Secondly, there is a bug in Flash player that prevents file uploads from happening in Firefox (PC and Mac) and Safari when using CFFORM when the format is Flash. Technically this is an issue with Flash, not CFLOGIN. However, by avoiding the use of CFLOGIN altogether, I would not have encountered this issue. Now I am in a position of redesigning my entire security schema for a particular app because the majority of users using my tools are FF or Safari users.
My advice: skip CFLOGIN.
Comment 7 written by Sami Hoda on 28 November 2006, at 1:43 PM
Maybe you and I can tag team on this one as an Enhancement Request/Bug entry for Scorpio. They seem to listen when more than one person complains. What do you think? I'd like to cflogin fixed rather than rip it out of my code as well.
Sami
Comment 8 written by James Edmunds on 29 November 2006, at 8:28 AM
Comment 9 written by Chris on 31 January 2008, at 9:30 AM
Comment 10 written by Raymond Camden on 31 January 2008, at 9:37 AM
Comment 11 written by Scott on 8 July 2008, at 4:42 PM
Comment 12 written by Adam Bellas on 5 January 2009, at 9:35 PM
We tried inventing a roll-you-own system to handle AJAX security and it's just not as easy and fast as the built in stuff. If you can stomach the CFLOGIN roller-coaster of woe, that is.
Comment 13 written by Reinhard Jung on 17 November 2009, at 6:26 PM
[Add Comment] [Subscribe to Comments]