cnpm-ldap-user-service
LDAP user service for cnpmjs.org
Install
$ npm install cnpm-ldap-user-service --save
Example
Set userService
on your config/config.js
var LdapUserService = ; moduleexports = // input your custom config here admin: 'admin': 'admin@cnpmjs.org' // enable private mode, only admin can publish, other use just can sync package from source npm enablePrivate: false // registry scopes, if don't set, means do not support scopes scopes: '@lnpm' // redirect @cnpm/private-package => private-package // forward compatbility for update from lower version cnpmjs.org adaptScope: true // force user publish with scope // but admins still can publish without scope forcePublishWithScope: true // your ldap user service userService: url: 'ldaps://ldap.example.org:636' bindDN: 'uid=myadminusername,ou=users,dc=example,dc=org' bindCredentials: 'mypassword' searchBase: 'ou=users,dc=example,dc=org' searchFilter: '(uid={{username}})' reconnect: true ;
API
new LdapUserService(ldapConfig, userMapper)
Returns: instance of LdapUserService
Arguments
ldapConfig
: (required) pass theLdapAuth
Config ObjectuserMapper
: (optional) custom user mapper function
By default, internal userMapper
bind three properties like below.
login
property is bound touid
attributeemail
property is bound tomail
attributename
property is bound todisplayName
attribute
If you want to change the default, you can pass the userMapper
function like below.
var LdapUserService = ; var config = // input your custom config here admins: 'admin': 'admin@cnpmjs.org' // ... userService: url: 'ldaps://ldap.example.org:636' bindDN: 'uid=myadminusername,ou=users,dc=example,dc=org' bindCredentials: 'mypassword' searchBase: 'ou=users,dc=example,dc=org' searchFilter: '(uid={{username}})' reconnect: true { // TODO: return your own authorization object using `ldapUser` // TODO: (https://github.com/cnpm/cnpmjs.org/wiki/Use-Your-Own-User-Authorization) return login: ldapUseruid email: ldapUsermail name: ldapUserdisplayName site_admin: configadminsldapUseruid === ldapUsermail } ; moduleexports = config
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue