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

Fixed escaping error on LDAP filters #10297

Merged
merged 1 commit into from Dec 4, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions api/src/auth/drivers/ldap.ts
Expand Up @@ -2,6 +2,7 @@ import { Router } from 'express';
import ldap, {
Client,
Error,
EqualityFilter,
SearchCallbackResponse,
SearchEntry,
InappropriateAuthenticationError,
Expand Down Expand Up @@ -108,7 +109,10 @@ export class LDAPAuthDriver extends AuthDriver {
// Search for the user in LDAP by attribute
this.bindClient.search(
userDn,
{ filter: `(${userAttribute ?? 'cn'}=${identifier})`, scope: userScope ?? 'one' },
{
filter: new EqualityFilter({ attribute: userAttribute, value: identifier }),
scope: userScope ?? 'one',
},
(err: Error | null, res: SearchCallbackResponse) => {
if (err) {
reject(handleError(err));
Expand Down Expand Up @@ -186,7 +190,7 @@ export class LDAPAuthDriver extends AuthDriver {
groupDn,
{
attributes: ['cn'],
filter: `(${groupAttribute ?? 'member'}=${userDn})`,
filter: new EqualityFilter({ attribute: groupAttribute, value: userDn }),
scope: groupScope ?? 'one',
},
(err: Error | null, res: SearchCallbackResponse) => {
Expand Down