views:

27

answers:

2

TLDR Using plain HTML / Javascript (Client Side) I want to prevent viewing of certain pages. The user will have to type a username and password and depending on that they get access to different pages.


Answers can NOT include server side whatsoever

It does not matter if they can break it easily. There is no sensitive information etc. Also the target audience will not have access to internet OR probably know what a cookie is...


At some point the user will have to type username / password.(I can define the cookie here)
Currently I thought of using cookies to set a cookie for each page to say "true" / "false" but that would get messy with so many cookies. Or setting an array within a cookie for each page?
I have div field "#Content" which as it looks encompasses all of my content on the page so blocking out content will be as simple as replacing it with ("sorry you don't have access") etc.

For Example:

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

I am looking for anyway to do this does not have to be with cookies.
Would be nice to get a discussion of different ways this can be done.


So the question is:
What do YOU think would be a good way to go about doing this with client side validation?

Also on another note discussion on how to make client side more secure or ways to do so are acceptable.

+1  A: 

My lame hack would be to use some sort of hash on the username/password (someone must've written SHA-1 in Javascript) to decrypt page names. If it decrypts correctly, the links work; if not, the links don't. You'll need to store encrypted page names for every username/pass combination, but oh well.

tc.
I do not mind the links to work or not. Fine for them to load the page. Just not to see the content on it. Definently an interesting way to go about it.
Thqr
A: 

My cookie idea goes along the lines of:

Dependant on username and password set some cookies to:

KEY - VALUE

User 1:
Page1Access - true
Page2Access - true

User 2:
Page2Access - true
Page4Access - true
Page9Access - true

etc.

Then in the HTML:

 if ($.cookie('Page2Access') == null) {
        $('#content').html('Sorry you do not have access to this.');
    }
    else { }

With #content encompasses quite literally everything but my navigation.

Thqr