Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

ArangoDB auth plugin #85

Open
wants to merge 4 commits into from

2 participants

Commits on Aug 20, 2013
  1. @andelo

    arangoDB auth plugin

    andelo authored
  2. @andelo

    added auth fileserver example

    andelo authored
  3. @andelo

    added arango client dependency

    andelo authored
Commits on Feb 4, 2014
  1. @andelo
This page is out of date. Refresh to see the latest.
View
23 examples/authfs.js
@@ -0,0 +1,23 @@
+"use strict";
+
+var jsDAV = require("./../lib/jsdav");
+jsDAV.debugMode = true;
+
+var jsDAV_Locks_Backend_FS = require("./../lib/DAV/plugins/locks/fs");
+var authBackend = require("./../lib/DAV/plugins/auth/arango");
+var authPlugin = require("./../lib/DAV/plugins/auth");
+var Db = require("./../lib/shared/backends/arango");
+
+Db.getConnection("http://127.0.0.1:8529/users", function(err, db) {
+ if (err) throw err;
+
+ var arangoDB = authBackend.new(db);
+
+ jsDAV.createServer({
+ node: __dirname + "/../test/assets",
+ authBackend: arangoDB,
+ locksBackend: jsDAV_Locks_Backend_FS.new(__dirname + "/../test/assets"),
+ realm: "jsDAV",
+ plugins: [authPlugin]
+ }, 8000);
+});
View
29 lib/DAV/plugins/auth/arango.js
@@ -0,0 +1,29 @@
+"use strict";
+
+var jsDAV_Auth_Backend_AbstractDigest = require("./abstractDigest");
+
+/**
+ * This is an authentication backend that uses the arango database to manage passwords.
+ */
+var jsDAV_Auth_Backend_Arango = module.exports = jsDAV_Auth_Backend_AbstractDigest.extend({
+ initialize: function (db) {
+ jsDAV_Auth_Backend_AbstractDigest.initialize.call(this);
+ this.db = db;
+ },
+
+ /**
+ * Returns a users' information
+ *
+ * @param {string} realm
+ * @param {string} username
+ * @return {string}
+ */
+ getDigestHash: function (realm, username, cbdigest) {
+ this.db.simple.first({username:username,realm:realm})
+ .then(function(ret){
+ cbdigest(null,ret && ret.document && ret.document.password);
+ },function(err){
+ return cbdigest(err);
+ });
+ }
+});
View
10 lib/shared/backends/arango.js
@@ -0,0 +1,10 @@
+var arango = require("arango");
+
+/* Example: getConnection("http://127.0.0.1:8529/users",clbk); */
+exports.getConnection = function(connStr, callback) {
+ try {
+ callback(null,new arango.Connection(connStr));
+ } catch (err) {
+ callback(err);
+ }
+};
View
3  package.json
@@ -25,7 +25,8 @@
"dbox": "~0.5.6",
"redis": "~0.8.2",
"mongodb": "~1.2.12",
- "gnu-tools": "0.0.x"
+ "gnu-tools": "0.0.x",
+ "arango": "git://github.com/kaerus-component/arango.git#master"
},
"licenses": [{
"type": "The MIT License",
Something went wrong with that request. Please try again.