views:

39

answers:

2

TLDR Using plain HTML / Javascript. Want to block access to some pages (doesn't have to be super secure just to stop some peeking eyes).

I would like this to be a discussion preferably on different ways of doing this? If anyone has any other ideas than using cookies or differeny ways to do this.


I thought of simply doing this by setting a cookie for each page they are allowed to visit with a value of true but thats a bit messy. Although it would work. Is there a way to set an array of values to a cookie so I can read the cookie and if a name of a page is in there then allow access with an IF statement or so on each of my pages. If they dont have the cookie just to replace my #content (entirepage) to "sorry no" etc.

For example:

 $.cookie("Access","page1, page2, page3",{ expires: 1 });

Am already using JQuery, Jquery cookie. etc.

I am up for anyway of doing this cookie idea is just an example I am working on a cookie version at the moment just thought it would make an interesting question and to see what people thought would be good at client side? Because I mean if it wasn't for the case I had I would never use client side :P


Note: I have some ASP pages that require login etc. But this is a seperate directory on the server. So nevermind about all of that. They will have to type a username / password at some point upon doing so I can assign a cookie or such. (Don't want serverside) just to reiterate. It really doesn't matter if they can break it. Its just to stop prying eyes and sneaking fingers. If they take the effort to break it which I have no idea why they would in this case the information they have access to does nothing in this case..


Answers not containining USE SERVERSIDE LOL would be appreciated it is not part of the question or what I asked for. I know serverside makes alot more sense but I do not want to use it here. There really is no need to.

So what do you think would be the best / most efficient way of managing this?

+2  A: 

If you have server-side access, I'd highly recommend this. Anyone can kill their cookies at any time.

There's really no way of reliably denying access on the client-side as far as I know (almost anything can be spoofed or modified or removed), but we'll see what other people come up with.

Otherwise, I'd just recommend removing read privileges for the affected files or with your access rules (many different ways to do this among many different servers, <File> or <Directory> in Apache), or creating a simple HTTP authentication file (in Apache, a .htpasswd file and some rules in the .htaccess file or <VirtualHost>).

Dan Beam
Pretty much what I was just about to write myself.
Jakub Hampl
same here. Cookie method would be too unreliable. Try serverside implementation.. You could use a cusom DB. if your using IIS try your webconfig with users and roles.
John Hartsock
He does say though, that it doesn't particularly matter if people get there, just n00bs, perhaps. In that case, you can surely set a cookie with some type of simple data structure (JSON, CSV, etc.), and check to see if the browsing user or page is on that white list. But again, nothing is bullet proof on the client-side.
Dan Beam
As I said yeah doesnt matter if they actually get there just making it a little harder. Plus most of the target audience isn't going to know a thing about or maybe even what a cookie is.
Thqr
A: 

If the pages are known and limited, how about generating all the contents on the fly, with AJAX for retrieval?

shinkou
Most of the pages are. But how to differ between different users access? Some may access to certain places others may not how to catch this?
Thqr
How do you assign different cookies to different users then? You should be able to apply just those rules.
shinkou
I should mention that above. There are SOME ASP pages with server side these however are not because they do not need to be secure it is really just in effect of keeping with the standards. Don't need certain users looking at certain things. (not that it would matter)
Thqr
Same issue, child's play to spoof. This is giving people the wrong general idea about web security (though it does work for this problem).
Dan Beam