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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with AJAX and Authentication

Status
Not open for further replies.

isporter

Programmer
Oct 18, 2007
11
GB
I'm developing an eCommerce application. A page's content is written to the page from the server, to ensure the search engines see it.

On the client-side, I add event handlers to various elements on the page. Some of these event handlers should only be present if the user is logged in - i.e. the menu should only be draggable (for reordering) when an appropriately authenticated user is logged in.

However, I'm conscious that any variable on the client-side indicated whether the user is authenticated or not is susceptible to manipulation by a hacker. Thus, how do I ensure the security of my application?

Is the following a common solution: I pass a value (i.e. 'authenticated' or 'not authenticated' to a hidden input on the page, and use this value in client-side code to determine whether to attach the event handlers. Hackers can of course thus gain access to the interface. But then any execution of server-side code via AJAX first require authentication with a Session Variable. i.e. if the user isn't authenticated on the server side, the code doesn't get executed?

Thanks,
Iain
 
Ideally you would use something like session variables to store this information. These are only available server-side and can be used to determine what your back-end delivers to the page.

If you are using a load-balanced web hosting solution, you will have to ensure the load-balancer has session affinity enabled.

Cheers,
Jeff

[tt]Jeff's Blog [!]@[/!] CodeRambler
[/tt]

Make sure your web page and css validates properly against the doctype you have chosen - before you attempt to debug a problem!

FAQ216-6094
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top