Permalink
Browse files

basicAuth

  • Loading branch information...
tj committed Oct 13, 2012
1 parent 84d3ba3 commit 021fc3ed9485ad21a1a63c8322a0fef64a3ea421
Showing with 51 additions and 0 deletions.
  1. +4 −0 api.jade
  2. +20 −0 en/api/middleware.jade
  3. +27 −0 en/api/mw-basicAuth.jade
View
@@ -30,4 +30,8 @@ html
a(name='response')
include en/api/res
+ h2 Middleware
+ a(name='middleware')
+ include en/api/middleware
+
include includes/footer
View
@@ -0,0 +1,20 @@
+include ./mw-basicAuth
+include ./mw-bodyParser
+include ./mw-compress
+include ./mw-cookieParser
+include ./mw-cookieSession
+include ./mw-csrf
+include ./mw-directory
+include ./mw-errorHandler
+include ./mw-favicon
+include ./mw-json
+include ./mw-limit
+include ./mw-logger
+include ./mw-methodOverride
+include ./mw-multipart
+include ./mw-query
+include ./mw-responseTime
+include ./mw-static
+include ./mw-timeout
+include ./mw-urlencoded
+include ./mw-vhost
View
@@ -0,0 +1,27 @@
+section
+ h3(id='basicAuth') basicAuth()
+
+ p.
+ Basic Authentication middleware, populating `req.user`
+ with the username.
+
+ p Simple username and password:
+
+ +js.
+ app.use(express.basicAuth('username', 'password'));
+
+ p Callback verification:
+
+ +js.
+ app.use(express.basicAuth(function(user, pass){
+ return 'tj' == user & 'wahoo' == pass;
+ }));
+
+ p.
+ Async callback verification, accepting `fn(err, user)`,
+ in this case `req.user` will be the `user` object passed.
+
+ +js.
+ app.use(connect.basicAuth(function(user, pass, fn){
+ User.authenticate({ user: user, pass: pass }, fn);
+ }))

0 comments on commit 021fc3e

Please sign in to comment.