mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-14 06:29:37 +00:00
Refactor ldap filter validation
This commit is contained in:
@@ -40,7 +40,7 @@ import {
|
||||
TTestLdapConnectionDTO,
|
||||
TUpdateLdapCfgDTO
|
||||
} from "./ldap-config-types";
|
||||
import { isValidLdapFilter, testLDAPConfig } from "./ldap-fns";
|
||||
import { testLDAPConfig } from "./ldap-fns";
|
||||
import { TLdapGroupMapDALFactory } from "./ldap-group-map-dal";
|
||||
|
||||
type TLdapConfigServiceFactoryDep = {
|
||||
@@ -113,18 +113,6 @@ export const ldapConfigServiceFactory = ({
|
||||
"Failed to create LDAP configuration due to plan restriction. Upgrade plan to create LDAP configuration."
|
||||
});
|
||||
|
||||
const isSearchFilterValid = isValidLdapFilter(searchFilter);
|
||||
if (!isSearchFilterValid)
|
||||
throw new BadRequestError({
|
||||
message: "Failed to create LDAP configuration due to invalid search filter."
|
||||
});
|
||||
|
||||
const isGroupSearchFilterValid = isValidLdapFilter(groupSearchFilter);
|
||||
if (!isGroupSearchFilterValid)
|
||||
throw new BadRequestError({
|
||||
message: "Failed to create LDAP configuration due to invalid group search filter."
|
||||
});
|
||||
|
||||
const orgBot = await orgBotDAL.transaction(async (tx) => {
|
||||
const doc = await orgBotDAL.findOne({ orgId }, tx);
|
||||
if (doc) return doc;
|
||||
@@ -225,22 +213,6 @@ export const ldapConfigServiceFactory = ({
|
||||
"Failed to update LDAP configuration due to plan restriction. Upgrade plan to update LDAP configuration."
|
||||
});
|
||||
|
||||
if (searchFilter) {
|
||||
const isSearchFilterValid = isValidLdapFilter(searchFilter);
|
||||
if (!isSearchFilterValid)
|
||||
throw new BadRequestError({
|
||||
message: "Failed to update LDAP configuration due to invalid search filter."
|
||||
});
|
||||
}
|
||||
|
||||
if (groupSearchFilter) {
|
||||
const isGroupSearchFilterValid = isValidLdapFilter(groupSearchFilter);
|
||||
if (!isGroupSearchFilterValid)
|
||||
throw new BadRequestError({
|
||||
message: "Failed to update LDAP configuration due to invalid group search filter."
|
||||
});
|
||||
}
|
||||
|
||||
const updateQuery: TLdapConfigsUpdate = {
|
||||
isActive,
|
||||
url,
|
||||
|
||||
Reference in New Issue
Block a user