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.3.2 to 2.3.3

.devcontainer/devcontainer.json

1

index.js

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

user = entry.object
user.raw = entry.raw
})

@@ -92,0 +93,0 @@ res.on('searchReference', function (referral) {

4

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

@@ -42,4 +42,4 @@ "main": "index.js",

"devDependencies": {
"jasmine": "^4.4.0"
"jasmine": "^4.5.0"
}
}
# 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)
[![Integration Tests](https://github.com/shaozi/ldap-authentication/actions/workflows/integration-test.yml/badge.svg)](https://github.com/shaozi/ldap-authentication/actions/workflows/integration-test.yml)
[![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)

@@ -179,1 +179,22 @@

- `groupMemberUserAttribute`: if specified with groupClass and groupsSearchBase, will be used as the attribute on the user object (if not specified this defaults to `dn`) in search filter for authenticated user groups
## Returns
The user object if `authenticate()` is success.
The user object has a `raw` field that has the raw data from the LDAP/AD server. It can be used to access buffer objects (profile pics for example).
Buffer data can now be accessed by `user.raw.profilePhoto`, etc, instead of `user.profilePhoto`.
const { authenticate, LdapAuthenticationError } = require('../index.js')
const url = process.env.INGITHUB ? 'ldap://localhost:1389' : 'ldap://ldap:1389'
describe('ldap-authentication test', () => {

@@ -7,3 +9,3 @@ it('Use an admin user to check if user exists', async () => {

ldapOpts: {
url: 'ldap://ldap.forumsys.com',
url: url,
},

@@ -17,2 +19,3 @@ adminDn: 'cn=read-only-admin,dc=example,dc=com',

}
let user = await authenticate(options)

@@ -25,3 +28,3 @@ expect(user).toBeTruthy()

ldapOpts: {
url: 'ldap://ldap.forumsys.com',
url: url,
},

@@ -35,2 +38,3 @@ adminDn: 'cn=read-only-admin,dc=example,dc=com',

}
let user = await authenticate(options)

@@ -43,3 +47,3 @@ expect(user).toBeTruthy()

ldapOpts: {
url: 'ldap://ldap.forumsys.com',
url: url,
},

@@ -54,6 +58,7 @@ adminDn: 'cn=read-only-admin,dc=example,dc=com',

}
let user = await authenticate(options)
expect(user).toBeTruthy()
expect(user.uid).toEqual('gauss')
expect(user.sn).toEqual('Gauss')
expect(user.sn).toEqual('Bar1')
expect(user.cn).toBeUndefined()

@@ -64,5 +69,5 @@ })

ldapOpts: {
url: 'ldap://ldap.forumsys.com',
url: url,
},
userDn: 'uid=einstein,dc=example,dc=com',
userDn: 'cn=einstein,ou=users,dc=example,dc=com',
userPassword: 'password',

@@ -73,5 +78,7 @@ userSearchBase: 'dc=example,dc=com',

}
let user = await authenticate(options)
expect(user).toBeTruthy()
expect(user.uid).toEqual('einstein')
expect(user.raw).toBeTruthy()
})

@@ -81,5 +88,5 @@ it('Use an regular user to authenticate iteself and return attributes', async () => {

ldapOpts: {
url: 'ldap://ldap.forumsys.com',
url: url,
},
userDn: 'uid=einstein,dc=example,dc=com',
userDn: 'cn=einstein,ou=users,dc=example,dc=com',
userPassword: 'password',

@@ -91,6 +98,7 @@ userSearchBase: 'dc=example,dc=com',

}
let user = await authenticate(options)
expect(user).toBeTruthy()
expect(user.uid).toEqual('einstein')
expect(user.sn).toEqual('Einstein')
expect(user.sn).toEqual('Bar2')
expect(user.cn).toBeUndefined()

@@ -101,7 +109,8 @@ })

ldapOpts: {
url: 'ldap://ldap.forumsys.com',
url: url,
},
userDn: 'uid=einstein,dc=example,dc=com',
userDn: 'cn=einstein,ou=users,dc=example,dc=com',
userPassword: 'password',
}
let user = await authenticate(options)

@@ -113,3 +122,3 @@ expect(user).toBeTruthy()

ldapOpts: {
url: 'ldap://ldap.forumsys.com',
url: url,
},

@@ -123,6 +132,7 @@ adminDn: 'cn=read-only-admin,dc=example,dc=com',

groupsSearchBase: 'dc=example,dc=com',
groupClass: 'groupOfUniqueNames',
groupMemberAttribute: 'uniqueMember',
groupClass: 'groupOfNames',
groupMemberAttribute: 'member',
groupMemberUserAttribute: 'dn',
}
let user = await authenticate(options)

@@ -135,5 +145,5 @@ expect(user).toBeTruthy()

ldapOpts: {
url: 'ldap://ldap.forumsys.com',
url: url,
},
userDn: 'uid=gauss,dc=example,dc=com',
userDn: 'cn=gauss,ou=users,dc=example,dc=com',
userPassword: 'password',

@@ -144,6 +154,7 @@ userSearchBase: 'dc=example,dc=com',

