diff --git a/CHANGELOG.md b/CHANGELOG.md index 16ed981e..8e831486 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Change Log +## 0.0.4 +- Implementing a clean Basic Auth (by config) + ## 0.0.3 - Updated `turtle.io` to 2.1.9 to gain customization of JSON formatting - Updated routing such that handlers execute with the context of the Tensō instance diff --git a/README.md b/README.md index 0ff10a27..64a04d69 100644 --- a/README.md +++ b/README.md @@ -38,16 +38,18 @@ This is a sample configuration for Tensō, without authentication or SSL. This w ```json { - "hostname": "localhost", - "port": 8000, - "routes": require( "./routes.js" ), - "logs": { + "auth": ["username:password", ...] or {"realm": "Super Secret", "list": ["username:password", ...]} // Optional + "hostname": "localhost", /* Optional, default is 'localhost' */ + "port": 8000, /* Optional, default is 8000 */ + "uid": N, /* Optional, system account uid to drop to after starting with elevated privileges to run on a low port */ + "routes": require( "./routes.js" ), /* Required! */ + "logs": { /* Optional */ "level": "info", "stdout": true, "dtrace": false, "syslog": false }, - "ssl": { + "ssl": { /* Optional */ "key": null, "cert": null } diff --git a/doc/global.html b/doc/global.html index a3f115ff..8ca16c1b 100644 --- a/doc/global.html +++ b/doc/global.html @@ -681,7 +681,7 @@
Parameters:
Source:
@@ -845,7 +845,7 @@
Parameters:
Source:
@@ -919,7 +919,7 @@
Returns:
Documentation generated by JSDoc 3.2.2 - on Sat Aug 02 2014 10:47:22 GMT-0400 (EDT) using the DocStrap template. + on Sat Aug 02 2014 12:02:11 GMT-0400 (EDT) using the DocStrap template. diff --git a/doc/index.html b/doc/index.html index 945f9548..2bdf3fc2 100644 --- a/doc/index.html +++ b/doc/index.html @@ -126,18 +126,20 @@

Creating Routes

} }

Configuration

-

This is a sample configuration for Tensō, without authentication or SSL. This would be ideal for development, but not production! Enabling is as easy as providing file paths for the two keys.

+

This is a sample configuration for Tensō, without authentication or SSL. This would be ideal for development, but not production! Enabling SSL is as easy as providing file paths for the two keys.

