Skip to content

Commit 5fd2645

Browse files
committed
2 parents e69d7c8 + a7f5c8d commit 5fd2645

4 files changed

Lines changed: 83 additions & 23 deletions

File tree

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
# [0.7.0](https://github.com/open-inc/node-parse-server-ldap/compare/v0.6.8...v0.7.0) (2025-07-04)
2+
3+
4+
### Bug Fixes
5+
6+
* ensure session token after signup ([164cf7f](https://github.com/open-inc/node-parse-server-ldap/commit/164cf7f0dc9c7158c032bf975f22066dda6e379b))
7+
8+
9+
### Features
10+
11+
* introduce env variable for tls option rejectUnauthorized ([ce1422c](https://github.com/open-inc/node-parse-server-ldap/commit/ce1422c11ef66f80b7b24a7e56f14484ba3ce73c))
12+
* set default tenant using env variable ([8e5b964](https://github.com/open-inc/node-parse-server-ldap/commit/8e5b9646696b6dc236e2a7007de57a76e6388bf7))
13+
114
## [0.6.8](https://github.com/open-inc/node-parse-server-ldap/compare/v0.6.7...v0.6.8) (2025-06-04)
215

316

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@openinc/parse-server-ldap",
3-
"version": "0.6.8",
3+
"version": "0.7.0",
44
"description": "Parse Server Cloud Code to authenticate with LDAP/AD",
55
"packageManager": "pnpm@10.12.4",
66
"type": "module",

pnpm-lock.yaml

Lines changed: 52 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ let PARSE_LDAP_EXPIRE_LENGTH = process.env.PARSE_LDAP_EXPIRE_LENGTH
3535
: new Date(Date.now() + 1000 * 60 * 60 * 24 * 365);
3636

3737
const PARSE_LDAP_UNIFY_CREDENTIALS = process.env.PARSE_LDAP_UNIFY_CREDENTIALS === "true";
38+
const PARSE_LDAP_DEFAULT_TENANT_ID = process.env.PARSE_LDAP_DEFAULT_TENANT_ID || undefined;
39+
const PARSE_LDAP_REJECT_UNAUTHORIZED = process.env.PARSE_LDAP_REJECT_UNAUTHORIZED === "true";
40+
41+
const clientOptions = PARSE_LDAP_REJECT_UNAUTHORIZED ? {url: PARSE_LDAP_URL} : {url: PARSE_LDAP_URL, tlsOptions: {rejectUnauthorized: false}};
3842

3943
export async function init() {
4044
if (!PARSE_LDAP_URL) {
@@ -169,9 +173,17 @@ export async function init() {
169173
user_c.set(PARSE_LDAP_PARSE_LDAP_DN_ATTRIBUTE, user.dn);
170174
user_c.set("password", token);
171175

176+
if (PARSE_LDAP_DEFAULT_TENANT_ID !== undefined) {
177+
const tenant = new Parse.Object("OD3_Tenant");
178+
tenant.id = PARSE_LDAP_DEFAULT_TENANT_ID;
179+
user_c.set("tenant", tenant);
180+
}
181+
172182
await user_c.signUp();
173183

174-
return { ...user, session: user_c.getSessionToken() };
184+
const user_b = await Parse.User.logIn(user.username as string, token);
185+
186+
return { ...user, session: user_b.getSessionToken() };
175187
} catch (error) {
176188
console.error(error);
177189

@@ -181,7 +193,7 @@ export async function init() {
181193
}
182194

183195
async function validateCredentials(username: string, password: string) {
184-
const client = new Client({ url: PARSE_LDAP_URL });
196+
const client = new Client(clientOptions);
185197

186198
try {
187199
const user = username;
@@ -273,7 +285,7 @@ async function getBindPath(params: Record<string, string>) {
273285
return replaceParams(PARSE_LDAP_LOGIN_BIND_DN, params);
274286
}
275287

276-
const client = new Client({ url: PARSE_LDAP_URL });
288+
const client = new Client(clientOptions);
277289

278290
try {
279291
await client.bind(
@@ -307,7 +319,7 @@ async function getBindPath(params: Record<string, string>) {
307319
}
308320

309321
async function validateGroupMember(dn: string | string[] | Buffer | Buffer[]): Promise<boolean> {
310-
const client = new Client({ url: PARSE_LDAP_URL });
322+
const client = new Client(clientOptions);
311323

312324
try {
313325
await client.bind(
@@ -346,7 +358,7 @@ async function validateGroupMember(dn: string | string[] | Buffer | Buffer[]): P
346358
}
347359

348360
async function getValidGroupMembers() {
349-
const client = new Client({ url: PARSE_LDAP_URL });
361+
const client = new Client(clientOptions);
350362

351363
try {
352364
await client.bind(

0 commit comments

Comments
 (0)