Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

update view secret request by ID page

Scott Wilsone61d242b4ce6
diff --git a/frontend/src/components/v3/generic/Alert/Alert.tsx b/frontend/src/components/v3/generic/Alert/Alert.tsx
index 491ae17b88..6b74dedb8c 100644
--- a/frontend/src/components/v3/generic/Alert/Alert.tsx
+++ b/frontend/src/components/v3/generic/Alert/Alert.tsx
@@ -13,6 +13,7 @@ const alertVariants = cva(
default: "bg-container text-card-foreground",
info: "bg-info/5 text-info border-info/20",
warning: "bg-warning/5 text-warning border-warning/20",
+ success: "bg-success/5 text-success border-success/20",
danger: "bg-danger/5 text-danger border-danger/20",
org: "bg-org/5 text-org border-org/20",
"sub-org": "bg-sub-org/5 text-sub-org border-sub-org/20"
diff --git a/frontend/src/pages/public/ViewSecretRequestByIDPage/ViewSecretRequestByIDPage.tsx b/frontend/src/pages/public/ViewSecretRequestByIDPage/ViewSecretRequestByIDPage.tsx
index e63ccb765b..d34970801f 100644
--- a/frontend/src/pages/public/ViewSecretRequestByIDPage/ViewSecretRequestByIDPage.tsx
+++ b/frontend/src/pages/public/ViewSecretRequestByIDPage/ViewSecretRequestByIDPage.tsx
@@ -1,14 +1,21 @@
import { useEffect, useMemo, useState } from "react";
import { Helmet } from "react-helmet";
-import { faArrowRight } from "@fortawesome/free-solid-svg-icons";
-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { useNavigate, useParams } from "@tanstack/react-router";
import { AxiosError } from "axios";
import { addSeconds, formatISO } from "date-fns";
-import { twMerge } from "tailwind-merge";
+import { AuthPageBackground } from "@app/components/auth/AuthPageBackground";
+import { AuthPageFooter } from "@app/components/auth/AuthPageFooter";
+import { AuthPageHeader } from "@app/components/auth/AuthPageHeader";
import { createNotification } from "@app/components/notifications";
-import { Lottie } from "@app/components/v2";
+import {
+ Card,
+ CardContent,
+ CardDescription,
+ CardHeader,
+ CardTitle,
+ PageLoader
+} from "@app/components/v3";
import { SessionStorageKeys } from "@app/const";
import { ROUTE_PATHS } from "@app/const/routes";
import { TBrandingConfig, useGetSecretRequestById } from "@app/hooks/api/secretSharing";
@@ -16,7 +23,6 @@ import { TBrandingConfig, useGetSecretRequestById } from "@app/hooks/api/secretS
import {
adjustColor,
DEFAULT_FAVICON_URL,
- DEFAULT_LOGO_URL,
isLightColor
} from "../ViewSharedSecretByIDPage/ViewSharedSecretByIDPage";
import { SecretRequestErrorContainer } from "./components/SecretErrorContainer";
@@ -61,7 +67,6 @@ export const ViewSecretRequestByIDPage = () => {
useEffect(() => {
if (isUnauthorized && !isInvalidCredential) {
- // persist current URL in session storage so that we can come back to this after successful login
sessionStorage.setItem(
SessionStorageKeys.ORG_LOGIN_SUCCESS_REDIRECT_URL,
JSON.stringify({
@@ -75,9 +80,7 @@ export const ViewSecretRequestByIDPage = () => {
text: "Login is required in order to access the shared secret."
});
- navigate({
- to: "/login"
- });
+ navigate({ to: "/login" });
}
if (isForbidden) {
@@ -89,11 +92,13 @@ export const ViewSecretRequestByIDPage = () => {
}, [error]);
const brandingConfig = secretRequest?.brandingConfig || savedBrandingConfig;
- const hasCustomBranding = !!brandingConfig;
+ const hasCustomBranding =
+ !!brandingConfig &&
+ (brandingConfig.hasLogo || brandingConfig.hasFavicon || !!brandingConfig.primaryColor);
const logoUrl = brandingConfig?.hasLogo
? `/api/v1/shared-secrets/requests/${id}/branding/brand-logo`
- : DEFAULT_LOGO_URL;
+ : undefined;
const faviconUrl = brandingConfig?.hasFavicon
? `/api/v1/shared-secrets/requests/${id}/branding/brand-favicon`
: DEFAULT_FAVICON_URL;
@@ -110,10 +115,8 @@ export const ViewSecretRequestByIDPage = () => {
return {
primaryColor: primary,
secondaryColor: secondary,
- // Text colors based on secondary brightness (for components)
textColor: isSecondaryLight ? "#1a1a1a" : "#f5f5f5",
textMutedColor: isSecondaryLight ? "#1a1a1acc" : "#f5f5f5cc",
- // Panel and components based on secondary color
panelBg: secondary,
panelBorder: adjustColor(secondary, isSecondaryLight ? -30 : 30),
inputBg: adjustColor(secondary, isSecondaryLight ? -15 : 15),
@@ -159,170 +162,108 @@ export const ViewSecretRequestByIDPage = () => {
if (isPending) {
return (
- <div className="flex h-screen w-screen items-center justify-center bg-bunker-800">
- <Lottie isAutoPlay icon="infisical_loading" className="h-32 w-32" />
+ <div className="h-screen w-screen bg-bunker-800">
+ <PageLoader lottieClassName="w-34" />;
</div>
);
}
- return (
+ const requestContent = (
<>
- <Helmet>
- <title>Securely Share Secrets{hasCustomBranding ? "" : " | Infisical"}</title>
- <meta property="og:image" content="/images/message.png" />
- <meta property="og:title" content="" />
- <meta name="og:description" content="" />
- </Helmet>
- <div
- className={twMerge(
- "flex h-screen flex-col justify-between overflow-auto text-gray-200 dark:scheme-dark",
- !backgroundStyle && "bg-linear-to-tr from-mineshaft-700 to-bunker-800"
+ {!error &&
+ !secretRequest?.error &&
+ secretRequest?.request &&
+ step === "set-value" &&
+ !secretRequest.isSecretValueSet && (
+ <SecretRequestContainer
+ onSuccess={() => setStep("success")}
+ secretRequestId={id}
+ brandingTheme={brandingTheme}
+ />
)}
- style={backgroundStyle}
- >
- <div />
- <div className="mx-auto w-full max-w-xl px-4 py-4 md:px-0">
- <div className="mb-8 text-center">
- <div className="mb-4 flex justify-center pt-8">
- {hasCustomBranding ? (
- <img
- src={logoUrl}
- height={90}
- width={120}
- alt="Logo"
- className="max-h-24 w-auto object-contain"
- />
- ) : (
- <a target="_blank" rel="noopener noreferrer" href="https://infisical.com">
- <img
- src={logoUrl}
- height={90}
- width={120}
- alt="Infisical logo"
- className="cursor-pointer"
- />
- </a>
- )}
- </div>
- <h1
- className={twMerge(
- "mb-2 bg-linear-to-b bg-clip-text text-center text-4xl font-medium text-transparent",
- brandingTheme && isLightColor(brandingTheme.primaryColor)
- ? "from-black to-bunker-500"
- : "from-white to-bunker-200"
- )}
- >
+ {secretRequest?.isSecretValueSet && (
+ <SecretValueAlreadySharedContainer brandingTheme={brandingTheme} />
+ )}
+ {(secretRequest?.error || (error && !isInvalidCredential && !isUnauthorized)) && (
+ <SecretRequestErrorContainer brandingTheme={brandingTheme} error={secretRequest?.error} />
+ )}
+ {step === "success" && (
+ <SecretRequestSuccessContainer
+ requesterUsername={secretRequest!.request.requester.username}
+ brandingTheme={brandingTheme}
+ />
+ )}
+ </>
+ );
+
+ const requesterInfo = secretRequest?.request ? (
+ <CardDescription>
+ Secret requested by {secretRequest.request.requester.username}
+ {!hasCustomBranding && (
+ <> from the {secretRequest.request.requester.organizationName} organization</>
+ )}
+ </CardDescription>
+ ) : null;
+
+ // Custom branding: minimal layout with brand colors, no Infisical elements
+ if (hasCustomBranding) {
+ return (
+ <>
+ <Helmet>
+ <title>Secret Request</title>
+ <meta property="og:image" content="/images/message.png" />
+ </Helmet>
+ <div
+ className="flex min-h-screen flex-col items-center justify-center overflow-auto px-4 py-10 scheme-dark"
+ style={backgroundStyle}
+ >
+ {logoUrl && (
+ <img src={logoUrl} alt="Logo" className="mb-8 max-h-16 w-auto object-contain" />
+ )}
+ <div
+ className="w-full max-w-xl rounded-lg border p-5"
+ style={{
+ backgroundColor: brandingTheme?.panelBg,
+ borderColor: brandingTheme?.panelBorder,
+ color: brandingTheme?.textColor
+ }}
+ >
+ <h1 className="mb-1 text-lg font-semibold" style={{ color: brandingTheme?.textColor }}>
{step === "set-value" ? "Secret Request" : "Secret request shared"}
</h1>
{secretRequest?.request && (
- <p
- className="text-sm"
- style={brandingTheme ? { color: brandingTheme.textMutedColor } : undefined}
- >
+ <p className="mb-5 text-sm" style={{ color: brandingTheme?.textMutedColor }}>
Secret requested by {secretRequest.request.requester.username}
- {!hasCustomBranding && (
- <> from the {secretRequest.request.requester.organizationName} organization</>
- )}
- </p>
- )}
- {!hasCustomBranding && (
- <p className="text-md mt-2">
- Powered by{" "}
- <a
- href="https://github.com/infisical/infisical"
- target="_blank"
- rel="noopener noreferrer"
- className="text-bold bg-linear-to-tr from-yellow-500 to-primary-500 bg-clip-text text-transparent"
- >
- Infisical &rarr;
- </a>
</p>
)}
+ {requestContent}
</div>
- {!isPending && (
- <>
- {!error &&
- !secretRequest?.error &&
- secretRequest?.request &&
- step === "set-value" &&
- !secretRequest.isSecretValueSet && (
- <SecretRequestContainer
- onSuccess={() => setStep("success")}
- secretRequestId={id}
- brandingTheme={brandingTheme}
- />
- )}
- {secretRequest?.isSecretValueSet && (
- <SecretValueAlreadySharedContainer brandingTheme={brandingTheme} />
- )}
- {(secretRequest?.error || (error && !isInvalidCredential && !isUnauthorized)) && (
- <SecretRequestErrorContainer
- brandingTheme={brandingTheme}
- error={secretRequest?.error}
- />
- )}
- {step === "success" && (
- <SecretRequestSuccessContainer
- requesterUsername={secretRequest!.request.requester.username}
- brandingTheme={brandingTheme}
- />
- )}
- </>
- )}
- {!hasCustomBranding && (
- <>
- <div className="m-auto my-8 flex w-full">
- <div className="w-full border-t border-mineshaft-600" />
- </div>
- <div className="m-auto flex w-full flex-col rounded-md border border-primary-500/30 bg-primary/5 p-6 pt-5">
- <p className="w-full pb-2 text-lg font-medium text-mineshaft-100 md:pb-3 md:text-xl">
- Open source{" "}
- <span className="bg-linear-to-tr from-yellow-500 to-primary-500 bg-clip-text text-transparent">
- secret management
- </span>{" "}
- for developers
- </p>
- <div className="flex flex-col items-start sm:flex-row sm:items-center">
- <p className="md:text-md text-md mr-4">
- <a
- href="https://github.com/infisical/infisical"
- target="_blank"
- rel="noopener noreferrer"
- className="text-bold bg-linear-to-tr from-yellow-500 to-primary-500 bg-clip-text text-transparent"
- >
- Infisical
- </a>{" "}
- is the all-in-one secret management platform to securely manage secrets,
- configs, and certificates across your team and infrastructure.
- </p>
- <div className="mt-4 cursor-pointer sm:mt-0">
- <a target="_blank" rel="noopener noreferrer" href="https://infisical.com">
- <div className="flex items-center justify-between rounded-md border border-mineshaft-400/40 bg-mineshaft-600 px-3 py-2 duration-200 hover:border-primary/60 hover:bg-primary/20 hover:text-white">
- <p className="mr-4 whitespace-nowrap">Try Infisical</p>
- <FontAwesomeIcon icon={faArrowRight} />
- </div>
- </a>
- </div>
- </div>
- </div>
- </>
- )}
</div>
- {hasCustomBranding ? (
- <div />
- ) : (
- <div className="w-full bg-mineshaft-600 p-2">
- <p className="text-center text-sm text-mineshaft-300">
- Made with ❤️ by{" "}
- <a className="text-primary" href="https://infisical.com">
- Infisical
- </a>
- <br />
- 235 2nd st, San Francisco, California, 94105, United States. 🇺🇸
- </p>
- </div>
- )}
+ </>
+ );
+ }
+
+ // Default: Infisical auth page layout
+ return (
+ <div className="relative flex max-h-screen min-h-screen flex-col overflow-y-auto bg-bunker-800 px-4 text-foreground scheme-dark">
+ <AuthPageBackground />
+ <Helmet>
+ <title>Secret Request | Infisical</title>
+ <meta property="og:image" content="/images/message.png" />
+ </Helmet>
+ <AuthPageHeader />
+ <div className="relative z-10 my-auto flex flex-col items-center py-10">
+ <Card className="w-full max-w-xl">
+ <CardHeader>
+ <CardTitle>
+ {step === "set-value" ? "Secret Request" : "Secret request shared"}
+ </CardTitle>
+ {requesterInfo}
+ </CardHeader>
+ <CardContent>{requestContent}</CardContent>
+ </Card>
</div>
- </>
+ <AuthPageFooter />
+ </div>
);
};
diff --git a/frontend/src/pages/public/ViewSecretRequestByIDPage/components/SecretErrorContainer.tsx b/frontend/src/pages/public/ViewSecretRequestByIDPage/components/SecretErrorContainer.tsx
index 21a5f60b8d..701004d380 100644
--- a/frontend/src/pages/public/ViewSecretRequestByIDPage/components/SecretErrorContainer.tsx
+++ b/frontend/src/pages/public/ViewSecretRequestByIDPage/components/SecretErrorContainer.tsx
@@ -1,5 +1,6 @@
import { TriangleAlertIcon } from "lucide-react";
-import { twMerge } from "tailwind-merge";
+
+import { Alert, AlertTitle } from "@app/components/v3";
import { BrandingTheme } from "../../ViewSharedSecretByIDPage/ViewSharedSecretByIDPage";
@@ -18,20 +19,13 @@ export const SecretRequestErrorContainer = ({ error, brandingTheme }: Props) =>
: undefined;
return (
- <div
- className={twMerge(
- "rounded-lg border p-6",
- !brandingTheme && "border-mineshaft-600 bg-mineshaft-800"
- )}
- style={panelStyle}
- >
- <div className="flex items-center gap-4">
- <TriangleAlertIcon
- className="shrink-0"
- style={{ color: brandingTheme?.textMutedColor || "orangered" }}
- />
- <span>{error || "The secret request you are looking for is missing or has expired."}</span>
- </div>
- </div>
+ <Alert variant={brandingTheme ? "default" : "danger"} style={panelStyle}>
+ <TriangleAlertIcon
+ style={brandingTheme ? { color: brandingTheme.textMutedColor } : undefined}
+ />
+ <AlertTitle>
+ {error || "The secret request you are looking for is missing or has expired."}
+ </AlertTitle>
+ </Alert>
);
};
diff --git a/frontend/src/pages/public/ViewSecretRequestByIDPage/components/SecretRequestContainer.tsx b/frontend/src/pages/public/ViewSecretRequestByIDPage/components/SecretRequestContainer.tsx
index 0ea07d6da5..31ecc854ed 100644
--- a/frontend/src/pages/public/ViewSecretRequestByIDPage/components/SecretRequestContainer.tsx
+++ b/frontend/src/pages/public/ViewSecretRequestByIDPage/components/SecretRequestContainer.tsx
@@ -1,10 +1,10 @@
import { Controller, FormProvider, useForm } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";
-import { ArrowRightIcon } from "lucide-react";
+import { ForwardIcon } from "lucide-react";
+import { twMerge } from "tailwind-merge";
import { z } from "zod";
-import { FormControl, TextArea } from "@app/components/v2";
-import { Button } from "@app/components/v3";
+import { Button, Field, FieldError, FieldLabel, TextArea } from "@app/components/v3";
import { useSetSecretRequestValue } from "@app/hooks/api";
import { BrandingTheme } from "../../ViewSharedSecretByIDPage/ViewSharedSecretByIDPage";
@@ -45,54 +45,59 @@ export const SecretRequestContainer = ({ brandingTheme, onSuccess, secretRequest
: undefined;
const inputStyle = brandingTheme
- ? {
+ ? ({
backgroundColor: brandingTheme.inputBg,
color: brandingTheme.textColor,
"--muted-color": brandingTheme.textMutedColor,
borderColor: brandingTheme.panelBorder
- }
+ } as React.CSSProperties)
: undefined;
return (
<FormProvider {...form}>
<form onSubmit={form.handleSubmit(onSubmit)}>
- <div
- className={`flex flex-col rounded-lg border p-4 ${brandingTheme ? "" : "border-mineshaft-600 bg-mineshaft-800"}`}
- style={panelStyle}
- >
+ <div className="flex flex-col gap-4" style={panelStyle}>
<Controller
control={form.control}
name="secretValue"
render={({ field, fieldState: { error } }) => (
- <div style={brandingTheme ? { color: brandingTheme.textColor } : undefined}>
- <FormControl
- isError={Boolean(error)}
- errorText={error?.message}
- isRequired
- label="Secret Value"
- labelClassName="text-[var(--muted-color)]"
+ <Field style={brandingTheme ? { color: brandingTheme.textColor } : undefined}>
+ <FieldLabel
+ className={brandingTheme ? "text-[var(--muted-color)]" : ""}
+ style={
+ brandingTheme
+ ? ({ "--muted-color": brandingTheme.textMutedColor } as React.CSSProperties)
+ : undefined
+ }
>
- <TextArea
- {...field}
- rows={10}
- reSize="none"
- style={inputStyle}
- className="border placeholder-[var(--muted-color)]/70 focus:ring-[var(--muted-color)]/50"
- />
- </FormControl>
- </div>
+ Secret Value
+ </FieldLabel>
+ <TextArea
+ {...field}
+ rows={10}
+ className={twMerge(
+ "resize-none",
+ brandingTheme &&
+ "border placeholder-[var(--muted-color)]/70 focus-visible:ring-[var(--muted-color)]/50"
+ )}
+ style={inputStyle}
+ aria-invalid={Boolean(error)}
+ />
+ {error && <FieldError>{error.message}</FieldError>}
+ </Field>
)}
/>
<Button
isPending={isPending}
- isDisabled={isPending}
- variant="neutral"
- className="w-full"
+ isDisabled={isPending || !form.formState.isValid}
+ variant="project"
+ isFullWidth
+ size="lg"
type="submit"
style={inputStyle}
>
Share Secret
- <ArrowRightIcon />
+ <ForwardIcon />
</Button>
</div>
</form>
diff --git a/frontend/src/pages/public/ViewSecretRequestByIDPage/components/SecretRequestSuccessContainer.tsx b/frontend/src/pages/public/ViewSecretRequestByIDPage/components/SecretRequestSuccessContainer.tsx
index ecb1e01a48..1dacc6c65c 100644
--- a/frontend/src/pages/public/ViewSecretRequestByIDPage/components/SecretRequestSuccessContainer.tsx
+++ b/frontend/src/pages/public/ViewSecretRequestByIDPage/components/SecretRequestSuccessContainer.tsx
@@ -1,5 +1,6 @@
-import { CircleCheckBigIcon } from "lucide-react";
-import { twMerge } from "tailwind-merge";
+import { CheckCircleIcon } from "lucide-react";
+
+import { Alert, AlertDescription, AlertTitle } from "@app/components/v3";
import { BrandingTheme } from "../../ViewSharedSecretByIDPage/ViewSharedSecretByIDPage";
@@ -10,37 +11,23 @@ type Props = {
export const SecretRequestSuccessContainer = ({ brandingTheme, requesterUsername }: Props) => {
const panelStyle = brandingTheme
- ? {
+ ? ({
backgroundColor: brandingTheme.panelBg,
color: brandingTheme.textColor,
- "--muted-color": brandingTheme.textMutedColor,
borderColor: brandingTheme.panelBorder
- }
+ } as React.CSSProperties)
: undefined;
return (
- <div
- className={twMerge(
- "rounded-lg border p-6",
- !brandingTheme && "border-mineshaft-600 bg-mineshaft-800"
- )}
- style={panelStyle}
- >
- <div className="flex items-center gap-4">
- <CircleCheckBigIcon
- className="size-8 shrink-0"
- style={{ color: brandingTheme?.textMutedColor || "white" }}
- />
- <div className="flex flex-col">
- <span className="font-medium">Secret Shared</span>
- <span
- className={`text-sm ${brandingTheme ? "text-[var(--muted-color)]" : "text-mineshaft-300"}`}
- >
- <strong>{requesterUsername}</strong> has now been notified of your shared secret, and
- will be able to access it shortly.
- </span>
- </div>
- </div>
- </div>
+ <Alert variant={brandingTheme ? "default" : "success"} style={panelStyle}>
+ <CheckCircleIcon
+ style={brandingTheme ? { color: brandingTheme.textMutedColor } : undefined}
+ />
+ <AlertTitle>Secret Shared</AlertTitle>
+ <AlertDescription style={brandingTheme ? { color: brandingTheme.textMutedColor } : undefined}>
+ {requesterUsername} has now been notified of your shared secret, and will be able to access
+ it shortly.
+ </AlertDescription>
+ </Alert>
);
};
diff --git a/frontend/src/pages/public/ViewSecretRequestByIDPage/components/SecretValueAlreadySharedContainer.tsx b/frontend/src/pages/public/ViewSecretRequestByIDPage/components/SecretValueAlreadySharedContainer.tsx
index e4fb626d73..35f5124099 100644
--- a/frontend/src/pages/public/ViewSecretRequestByIDPage/components/SecretValueAlreadySharedContainer.tsx
+++ b/frontend/src/pages/public/ViewSecretRequestByIDPage/components/SecretValueAlreadySharedContainer.tsx
@@ -1,5 +1,6 @@
import { KeyRoundIcon } from "lucide-react";
-import { twMerge } from "tailwind-merge";
+
+import { Alert, AlertDescription, AlertTitle } from "@app/components/v3";
import { BrandingTheme } from "../../ViewSharedSecretByIDPage/ViewSharedSecretByIDPage";
@@ -9,36 +10,20 @@ type Props = {
export const SecretValueAlreadySharedContainer = ({ brandingTheme }: Props) => {
const panelStyle = brandingTheme
- ? {
+ ? ({
backgroundColor: brandingTheme.panelBg,
color: brandingTheme.textColor,
- "--muted-color": brandingTheme.textMutedColor,
borderColor: brandingTheme.panelBorder
- }
+ } as React.CSSProperties)
: undefined;
return (
- <div
- className={twMerge(
- "rounded-lg border p-6",
- !brandingTheme && "border-mineshaft-600 bg-mineshaft-800"
- )}
- style={panelStyle}
- >
- <div className="flex items-center gap-4">
- <KeyRoundIcon
- className="size-8 shrink-0"
- style={{ color: brandingTheme?.textMutedColor || "white" }}
- />
- <div className="flex flex-col">
- <span className="font-medium">Secret Already Shared</span>
- <span
- className={`text-sm ${brandingTheme ? "text-[var(--muted-color)]" : "text-mineshaft-300"}`}
- >
- A secret value has already been shared for this secret request.
- </span>
- </div>
- </div>
- </div>
+ <Alert variant={brandingTheme ? "default" : "info"} style={panelStyle}>
+ <KeyRoundIcon style={brandingTheme ? { color: brandingTheme.textMutedColor } : undefined} />
+ <AlertTitle>Secret Already Shared</AlertTitle>
+ <AlertDescription style={brandingTheme ? { color: brandingTheme.textMutedColor } : undefined}>
+ A secret value has already been shared for this secret request.
+ </AlertDescription>
+ </Alert>
);
};