Skip to main content
Known Participant
June 22, 2009
Question

How to secure one page not entire application?

  • June 22, 2009
  • 1 reply
  • 859 views

Hi there,

I'm looking for some guidance on how to secure individual pages on my site. I've read a number of articles discussing creating a login using the Application.cfc. The thing is this approach locks down the entire site. I only want to secure a page. In my scenario, if the user hasn't logged in, and goes to a profile.cfm page, they will be asked to login. Once they login, they will then be directed to the profile.cfm page.

Any and all advice would be greatly appreciated.

Thanks.

Novian

    This topic has been closed for replies.

    1 reply

    Inspiring
    June 22, 2009

    Hi, Novian,

    An option that come directly to mind is to check for the specific page to be locked down in onRequestStart of your Application.cfc.

    This approach is relatively easy to implement but may not be the best approach (don't know how it might affect performance or something else). Basically, use a conditional in your onRequestStart method to see if the page being requested by the user is the page that needs to be secured. Something along the lines of:

    <cffunction name="onRequestStart">

         <cfargument name="target_page" />

         <cfif target_page is 'super-secure-page.cfm'>

              <!--- security stuff --->

         </cfif>

    </cffunction>

    There are, of course, other options but this was a quick and easy one that came right to mind.

    Known Participant
    June 23, 2009

    Thanks, Craig. This did the trick.

    If you have time, I'd love to learn about the other approaches you alluded to. If you don't have time to explain, maybe you could provide me with some links that I could read over?

    Either way, thank you so much for your help. I really appreciate it.

    Novian