mirror of
https://github.com/fosrl/pangolin.git
synced 2026-05-27 19:22:50 +00:00
show user idp in devices
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import { Request, Response, NextFunction } from "express";
|
||||
import { z } from "zod";
|
||||
import { db, olms, users } from "@server/db";
|
||||
import { db, idp, idpOidcConfig, olms, users } from "@server/db";
|
||||
import { clients, currentFingerprint } from "@server/db";
|
||||
import { eq, and } from "drizzle-orm";
|
||||
import { and, eq } from "drizzle-orm";
|
||||
import response from "@server/lib/response";
|
||||
import HttpCode from "@server/types/HttpCode";
|
||||
import createHttpError from "http-errors";
|
||||
@@ -236,6 +236,9 @@ export type GetClientResponse = NonNullable<
|
||||
lastSeen: number | null;
|
||||
} | null;
|
||||
posture: PostureData | null;
|
||||
userType: string | null;
|
||||
idpName: string | null;
|
||||
idpVariant: string | null;
|
||||
};
|
||||
|
||||
registry.registerPath({
|
||||
@@ -337,6 +340,30 @@ export async function getClient(
|
||||
: maskPostureDataWithPlaceholder(rawPosture)
|
||||
: null;
|
||||
|
||||
let userType: string | null = null;
|
||||
let idpName: string | null = null;
|
||||
let idpVariant: string | null = null;
|
||||
|
||||
if (client.clients.userId) {
|
||||
const [idpRow] = await db
|
||||
.select({
|
||||
userType: users.type,
|
||||
idpName: idp.name,
|
||||
idpVariant: idpOidcConfig.variant
|
||||
})
|
||||
.from(users)
|
||||
.leftJoin(idp, eq(users.idpId, idp.idpId))
|
||||
.leftJoin(idpOidcConfig, eq(idpOidcConfig.idpId, idp.idpId))
|
||||
.where(eq(users.userId, client.clients.userId))
|
||||
.limit(1);
|
||||
|
||||
if (idpRow) {
|
||||
userType = idpRow.userType;
|
||||
idpName = idpRow.idpName;
|
||||
idpVariant = idpRow.idpVariant;
|
||||
}
|
||||
}
|
||||
|
||||
const data: GetClientResponse = {
|
||||
...client.clients,
|
||||
name: clientName,
|
||||
@@ -347,7 +374,10 @@ export async function getClient(
|
||||
userName: client.user?.name ?? null,
|
||||
userUsername: client.user?.username ?? null,
|
||||
fingerprint: fingerprintData,
|
||||
posture: postureData
|
||||
posture: postureData,
|
||||
userType,
|
||||
idpName,
|
||||
idpVariant
|
||||
};
|
||||
|
||||
return response<GetClientResponse>(res, {
|
||||
|
||||
@@ -3,6 +3,8 @@ import {
|
||||
clients,
|
||||
currentFingerprint,
|
||||
db,
|
||||
idp,
|
||||
idpOidcConfig,
|
||||
olms,
|
||||
orgs,
|
||||
roleClients,
|
||||
@@ -165,6 +167,9 @@ function queryUserDevicesBase() {
|
||||
userId: clients.userId,
|
||||
username: users.username,
|
||||
userEmail: users.email,
|
||||
userType: users.type,
|
||||
idpName: idp.name,
|
||||
idpVariant: idpOidcConfig.variant,
|
||||
niceId: clients.niceId,
|
||||
agent: olms.agent,
|
||||
approvalState: clients.approvalState,
|
||||
@@ -184,6 +189,8 @@ function queryUserDevicesBase() {
|
||||
.leftJoin(orgs, eq(clients.orgId, orgs.orgId))
|
||||
.leftJoin(olms, eq(clients.clientId, olms.clientId))
|
||||
.leftJoin(users, eq(clients.userId, users.userId))
|
||||
.leftJoin(idp, eq(users.idpId, idp.idpId))
|
||||
.leftJoin(idpOidcConfig, eq(idpOidcConfig.idpId, idp.idpId))
|
||||
.leftJoin(currentFingerprint, eq(olms.olmId, currentFingerprint.olmId));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user