Basic auth in node.js

Super easy – already supported if you use express/connect.

Example (using express):

var express = require('express');
 
function authorize(username, password) {
    return 'username' === username & 'password' === password;
}
 
var app = express.createServer(
    express.basicAuth(authorize)
);

Example using connect

One Response to “Basic auth in node.js”

  1. Tanya Nam » Blog Archive » Why I love Heroku Says:

    [...] I’ve been doing development with node.js and since Heroku supports it (wonder if they were first to offer it), it was a [...]

Leave a Reply