Skip to content

Commit

Permalink
Merge d163078 into a7c23b1
Browse files Browse the repository at this point in the history
  • Loading branch information
gr2m committed Jan 5, 2017
2 parents a7c23b1 + d163078 commit af6add3
Show file tree
Hide file tree
Showing 25 changed files with 234 additions and 775 deletions.
3 changes: 2 additions & 1 deletion README.md
Expand Up @@ -52,10 +52,11 @@ server.register({
option | default | description
------------------------- | ------------ | -------------
**adminPassword** | - | Password to login with admin account
**paths.data** | `'.hoodie'` | Data path
**paths.public** | `'public'` | Public path
**PouchDB** | – | [PouchDB constructor](https://pouchdb.com/api.html#defaults). See also [custom PouchDB builds](https://pouchdb.com/2016/06/06/introducing-pouchdb-custom-builds.html).
**account** | `{}` | [Hoodie Account Server](https://github.com/hoodiehq/hoodie-account-server/tree/master/plugin#options) options. `account.admins`, `account.secret` and `account.usersDb` are set based on `db` option above.
**account** | `{}` | [Hoodie Account Server](https://github.com/hoodiehq/hoodie-account-server/tree/master/plugin#options) options. `account.admins` are generated based on `adminPassword` option above. `account.usersDb` is hardcoded to `_users` at this point. `account.secret` is stored in `hoodie-store/hoodie` and will be generated if it does not yet exist.
**store** | `{}` | [Hoodie Store Server](https://github.com/hoodiehq/hoodie-store-server#options) options. `store.couchdb`, `store.PouchDB` are set based on the `PouchDB` option above. `store.hooks.onPreAuth` is set to bind user authentication for Hoodie Account to Hoodie Store.
## Testing
Expand Down
4 changes: 2 additions & 2 deletions lib/config/account/index.js
Expand Up @@ -4,8 +4,8 @@ var defaultsDeep = require('lodash').defaultsDeep

function accountConfig (state, callback) {
defaultsDeep(state.config.account, {
admins: state.db.admins,
secret: state.db.secret,
admins: state.admins,
secret: state.secret,
PouchDB: state.config.PouchDB,
usersDb: '_users'
})
Expand Down
31 changes: 31 additions & 0 deletions lib/config/admins.js
@@ -0,0 +1,31 @@
module.exports = getAdmins

var internals = getAdmins.internals = {}
internals.Admins = require('pouchdb-admins').admins

function getAdmins (state, callback) {
if (!state.config.adminPassword) {
state.server.log(['account', 'warn'], 'Admin account disabled: `options.adminPassword` not set')
state.admins = {}
return process.nextTick(callback)
}

var admins = new internals.Admins({
secret: state.secret
})

admins.set('admin', state.config.adminPassword)

.then(function () {
return admins.get('admin')
})

.then(function (doc) {
state.admins = {
admin: '-pbkdf2-' + doc.derived_key + ',' + doc.salt + ',10'
}
callback()
})

.catch(callback)
}
30 changes: 0 additions & 30 deletions lib/config/db/couchdb-check-vendor.js

This file was deleted.

13 changes: 0 additions & 13 deletions lib/config/db/couchdb-get-admins.js

This file was deleted.

23 changes: 0 additions & 23 deletions lib/config/db/couchdb-get-config.js

This file was deleted.

105 changes: 0 additions & 105 deletions lib/config/db/couchdb-migrate-to-store-db.js

This file was deleted.

15 changes: 0 additions & 15 deletions lib/config/db/couchdb-set-config.js

This file was deleted.

36 changes: 0 additions & 36 deletions lib/config/db/couchdb.js

This file was deleted.

73 changes: 0 additions & 73 deletions lib/config/db/pouchdb.js

This file was deleted.

0 comments on commit af6add3

Please sign in to comment.