Skip to content

Commit 198942f

Browse files
🐛 properly escape ldap string
1 parent 063a309 commit 198942f

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@
99
"start": "node ./out/src/app.js",
1010
"build": "tsc && shx cp ./src/openapi.yaml ./out/src/openapi.yaml",
1111
"openapi": "npx -y openapi-to-ts -i ./src/openapi.yaml -o ./src/types/sync-models.d.ts",
12-
"play": "ts-node playground.ts"
12+
"play": "ts-node playground.ts"
1313
},
1414
"author": "",
1515
"license": "ISC",
1616
"devDependencies": {
1717
"@types/express": "^4.17.17",
1818
"@types/js-yaml": "^4.0.5",
19+
"@types/ldap-escape": "^2.0.0",
1920
"@types/ldapjs": "^2.2.5",
2021
"@types/swagger-ui-express": "^4.1.3",
2122
"nodemon": "^2.0.21",
@@ -28,6 +29,7 @@
2829
"dotenv": "^16.0.3",
2930
"express": "^4.18.2",
3031
"js-yaml": "^4.1.0",
32+
"ldap-escape": "^2.0.6",
3133
"ldapjs": "^3.0.1",
3234
"octokit": "^2.0.14",
3335
"openapi-backend": "^5.9.1",

src/services/ldapClient.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Config } from "../config";
22
import ldap from "ldapjs";
3+
import ldapEscape from "ldap-escape";
34

45
const config = Config()
56

@@ -12,7 +13,7 @@ client.bind(config.LDAP.User, config.LDAP.Password, (err) => {
1213
});
1314

1415
function SearchAsync(groupName: string): Promise<any> {
15-
const component = encodeURIComponent(groupName);
16+
const component = ldapEscape.filter`${groupName}`;
1617
const ldapSearchString = `(&(objectCategory=user)(memberOf=CN=${component},CN=Users,${config.LDAP.GroupBaseDN}))`
1718

1819
const opts: ldap.SearchOptions = {

0 commit comments

Comments
 (0)