Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Update README.md

  • Loading branch information...
commit ac0941d7016443fcf568581f408f68aeef1978c4 1 parent 1491133
Camilo Aguilar authored January 24, 2012

Showing 1 changed file with 54 additions and 0 deletions. Show diff stats Hide diff stats

  1. 54  README.md
54  README.md
Source Rendered
... ...
@@ -0,0 +1,54 @@
  1
+##Flexible HTTP Basic Authentication for Connect Framework.
  2
+
  3
+### Why
  4
+This project came to live due to the lack of flexibility of the existent middlewares, specially 
  5
+when developing RESTful APIs.
  6
+
  7
+### Features
  8
+* Easy to use
  9
+* Asynchronous
  10
+* Gives you access to the request and response objects from your authentication callback.
  11
+* Lets you send a custom response body along with the Authorization Required header. Useful for RESTful APIs.
  12
+
  13
+### How to use
  14
+
  15
+```javascript
  16
+var basicAuth = require('connect-basic-auth');
  17
+var express = require('express');
  18
+
  19
+var app = express.createServer();
  20
+app.use(basicAuth(function(credentials, req, res, next) {
  21
+  
  22
+  Account.authenticate(credentials, function(error) {
  23
+    next(error);
  24
+  });
  25
+
  26
+
  27
+}, 'Please enter your credentials.'));
  28
+
  29
+//Routes that do not require authentication go first
  30
+app.post('/accounts', function(req, res, next) {
  31
+  //Creates an Account.
  32
+});
  33
+
  34
+//Lets require authentication for the rest of our routes.
  35
+app.all('*', function(req, res, next) {
  36
+  req.requireAuthorization(req, res, next);
  37
+});
  38
+
  39
+app.get('/accounts/:username', function(req, res, next) {
  40
+  //Returns :username account information
  41
+});
  42
+
  43
+```
  44
+
  45
+### License
  46
+(The MIT License)
  47
+
  48
+Copyright 2010 Camilo Aguilar. All rights reserved.
  49
+
  50
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
  51
+
  52
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
  53
+
  54
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

0 notes on commit ac0941d

Please sign in to comment.
Something went wrong with that request. Please try again.