password protect a node.js website

2,237 views
Skip to first unread message

TINO THOMAS

unread,
May 29, 2012, 3:32:51 PM5/29/12
to nod...@googlegroups.com
Hello,

I would like to password protect a node.js website running on port 8000. I am not sure what method to follow for this.
Will installing htpasswd (https://github.com/gevorg/htpasswd#readme) will help to achieve this?.
I installed htpasswd and created a password file using htpasswd -c command. But I am not sure how to proceed after this.
Can anyone please help me to complete this task.

Tim Caswell

unread,
May 29, 2012, 6:06:51 PM5/29/12
to nod...@googlegroups.com
There is nothing built-in to node to auto-read htpassword files.  You'll need a library that implements the authentication. The easiest is to implement http basic auth <http://en.wikipedia.org/wiki/Basic_access_authentication> (the one where your browser shows an ugly blocking popup asking for username and password)

Most http frameworks have a library for this built-in.  I would look up the docs for Express or something if you're not comfortable implementing the spec yourself (not that it's hard, I don't want to scare you away)


--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com
To unsubscribe from this group, send email to
nodejs+un...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Jonathan Irving

unread,
May 29, 2012, 7:02:55 PM5/29/12
to nodejs
I found this very convenient for use with Express:

https://github.com/gevorg/http-auth/

cheers, J
Reply all
Reply to author
Forward
0 new messages