Skip to content

Commit

Permalink
have "Verify user exists" mode reflect attributes option (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikecat committed Aug 7, 2024
1 parent 02f8840 commit 65bbdf6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,8 @@ async function authenticate(options) {
options.groupsSearchBase,
options.groupClass,
options.groupMemberAttribute,
options.groupMemberUserAttribute
options.groupMemberUserAttribute,
options.attributes
)
}
assert(options.userPassword, 'userPassword must be provided')
Expand Down
20 changes: 20 additions & 0 deletions test/test.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,26 @@ describe('ldap-authentication test', () => {
expect(user).toBeTruthy()
expect(user.uid).toEqual('gauss')
})
it('Use an admin user to check if user exists and return attributes', async () => {
let options = {
ldapOpts: {
url: url,
},
adminDn: 'cn=read-only-admin,dc=example,dc=com',
adminPassword: 'password',
verifyUserExists: true,
userSearchBase: 'dc=example,dc=com',
usernameAttribute: 'uid',
username: 'gauss',
attributes: ['uid', 'sn'],
}

let user = await authenticate(options)
expect(user).toBeTruthy()
expect(user.uid).toEqual('gauss')
expect(user.sn).toEqual('Bar1')
expect(user.cn).toBeUndefined()
})
it('Use an admin user to authenticate a regular user', async () => {
let options = {
ldapOpts: {
Expand Down

0 comments on commit 65bbdf6

Please sign in to comment.