groupsSearchBase: 'dc=example,dc=com',
groupClass: 'groupOfUniqueNames',
groupMemberAttribute: 'uniqueMember',
groupClass: 'groupOfNames',
groupMemberAttribute: 'member',
groupMemberUserAttribute: 'dn',
}
let user = await authenticate(options)

@@ -156,5 +167,5 @@ expect(user).toBeTruthy()

ldapOpts: {
url: 'ldap://ldap.forumsys.com',
url: url,
},
userDn: 'uid=gauss,dc=example,dc=com',
userDn: 'cn=gauss,ou=users,dc=example,dc=com',
userPassword: 'password',

@@ -167,2 +178,3 @@ userSearchBase: 'dc=example,dc=com',

}
let user = await authenticate(options)

@@ -178,3 +190,3 @@ expect(user).toBeTruthy()

ldapOpts: {
url: 'ldap://ldap.forumsys.com',
url: url,
},

@@ -188,2 +200,3 @@ adminDn: 'cn=not-exist,dc=example,dc=com',

}
let e = null

@@ -195,2 +208,3 @@ try {

}
expect(e).toBeTruthy()

@@ -201,3 +215,3 @@ })

ldapOpts: {
url: 'ldap://ldap.forumsys.com',
url: url,
},

@@ -211,2 +225,3 @@ adminDn: 'cn=read-only-admin,dc=example,dc=com',

}
let e = null

@@ -218,2 +233,3 @@ try {

}
expect(e).toBeTruthy()

@@ -224,3 +240,3 @@ })

ldapOpts: {
url: 'ldap://ldap.forumsys.com',
url: url,
},

@@ -234,2 +250,3 @@ adminDn: 'cn=read-only-admin,dc=example,dc=com',

}
let e = null

@@ -241,2 +258,3 @@ try {

}
expect(e).toBeTruthy()

@@ -247,3 +265,3 @@ })

ldapOpts: {
url: 'ldap://ldap.forumsys.com',
url: url,
},

@@ -257,2 +275,3 @@ adminDn: 'cn=read-only-admin,dc=example,dc=com',

}
let e = null

@@ -264,2 +283,3 @@ try {

}
expect(e).toBeTruthy()

@@ -270,3 +290,3 @@ })

ldapOpts: {
url: 'ldap://ldap.forumsys.com',
url: url,
},

@@ -279,2 +299,3 @@ userDn: 'cn=not-exist,dc=example,dc=com',

}
let e = null

@@ -286,2 +307,3 @@ try {

}
expect(e).toBeTruthy()

@@ -292,3 +314,3 @@ })

ldapOpts: {
url: 'ldap://ldap.forumsys.com',
url: url,
},

@@ -301,2 +323,3 @@ userDn: 'cn=gauss,dc=example,dc=com',

}
let e = null

@@ -308,2 +331,3 @@ try {

}
expect(e).toBeTruthy()

@@ -314,3 +338,3 @@ })

ldapOpts: {
url: 'ldap://ldap.forumsys.com',
url: url,
},

@@ -320,2 +344,3 @@ userDn: 'uid=einstein,dc=example,dc=com',

}
try {

@@ -326,2 +351,3 @@ await authenticate(options)

}
expect(e).toBeTruthy()

@@ -332,10 +358,11 @@ })

ldapOpts: {
url: 'ldap://ldap.forumsys.com',
url: url,
},
userDn: 'uid=einstein,dc=example,dc=com',
userDn: 'cn=einstein,ou=users,dc=example,dc=com',
userPassword: 'password',
usernameAttribute: 'cn',
usernameAttribute: 'wrongattribute',
userSearchBase: 'dc=example,dc=com',
username: 'einstein',
}
try {

@@ -346,2 +373,3 @@ await authenticate(options)

}
expect(e).toBeTruthy()

@@ -362,2 +390,3 @@ expect(e).toBeInstanceOf(LdapAuthenticationError)

}
try {

@@ -368,2 +397,3 @@ await authenticate(options)

}
expect(e).toBeTruthy()

@@ -384,2 +414,3 @@ })

}
try {

@@ -390,2 +421,3 @@ await authenticate(options)

}
expect(e).toBeTruthy()

@@ -396,5 +428,5 @@ })

ldapOpts: {
url: 'ldap://ldap.forumsys.com',
url: url,
},
userDn: 'uid=gauss,dc=example,dc=com',
userDn: 'cn=gauss,ou=users,dc=example,dc=com',
userPassword: 'password',

@@ -405,6 +437,7 @@ userSearchBase: 'dc=example,dc=com',

groupsSearchBase: 'dc=example,dc=com',
groupClass: 'groupOfUniqueNames',
groupMemberAttribute: 'uniqueMember',
groupMemberUserAttribute: 'notARealGroupMemberUserAttribute',
groupClass: 'groupOfNames',
groupMemberAttribute: 'member',
groupMemberUserAttribute: 'dnWRONG',
}
let user = await authenticate(options)

@@ -411,0 +444,0 @@ expect(user).toBeTruthy()

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