Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

have "Verify user exists" mode reflect attributes option #68

Merged
merged 1 commit into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading