Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ldap-authentication

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ldap-authentication - npm Package Compare versions

Comparing version 2.1.1 to 2.1.2

.travis.yml

19

index.js

@@ -42,3 +42,3 @@ const assert = require('assert')

var filter = new ldap.filters.EqualityFilter({
attribute: usernameAttribute,
attribute: usernameAttribute,
value: username

@@ -85,3 +85,3 @@ })

ldapOpts.log && ldapOpts.log.trace(`admin did not find user! (${usernameAttribute}=${username})`)
throw new Error('user not found or usernameAttribute is wrong')
throw new LdapAuthenticationError('user not found or usernameAttribute is wrong')
}

@@ -104,3 +104,3 @@ var userDn = user.dn

ldapOpts.log && ldapOpts.log.trace(`user logged in, but user details could not be found. (${usernameAttribute}=${username}). Probabaly wrong attribute or searchBase?`)
throw new Error('user logged in, but user details could not be found. Probabaly usernameAttribute or userSearchBase is wrong?')
throw new LdapAuthenticationError('user logged in, but user details could not be found. Probabaly usernameAttribute or userSearchBase is wrong?')
}

@@ -148,3 +148,16 @@ ldapUserClient.unbind()

class LdapAuthenticationError extends Error {
constructor(message) {
super(message)
// Ensure the name of this error is the same as the class name
this.name = this.constructor.name
// This clips the constructor invocation from the stack trace.
// It's not absolutely essential, but it does make the stack trace a little nicer.
// @see Node.js reference (bottom)
Error.captureStackTrace(this, this.constructor);
}
}
module.exports.authenticate = authenticate
module.exports.LdapAuthenticationError = LdapAuthenticationError

2

package.json
{
"name": "ldap-authentication",
"version": "2.1.1",
"version": "2.1.2",
"description": "A simple async nodejs library for LDAP user authentication",

@@ -5,0 +5,0 @@ "main": "index.js",

# A Simple node Library that Authenticates a User Against an LDAP/AD Server
[![Build Status](https://travis-ci.org/shaozi/ldap-authentication.svg?branch=master)](https://travis-ci.org/shaozi/ldap-authentication)
[![Known Vulnerabilities](https://snyk.io/test/github/shaozi/ldap-authentication/badge.svg?targetFile=package.json)](https://snyk.io/test/github/shaozi/ldap-authentication?targetFile=package.json)
This library use `ldapjs` as the underneath library. It has two modes of authentications:

@@ -34,2 +37,6 @@

* An example on how to use with Passport is [passport-ldap-example](https://github.com/shaozi/passport-ldap-example)
* Another simple library [express-passport-ldap-mongoose](https://github.com/shaozi/express-passport-ldap-mongoose) provide turn key solution
#### User authenticate without getting user details

@@ -36,0 +43,0 @@

@@ -1,2 +0,2 @@

const { authenticate } = require('../index.js')
const { authenticate, LdapAuthenticationError } = require('../index.js')

@@ -182,2 +182,21 @@ describe('ldap-authentication test', () => {

})
test('Wrong options give LdapAuthenticationError', async () => {
let options = {
ldapOpts: {
url: 'ldap://ldap.forumsys.com'
},
userDn: 'uid=einstein,dc=example,dc=com',
userPassword: 'password',
usernameAttribute: 'cn',
userSearchBase: 'dc=example,dc=com',
username: 'einstein'
}
try {
await authenticate(options)
} catch(error) {
e = error
}
expect(e).toBeTruthy()
expect(e).toBeInstanceOf(LdapAuthenticationError)
})
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc