Quote:
Originally Posted by TheApprentice
1) Users being able to navigate through my site folders to find the file which containes the password. Even if my .js file is aprt from the html code, they can get the path of my file from the html page and then enter it in the browser window to get the source code and hence the password.
2) Users bypassing the password page through a google search which would allow them to access certain pages of my website directly.
Any EASY workaround that for a newbie programmer?
|
No. Javascript is inherently insecure, and any password is visible to the user with View Source.
You can obfuscate the password a little, but of course any user familiar with Javascript can very quickly unravel it.
Code:
var password = "70617373776f7264"
var result = "";
for (var i=0;i<password.length;i=i+2) {result=result+'%'+password.substr(i,2);}
var pwd = unescape(result);
alert (pwd); // password
You can block users from navigating direct to your web pages with a session cookie which is set on the password page. If the cookie does not exist access is denied. You will need to use <noscript> to block those with Javascript disabled.