Skip to content

Commit

Permalink
Implementing Basic Auth by config
Browse files Browse the repository at this point in the history
Updating README

Updating README
  • Loading branch information
avoidwork committed Aug 2, 2014
1 parent f456bdc commit 1a71265
Show file tree
Hide file tree
Showing 10 changed files with 66 additions and 29 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
6 changes: 3 additions & 3 deletions doc/global.html
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="tenso.js.html">tenso.js</a>, <a href="tenso.js.html#sunlight-1-line-141">line 141</a>
<a href="tenso.js.html">tenso.js</a>, <a href="tenso.js.html#sunlight-1-line-151">line 151</a>
</li></ul></dd>


Expand Down Expand Up @@ -845,7 +845,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="tenso.js.html">tenso.js</a>, <a href="tenso.js.html#sunlight-1-line-162">line 162</a>
<a href="tenso.js.html">tenso.js</a>, <a href="tenso.js.html#sunlight-1-line-172">line 172</a>
</li></ul></dd>


Expand Down Expand Up @@ -919,7 +919,7 @@ <h5>Returns:</h5>

<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.2</a>
on Sat Aug 02 2014 10:47:22 GMT-0400 (EDT) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
on Sat Aug 02 2014 12:02:11 GMT-0400 (EDT) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</span>
</footer>
</div>
Expand Down
16 changes: 9 additions & 7 deletions doc/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -126,18 +126,20 @@ <h3>Creating Routes</h3>
}
}</code></pre>
<h2>Configuration</h2>
<p>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.</p>
<p>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.</p>
<pre><code class="lang-json">{
&quot;hostname&quot;: &quot;localhost&quot;,
&quot;port&quot;: 8000,
&quot;routes&quot;: require( &quot;./routes.js&quot; ),
&quot;logs&quot;: {
&quot;auth&quot;: [&quot;username:password&quot;, ...] or {&quot;realm&quot;: &quot;Super Secret&quot;, &quot;list&quot;: [&quot;username:password&quot;, ...]} // Optional
&quot;hostname&quot;: &quot;localhost&quot;, /* Optional, default is 'localhost' */
&quot;port&quot;: 8000, /* Optional, default is 8000 */
&quot;uid&quot;: N, /* Optional, system account uid to drop to after starting with elevated privileges to run on a low port */
&quot;routes&quot;: require( &quot;./routes.js&quot; ), /* Required! */
&quot;logs&quot;: { /* Optional */
&quot;level&quot;: &quot;info&quot;,
&quot;stdout&quot;: true,
&quot;dtrace&quot;: false,
&quot;syslog&quot;: false
},
&quot;ssl&quot;: {
&quot;ssl&quot;: { /* Optional */
&quot;key&quot;: null,
&quot;cert&quot;: null
}
Expand Down Expand Up @@ -189,7 +191,7 @@ <h2>License</h2>

<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.2</a>
on Sat Aug 02 2014 10:47:22 GMT-0400 (EDT) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
on Sat Aug 02 2014 12:02:11 GMT-0400 (EDT) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</span>
</footer>
</div>
Expand Down
4 changes: 2 additions & 2 deletions doc/module-tenso.html
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ <h2>


<dt class="tag-version">Version:</dt>
<dd class="tag-version"><ul class="dummy"><li>0.0.3</li></ul></dd>
<dd class="tag-version"><ul class="dummy"><li>0.0.4</li></ul></dd>



Expand Down Expand Up @@ -190,7 +190,7 @@ <h2>

<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.2</a>
on Sat Aug 02 2014 10:47:22 GMT-0400 (EDT) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
on Sat Aug 02 2014 12:02:11 GMT-0400 (EDT) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</span>
</footer>
</div>
Expand Down
2 changes: 1 addition & 1 deletion doc/modules.list.html
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ <h2>

<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.2</a>
on Sat Aug 02 2014 10:47:22 GMT-0400 (EDT) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
on Sat Aug 02 2014 12:02:11 GMT-0400 (EDT) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</span>
</footer>
</div>
Expand Down
20 changes: 15 additions & 5 deletions doc/tenso.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,13 @@ <h1 class="page-title">Source: tenso.js</h1>
* @license BSD-3 &lt;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,
Expand All @@ -114,7 +114,7 @@ <h1 class="page-title">Source: tenso.js</h1>
function Tenso () {
this.messages = {};
this.server = new TurtleIO();
this.version = "0.0.3";
this.version = "0.0.4";
}

/**
Expand Down Expand Up @@ -206,7 +206,7 @@ <h1 class="page-title">Source: tenso.js</h1>
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" );
Expand All @@ -218,6 +218,16 @@ <h1 class="page-title">Source: tenso.js</h1>
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 );
Expand Down Expand Up @@ -290,7 +300,7 @@ <h1 class="page-title">Source: tenso.js</h1>

<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.2</a>
on Sat Aug 02 2014 10:47:22 GMT-0400 (EDT) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
on Sat Aug 02 2014 12:02:11 GMT-0400 (EDT) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</span>
</footer>
</div>
Expand Down
18 changes: 14 additions & 4 deletions lib/tenso.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
* @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,
Expand All @@ -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";
}

/**
Expand Down Expand Up @@ -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" );
Expand All @@ -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 );
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
12 changes: 11 additions & 1 deletion src/factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -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" );
Expand All @@ -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 );
Expand Down

0 comments on commit 1a71265

Please sign in to comment.