mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-06 14:27:59 +00:00
misc: fixed log clipping and added idempotency to session end
This commit is contained in:
@@ -152,6 +152,13 @@ export const pamSessionServiceFactory = ({
|
|||||||
OrgPermissionSubjects.Gateway
|
OrgPermissionSubjects.Gateway
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (session.status === PamSessionStatus.Ended) {
|
||||||
|
return {
|
||||||
|
session,
|
||||||
|
projectId: project.id
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
if (session.status !== PamSessionStatus.Active) {
|
if (session.status !== PamSessionStatus.Active) {
|
||||||
throw new BadRequestError({ message: "Cannot end sessions that are not active" });
|
throw new BadRequestError({ message: "Cannot end sessions that are not active" });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import ms from "ms";
|
|||||||
|
|
||||||
import { createNotification } from "@app/components/notifications";
|
import { createNotification } from "@app/components/notifications";
|
||||||
import { Button, FormLabel, Input, Modal, ModalClose, ModalContent } from "@app/components/v2";
|
import { Button, FormLabel, Input, Modal, ModalClose, ModalContent } from "@app/components/v2";
|
||||||
import { TPamAccount } from "@app/hooks/api/pam";
|
import { PamResourceType, TPamAccount } from "@app/hooks/api/pam";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
account?: TPamAccount;
|
account?: TPamAccount;
|
||||||
@@ -19,7 +19,10 @@ export const PamAccessAccountModal = ({ isOpen, onOpenChange, account }: Props)
|
|||||||
const isDurationValid = useMemo(() => duration && ms(duration || "1s") > 0, [duration]);
|
const isDurationValid = useMemo(() => duration && ms(duration || "1s") > 0, [duration]);
|
||||||
|
|
||||||
const command = useMemo(
|
const command = useMemo(
|
||||||
() => (account ? `infisical pam access ${account.id} --duration ${duration}` : ""),
|
() =>
|
||||||
|
account && account.resource.resourceType === PamResourceType.Postgres
|
||||||
|
? `infisical pam db access-account ${account.id} --duration ${duration}`
|
||||||
|
: "",
|
||||||
[account, duration]
|
[account, duration]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ export const PamSessionLogsSection = ({ session }: Props) => {
|
|||||||
<div className="flex items-center border-b border-mineshaft-400 pb-4">
|
<div className="flex items-center border-b border-mineshaft-400 pb-4">
|
||||||
<h3 className="text-lg font-semibold text-mineshaft-100">Session Logs</h3>
|
<h3 className="text-lg font-semibold text-mineshaft-100">Session Logs</h3>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex grow flex-col gap-4 text-xs">
|
<div className="flex grow flex-col gap-4 overflow-y-auto text-xs">
|
||||||
{session.commandLogs.length > 0 ? (
|
{session.commandLogs.length > 0 ? (
|
||||||
session.commandLogs.map((log) => (
|
session.commandLogs.map((log) => (
|
||||||
<div key={log.timestamp} className="flex flex-col">
|
<div key={log.timestamp} className="flex flex-col">
|
||||||
@@ -22,8 +22,12 @@ export const PamSessionLogsSection = ({ session }: Props) => {
|
|||||||
<span>{new Date(log.timestamp).toLocaleString()}</span>
|
<span>{new Date(log.timestamp).toLocaleString()}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="whitespace-pre-wrap font-mono">{log.input}</div>
|
<div className="overflow-hidden whitespace-pre-wrap break-all font-mono">
|
||||||
<div className="whitespace-pre-wrap font-mono text-bunker-300">{log.output}</div>
|
{log.input}
|
||||||
|
</div>
|
||||||
|
<div className="overflow-hidden whitespace-pre-wrap break-all font-mono text-bunker-300">
|
||||||
|
{log.output}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
))
|
))
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
Reference in New Issue
Block a user