diff options
| author | Sean Fridman <fridman@mail.sfsu.edu> | 2015-04-13 10:25:46 -0400 |
|---|---|---|
| committer | Sean Fridman <fridman@mail.sfsu.edu> | 2015-04-13 10:25:46 -0400 |
| commit | 3b16b2d58f876f6ab4abcdf8012efb2411504940 (patch) | |
| tree | 0b136a672382429e6c86acde012a611e8ad5bb15 /app/node_modules/okadminview | |
| parent | 952cac06cc8ccd66fe07b09ca81c5dc750a54805 (diff) | |
HTTP Digest authentication
Diffstat (limited to 'app/node_modules/okadminview')
| -rw-r--r-- | app/node_modules/okadminview/index.js | 19 | ||||
| -rw-r--r-- | app/node_modules/okadminview/package.json | 2 |
2 files changed, 21 insertions, 0 deletions
diff --git a/app/node_modules/okadminview/index.js b/app/node_modules/okadminview/index.js index 897c583..ac633e8 100644 --- a/app/node_modules/okadminview/index.js +++ b/app/node_modules/okadminview/index.js @@ -4,10 +4,22 @@ var bodyParser = require('body-parser'); var methodOverride = require('method-override'); var session = require('express-session'); var flash = require('connect-flash'); +var passport = require('passport'); +var DigestStrategy = require('passport-http').DigestStrategy; var Q = require('q'); var pluralize = require('pluralize'); var OKQuery = require('okquery'); +// Configure auth +passport.use(new DigestStrategy({qop: 'auth'}, + function authenticate(username, done) { + if (!process.env.OK_USER || !process.env.OK_PASS) { + return done(new Error('No user or pass configured on server')); + } else { + return done(null, process.env.OK_USER, process.env.OK_PASS); + } +})); + /** * OKAdminView! */ @@ -100,6 +112,13 @@ function OKAdminView(options) { } })); + var auth = passport.authenticate('digest', {session: false}); + + // This should really be mounted on the router, but can't be due to + // https://github.com/jaredhanson/passport-http/pull/16 + app.use('/_admin/', passport.initialize()); + app.all('/_admin/:path*', auth); + router.get('/', function readIndex(req, res, next) { fetchIndexTemplateData(meta, indexQueries).then(function(data) { view.renderIndex(req, res, assign(data, { diff --git a/app/node_modules/okadminview/package.json b/app/node_modules/okadminview/package.json index 4c6d11c..bdaefc5 100644 --- a/app/node_modules/okadminview/package.json +++ b/app/node_modules/okadminview/package.json @@ -15,6 +15,8 @@ "lodash.clonedeep": "^3.0.0", "method-override": "^2.3.2", "object-assign": "^2.0.0", + "passport": "^0.2.1", + "passport-http": "^0.2.2", "pluralize": "^1.1.2", "q": "^1.2.0" } |
