verdaccio/node_modules/sinopia-htpasswd
Alex Kocharin 1cb1e91ca1 update deps 2014-10-02 18:07:01 +04:00
..
tests update deps 2014-10-02 18:07:01 +04:00
.editorconfig importing all bundled deps to git 2014-09-14 18:28:17 +04:00
.npmignore importing all bundled deps to git 2014-09-14 18:28:17 +04:00
.travis.yml importing all bundled deps to git 2014-09-14 18:28:17 +04:00
README.md sinopia-htpasswd@0.4.2 2014-09-18 01:44:30 +04:00
index.js update deps 2014-10-02 18:07:01 +04:00
package.json update deps 2014-10-02 18:07:01 +04:00
utils.js update deps 2014-10-02 18:07:01 +04:00

README.md

Installation

$ npm install sinopia
$ npm install sinopia-htpasswd

PS: Actually, this module is bundled with sinopia, so you don't have to install it like this. But with other auth plugins you have to.

Config

Add to your config.yaml:

auth:
  htpasswd:
    users_file: ./htpasswd

    # Maximum amount of users allowed to register, defaults to "+inf".
    # You can set this to 0 to disable registration.
    #max_users: 1000

For plugin writers

It's called as:

require('sinopia-htpasswd')(config, stuff)

Where:

  • config - module's own config
  • stuff - collection of different internal sinopia objects
    • stuff.config - main config
    • stuff.logger - logger

This should export two functions:

  • adduser(user, password, cb)

    It should respond with:

    • cb(err) in case of an error (error will be returned to user)
    • cb(null, false) in case registration is disabled (next auth plugin will be executed)
    • cb(null, true) in case user registered successfully

    It's useful to set err.status property to set http status code (e.g. err.status = 403).

  • authenticate(user, password, cb)

    It should respond with:

    • cb(err) in case of a fatal error (error will be returned to user, keep those rare)
    • cb(null, false) in case user not authenticated (next auth plugin will be executed)
    • cb(null, [groups]) in case user is authenticated

    Groups is an array of all users/usergroups this user has access to. You should probably include username itself here.