Re: Newbie Question: Password protect a webpage
From: Ryan Stewart (zzanNOtozz_at_gSPAMo.com)
Date: 10/23/04
- Next message: Ryan Stewart: "Re: Newbie Question: Password protect a webpage"
- Previous message: Paige Miller: "Newbie Question: Password protect a webpage"
- In reply to: Paige Miller: "Newbie Question: Password protect a webpage"
- Next in thread: Ryan Stewart: "Re: Newbie Question: Password protect a webpage"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 23 Oct 2004 07:40:07 -0500
"Paige Miller" <pmiller5NOSPAM@rochester.rr.com> wrote in message
news:w1sed.18698$JS4.11772@twister.nyroc.rr.com...
> I'm trying to come up with a very low-security password protected
> web-page. I have found some short java code on the internet at
> http://www.dynamicdrive.com/dynamicindex9/password.htm that will do what
> I want, if only I could figure out one little thing.
>
> On the gateway page, you place a javascript which asks for the password,
> and then only if the proper password is provided do you allow access to
> the next page. Great. Exactly what I want.
>
> What I can't figure out is this: let's say the password protected page
> is named http://somewhere.com/abraham.html. How do I stop people from
> noticing that name, after the first time they correctly supply the
> password, from going directly to that page (bypassing the need to supply
> the password). If someone makes this page a Favorite, it appears they
> can go directly to this page, not what I want. How do I fix this?
>
> Thanks!
>
You check for the password in the page you want to protect, and you don't
rely on JavaScript to do it. The algorithm on that page you gave is only
slightly harder than plaintext to crack. You have a login page that checks
login credentials serverside, and then store the user id (or better yet,
User object) in the session:
session.setAttribute("currentUser", user);
Then wherever you need to validate a user (assuming you put a User object in
the session):
User user = (User) session.getAttribute("currentUser");
if (user == null) {
// Go back to login page
}
You also have the option of allowing certain users more access:
if (user.isAdmin()) {
// Let them in the admin section
} else {
// Back to login or some error page
}
For a simpler model, just put the user id in the session and get it out:
String user = (String) session.getAttribute("currentUser");
if (user == null) {
// Go back to login page
}
- Next message: Ryan Stewart: "Re: Newbie Question: Password protect a webpage"
- Previous message: Paige Miller: "Newbie Question: Password protect a webpage"
- In reply to: Paige Miller: "Newbie Question: Password protect a webpage"
- Next in thread: Ryan Stewart: "Re: Newbie Question: Password protect a webpage"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|