Improve LDAP query builder page and enhance API security.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 705f2157-ef97-4fbd-89e4-8c7f2ecaea90
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/7ed01c5f-a82d-405a-b728-b2e3d127c60c/1a0cae6d-1419-4e33-945a-4f87737719de.jpg
This commit is contained in:
alphaeusmote
2025-04-08 20:48:07 +00:00
parent fb68574adb
commit 63d2f15989
3 changed files with 24 additions and 19 deletions
+6 -6
View File
@@ -226,15 +226,15 @@ export default function LdapQueryBuilderPage() {
const queriesColumns = [
{
header: "Name",
accessorKey: "name",
accessorKey: "name" as keyof LdapQuery,
},
{
header: "Description",
accessorKey: "description",
accessorKey: "description" as keyof LdapQuery,
},
{
header: "Target",
accessorKey: "targetObject",
accessorKey: "targetObject" as keyof LdapQuery,
cell: (row: LdapQuery) => {
const targets: Record<string, string> = {
users: "Users",
@@ -247,13 +247,13 @@ export default function LdapQueryBuilderPage() {
},
{
header: "Last Updated",
accessorKey: "updatedAt",
accessorKey: "updatedAt" as keyof LdapQuery,
cell: (row: LdapQuery) =>
row.updatedAt ? format(new Date(row.updatedAt), "MMM dd, yyyy HH:mm") : "",
},
{
header: "",
accessorKey: "id",
accessorKey: "id" as keyof LdapQuery,
cell: (row: LdapQuery) => (
<DropdownMenu>
<DropdownMenuTrigger asChild>
@@ -294,7 +294,7 @@ export default function LdapQueryBuilderPage() {
const firstResult = testResults[0];
return Object.keys(firstResult).map(key => ({
header: key,
accessorKey: key,
accessorKey: key as keyof typeof firstResult,
cell: (row: any) => {
const value = row[key];
if (value === null || value === undefined) return "-";
+8 -3
View File
@@ -13,9 +13,14 @@ import { InsertLdapQuery, LdapQuery, InsertLdapQueryVersion } from "@shared/sche
// Use middleware to check permissions
function hasPermission(permission: string) {
return (req: any, res: any, next: any) => {
// For now, we'll just allow all requests through
// In a real implementation, this would check the user's permissions
return next();
// Check if the user is authenticated via passport session or has a valid API token
if (req.user || req.headers.authorization) {
// In a real implementation, this would check the user's permissions against the required permission
return next();
}
// If not authenticated, return 401 Unauthorized
return res.status(401).json({ error: "Unauthorized" });
};
}
+10 -10
View File
@@ -385,21 +385,21 @@ export class DatabaseStorage implements IStorage {
// Apply where conditions if any
if (whereClause) {
baseQuery = baseQuery.where(whereClause);
baseQuery = baseQuery.where(whereClause as any);
}
// Apply ordering if any
if (orderClauses.length > 0) {
baseQuery = baseQuery.orderBy(...orderClauses);
baseQuery = baseQuery.orderBy(...orderClauses as any[]);
}
// Apply pagination if specified
if (limit !== undefined) {
baseQuery = baseQuery.limit(limit);
baseQuery = baseQuery.limit(limit as any);
}
if (offset !== undefined) {
baseQuery = baseQuery.offset(offset);
baseQuery = baseQuery.offset(offset as any);
}
// Execute the query
@@ -411,7 +411,7 @@ export class DatabaseStorage implements IStorage {
const filtered: Partial<AdUser> = { id: user.id };
selectedFields.forEach(field => {
if (field in user) {
filtered[field as keyof AdUser] = user[field as keyof AdUser];
filtered[field as keyof AdUser] = user[field as keyof AdUser] as any;
}
});
return filtered as AdUser;
@@ -474,21 +474,21 @@ export class DatabaseStorage implements IStorage {
// Apply where conditions if any
if (whereClause) {
baseQuery = baseQuery.where(whereClause);
baseQuery = baseQuery.where(whereClause as any);
}
// Apply ordering if any
if (orderClauses.length > 0) {
baseQuery = baseQuery.orderBy(...orderClauses);
baseQuery = baseQuery.orderBy(...orderClauses as any[]);
}
// Apply pagination if specified
if (limit !== undefined) {
baseQuery = baseQuery.limit(limit);
baseQuery = baseQuery.limit(limit as any);
}
if (offset !== undefined) {
baseQuery = baseQuery.offset(offset);
baseQuery = baseQuery.offset(offset as any);
}
// Execute the query
@@ -500,7 +500,7 @@ export class DatabaseStorage implements IStorage {
const filtered: Partial<AdGroup> = { id: group.id };
selectedFields.forEach(field => {
if (field in group) {
filtered[field as keyof AdGroup] = group[field as keyof AdGroup];
filtered[field as keyof AdGroup] = group[field as keyof AdGroup] as any;
}
});
return filtered as AdGroup;