{
-    "hostname": "localhost",
-    "port": 8000,
-    "routes": require( "./routes.js" ),
-    "logs": {
+    "auth": ["username:password", ...] or {"realm": "Super Secret", "list": ["username:password", ...]} // Optional 
+    "hostname": "localhost", /* Optional, default is 'localhost' */
+    "port": 8000, /* Optional, default is 8000 */
+    "uid": N, /* Optional, system account uid to drop to after starting with elevated privileges to run on a low port */
+    "routes": require( "./routes.js" ), /* Required! */
+    "logs": { /* Optional */
         "level": "info",
         "stdout": true,
         "dtrace": false,
         "syslog": false
     },
-    "ssl": {
+    "ssl": { /* Optional */
         "key": null,
         "cert": null
     }
@@ -189,7 +191,7 @@ 

License

Documentation generated by JSDoc 3.2.2 - on Sat Aug 02 2014 10:47:22 GMT-0400 (EDT) using the DocStrap template. + on Sat Aug 02 2014 12:02:11 GMT-0400 (EDT) using the DocStrap template. diff --git a/doc/module-tenso.html b/doc/module-tenso.html index 606a399e..3d5ca9d0 100644 --- a/doc/module-tenso.html +++ b/doc/module-tenso.html @@ -104,7 +104,7 @@

Version:
-
  • 0.0.3
+
  • 0.0.4
@@ -190,7 +190,7 @@

Documentation generated by JSDoc 3.2.2 - on Sat Aug 02 2014 10:47:22 GMT-0400 (EDT) using the DocStrap template. + on Sat Aug 02 2014 12:02:11 GMT-0400 (EDT) using the DocStrap template. diff --git a/doc/modules.list.html b/doc/modules.list.html index fe5c3004..580ab23e 100644 --- a/doc/modules.list.html +++ b/doc/modules.list.html @@ -167,7 +167,7 @@

Documentation generated by JSDoc 3.2.2 - on Sat Aug 02 2014 10:47:22 GMT-0400 (EDT) using the DocStrap template. + on Sat Aug 02 2014 12:02:11 GMT-0400 (EDT) using the DocStrap template. diff --git a/doc/tenso.js.html b/doc/tenso.js.html index a2645373..3f03ca16 100644 --- a/doc/tenso.js.html +++ b/doc/tenso.js.html @@ -91,13 +91,13 @@

Source: tenso.js

* @license BSD-3 <https://raw.github.com/avoidwork/tenso/master/LICENSE> * @link http://avoidwork.github.io/tenso * @module tenso - * @version 0.0.3 + * @version 0.0.4 */ ( function () { "use strict"; var TurtleIO = require( "turtle.io" ), - SERVER = "tenso/0.0.3", + SERVER = "tenso/0.0.4", CONFIG = require( __dirname + "/../config.json" ), keigai = require( "keigai" ), util = keigai.util, @@ -114,7 +114,7 @@

Source: tenso.js

function Tenso () { this.messages = {}; this.server = new TurtleIO(); - this.version = "0.0.3"; + this.version = "0.0.4"; } /** @@ -206,7 +206,7 @@

Source: tenso.js

var HOSTNAME = arg ? arg.hostname || "localhost" : "localhost", vhosts = {}, config = arg ? merge( clone( CONFIG, true ), arg ) : CONFIG, - instance; + auth, instance; if ( !config.port ) { console.error( "Invalid configuration" ); @@ -218,6 +218,16 @@

Source: tenso.js

config.vhosts = vhosts; config["default"] = HOSTNAME; + if ( config.auth !== null ) { + auth = {}; + auth[HOSTNAME] = { + authRealm : config.auth.realm || "Private", + authList : config.auth.list || config.auth + }; + + config.auth = auth; + } + instance = new Tenso(); return bootstrap( instance, config ); @@ -290,7 +300,7 @@

Source: tenso.js

Documentation generated by JSDoc 3.2.2 - on Sat Aug 02 2014 10:47:22 GMT-0400 (EDT) using the DocStrap template. + on Sat Aug 02 2014 12:02:11 GMT-0400 (EDT) using the DocStrap template. diff --git a/lib/tenso.js b/lib/tenso.js index e600ac1c..cad0bccf 100644 --- a/lib/tenso.js +++ b/lib/tenso.js @@ -6,13 +6,13 @@ * @license BSD-3 * @link http://avoidwork.github.io/tenso * @module tenso - * @version 0.0.3 + * @version 0.0.4 */ ( function () { "use strict"; var TurtleIO = require( "turtle.io" ), - SERVER = "tenso/0.0.3", + SERVER = "tenso/0.0.4", CONFIG = require( __dirname + "/../config.json" ), keigai = require( "keigai" ), util = keigai.util, @@ -29,7 +29,7 @@ var TurtleIO = require( "turtle.io" ), function Tenso () { this.messages = {}; this.server = new TurtleIO(); - this.version = "0.0.3"; + this.version = "0.0.4"; } /** @@ -121,7 +121,7 @@ function factory ( arg ) { var HOSTNAME = arg ? arg.hostname || "localhost" : "localhost", vhosts = {}, config = arg ? merge( clone( CONFIG, true ), arg ) : CONFIG, - instance; + auth, instance; if ( !config.port ) { console.error( "Invalid configuration" ); @@ -133,6 +133,16 @@ function factory ( arg ) { config.vhosts = vhosts; config["default"] = HOSTNAME; + if ( config.auth !== null ) { + auth = {}; + auth[HOSTNAME] = { + authRealm : config.auth.realm || "Private", + authList : config.auth.list || config.auth + }; + + config.auth = auth; + } + instance = new Tenso(); return bootstrap( instance, config ); diff --git a/package.json b/package.json index 37bec280..14568af8 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "tenso", "description": "Tensō is a REST framework for node.js, designed to simplify the implementation of APIs.", - "version": "0.0.3", + "version": "0.0.4", "homepage": "http://avoidwork.github.io/tenso", "author": { "name": "Jason Mulligan", diff --git a/src/factory.js b/src/factory.js index 0354d946..774bd068 100644 --- a/src/factory.js +++ b/src/factory.js @@ -9,7 +9,7 @@ function factory ( arg ) { var HOSTNAME = arg ? arg.hostname || "localhost" : "localhost", vhosts = {}, config = arg ? merge( clone( CONFIG, true ), arg ) : CONFIG, - instance; + auth, instance; if ( !config.port ) { console.error( "Invalid configuration" ); @@ -21,6 +21,16 @@ function factory ( arg ) { config.vhosts = vhosts; config["default"] = HOSTNAME; + if ( config.auth !== null ) { + auth = {}; + auth[HOSTNAME] = { + authRealm : config.auth.realm || "Private", + authList : config.auth.list || config.auth + }; + + config.auth = auth; + } + instance = new Tenso(); return bootstrap( instance, config );