Add test connection btn for LDAP, update group search filter impl, update group search filter examples in docs

This commit is contained in:
Tuan Dang
2024-04-24 16:50:23 -07:00
parent 9992fbf3dd
commit 99d59a38d5
10 changed files with 192 additions and 42 deletions
@@ -37,8 +37,10 @@ import {
TGetLdapCfgDTO,
TGetLdapGroupMapsDTO,
TLdapLoginDTO,
TTestLdapConnectionDTO,
TUpdateLdapCfgDTO
} from "./ldap-config-types";
import { testLDAPConfig } from "./ldap-fns";
import { TLdapGroupMapDALFactory } from "./ldap-group-map-dal";
type TLdapConfigServiceFactoryDep = {
@@ -650,6 +652,23 @@ export const ldapConfigServiceFactory = ({
return deletedGroupMap;
};
const testLDAPConnection = async ({ actor, actorId, orgId, actorAuthMethod, actorOrgId }: TTestLdapConnectionDTO) => {
const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorAuthMethod, actorOrgId);
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Create, OrgPermissionSubjects.Ldap);
const plan = await licenseService.getPlan(orgId);
if (!plan.ldap)
throw new BadRequestError({
message: "Failed to test LDAP connection due to plan restriction. Upgrade plan to test the LDAP connection."
});
const ldapConfig = await getLdapCfg({
orgId
});
return testLDAPConfig(ldapConfig);
};
return {
createLdapCfg,
updateLdapCfg,
@@ -660,6 +679,7 @@ export const ldapConfigServiceFactory = ({
bootLdap,
getLdapGroupMaps,
createLdapGroupMap,
deleteLdapGroupMap
deleteLdapGroupMap,
testLDAPConnection
};
};